Skip to content

Commit c176447

Browse files
committed
Change attribute name for configuration
1 parent 1e16f14 commit c176447

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

simvue/run.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,19 @@ def __init__(
159159
self._data: dict[str, typing.Any] = {}
160160
self._step: int = 0
161161
self._active: bool = False
162-
self._config = SimvueConfiguration.fetch()
162+
self._user_config = SimvueConfiguration.fetch()
163163

164164
logging.getLogger(self.__class__.__module__).setLevel(
165165
logging.DEBUG
166166
if (debug is not None and debug)
167-
or (debug is None and self._config.client.debug)
167+
or (debug is None and self._user_config.client.debug)
168168
else logging.INFO
169169
)
170170

171171
self._aborted: bool = False
172172
self._resources_metrics_interval: typing.Optional[int] = HEARTBEAT_INTERVAL
173173
self._headers: dict[str, str] = {
174-
"Authorization": f"Bearer {self._config.server.token}"
174+
"Authorization": f"Bearer {self._user_config.server.token}"
175175
}
176176
self._simvue: typing.Optional[SimvueBaseClass] = None
177177
self._pid: typing.Optional[int] = 0
@@ -313,7 +313,8 @@ def _create_heartbeat_callback(
313313
self,
314314
) -> typing.Callable[[threading.Event], None]:
315315
if (
316-
self._mode == "online" and (not self._config.server.url or not self._id)
316+
self._mode == "online"
317+
and (not self._user_config.server.url or not self._id)
317318
) or not self._heartbeat_termination_trigger:
318319
raise RuntimeError("Could not commence heartbeat, run not initialised")
319320

@@ -395,7 +396,7 @@ def _create_dispatch_callback(
395396
if self._mode == "online" and not self._id:
396397
raise RuntimeError("Expected identifier for run")
397398

398-
if not self._config.server.url:
399+
if not self._user_config.server.url:
399400
raise RuntimeError("Cannot commence dispatch, run not initialised")
400401

401402
def _offline_dispatch_callback(
@@ -404,7 +405,7 @@ def _offline_dispatch_callback(
404405
run_id: typing.Optional[str] = self._id,
405406
uuid: str = self._uuid,
406407
) -> None:
407-
_offline_directory = self._config.offline.cache
408+
_offline_directory = self._user_config.offline.cache
408409
if not os.path.exists(_offline_directory):
409410
logger.error(
410411
f"Cannot write to offline directory '{_offline_directory}', directory not found."
@@ -431,7 +432,7 @@ def _offline_dispatch_callback(
431432
def _online_dispatch_callback(
432433
buffer: list[typing.Any],
433434
category: str,
434-
url: str = self._config.server.url,
435+
url: str = self._user_config.server.url,
435436
run_id: typing.Optional[str] = self._id,
436437
headers: dict[str, str] = self._headers,
437438
) -> None:
@@ -634,11 +635,11 @@ def init(
634635
)
635636
return True
636637

637-
description = description or self._config.run.description
638-
tags = (tags or []) + (self._config.run.tags or [])
639-
folder = folder or self._config.run.folder
640-
name = name or self._config.run.name
641-
metadata = (metadata or {}) | (self._config.run.metadata or {})
638+
description = description or self._user_config.run.description
639+
tags = (tags or []) + (self._user_config.run.tags or [])
640+
folder = folder or self._user_config.run.folder
641+
name = name or self._user_config.run.name
642+
metadata = (metadata or {}) | (self._user_config.run.metadata or {})
642643

643644
self._term_color = not no_color
644645

@@ -651,7 +652,7 @@ def init(
651652
self._error("invalid mode specified, must be online, offline or disabled")
652653
return False
653654

654-
if not self._config.server.token or not self._config.server.url:
655+
if not self._user_config.server.token or not self._user_config.server.url:
655656
self._error(
656657
"Unable to get URL and token from environment variables or config file"
657658
)
@@ -707,7 +708,7 @@ def init(
707708
name=self._name,
708709
uniq_id=self._uuid,
709710
mode=self._mode,
710-
config=self._config,
711+
config=self._user_config,
711712
suppress_errors=self._suppress_errors,
712713
)
713714
name, self._id = self._simvue.create_run(data)
@@ -730,7 +731,7 @@ def init(
730731
fg="green" if self._term_color else None,
731732
)
732733
click.secho(
733-
f"[simvue] Monitor in the UI at {self._config.server.url}/dashboard/runs/run/{self._id}",
734+
f"[simvue] Monitor in the UI at {self._user_config.server.url}/dashboard/runs/run/{self._id}",
734735
bold=self._term_color,
735736
fg="green" if self._term_color else None,
736737
)
@@ -938,7 +939,7 @@ def reconnect(self, run_id: str) -> bool:
938939

939940
self._id = run_id
940941
self._simvue = Simvue(
941-
self._name, self._id, self._mode, self._config, self._suppress_errors
942+
self._name, self._id, self._mode, self._user_config, self._suppress_errors
942943
)
943944
self._start(reconnect=True)
944945

0 commit comments

Comments
 (0)