Skip to content

Commit

Permalink
Fix: Use lazy initialization for ServerService and MonitoringService …
Browse files Browse the repository at this point in the history
…to suppress depracation warnings for the majority of users
  • Loading branch information
onefloid authored and MariusWirtz committed Nov 12, 2024
1 parent 896dd41 commit 6cbd53f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions TM1py/Services/TM1Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ def __init__(self, **kwargs):
self.audit_logs = AuditLogService(self._tm1_rest)

#higher level modules
self.server = ServerService(self._tm1_rest)
self.monitoring = MonitoringService(self._tm1_rest)
self.power_bi = PowerBiService(self._tm1_rest)
self.loggers = LoggerService(self._tm1_rest)

self._server = None
self._monitoring = None

def logout(self, **kwargs):
self._tm1_rest.logout(**kwargs)

Expand All @@ -103,6 +104,18 @@ def __exit__(self, exception_type, exception_value, traceback):
self.logout()
except Exception as e:
warnings.warn(f"Logout Failed due to Exception: {e}")

@property
def server(self):
if not self._server:
self._server = ServerService(self._tm1_rest)
return self._server

@property
def monitoring(self):
if not self._monitoring:
self._monitoring = MonitoringService(self._tm1_rest)
return self._monitoring

@property
def whoami(self):
Expand Down

0 comments on commit 6cbd53f

Please sign in to comment.