Skip to content

Commit 886f6c0

Browse files
committed
Added ability to specify profile for server in Run class
Also added specification of profile using SIMVUE_SERVER_PROFILE
1 parent d4e211c commit 886f6c0

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
- Added ability to specify above one server in the `simvue.toml` file using `profiles`.
6+
- Enforced keyword arguments for readability and certainty in intent within initialiser for `simvue.Run`.
7+
38
## [v2.3.0](https://github.com/simvue-io/client/releases/tag/v2.3.0) - 2025-12-11
49

510
- Refactored sender functionality introducing new `Sender` class.

simvue/config/user.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ def fetch(
189189
"""
190190
_config_dict: dict[str, dict[str, str]] = cls._load_pyproject_configs() or {}
191191

192+
profile = os.environ.get("SIMVUE_SERVER_PROFILE", profile)
193+
192194
try:
193195
# NOTE: Legacy INI support has been removed
194196
_config_dict |= toml.load(cls.config_file())

simvue/run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ class Run:
118118
@pydantic.validate_call
119119
def __init__(
120120
self,
121+
*,
121122
mode: typing.Literal["online", "offline", "disabled"] = "online",
122123
abort_callback: typing.Callable[[Self], None] | None = None,
123124
server_token: pydantic.SecretStr | None = None,
124125
server_url: str | None = None,
125126
debug: bool = False,
127+
server_profile: str = "default",
126128
) -> None:
127129
"""Initialise a new Simvue run
128130
@@ -143,6 +145,10 @@ def __init__(
143145
overwrite value for server URL, default is None
144146
debug : bool, optional
145147
run in debug mode, default is False
148+
server_profile : str, optional
149+
specify alternative profile to use for server, this assumes
150+
additional profiles have been specified in the configuration.
151+
Default is to use the main server.
146152
147153
Examples
148154
--------
@@ -185,7 +191,10 @@ def __init__(
185191
self._step: int = 0
186192
self._active: bool = False
187193
self._user_config: SimvueConfiguration = SimvueConfiguration.fetch(
188-
server_url=server_url, server_token=server_token, mode=mode
194+
server_url=server_url,
195+
server_token=server_token,
196+
mode=mode,
197+
profile=server_profile,
189198
)
190199

191200
logging.getLogger(self.__class__.__module__).setLevel(

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def create_test_run_offline(request, monkeypatch: pytest.MonkeyPatch, prevent_sc
158158
_ = prevent_script_exit
159159
with tempfile.TemporaryDirectory() as temp_d:
160160
monkeypatch.setenv("SIMVUE_OFFLINE_DIRECTORY", temp_d)
161-
with sv_run.Run("offline") as run:
161+
with sv_run.Run(mode="offline") as run:
162162
_test_run_data = setup_test_run(run, temp_dir=pathlib.Path(temp_d), create_objects=True, request=request)
163163
yield run, _test_run_data
164164
with contextlib.suppress(ObjectNotFoundError):
@@ -195,7 +195,7 @@ def create_plain_run_offline(request,prevent_script_exit,monkeypatch) -> Generat
195195
_ = prevent_script_exit
196196
with tempfile.TemporaryDirectory() as temp_d:
197197
monkeypatch.setenv("SIMVUE_OFFLINE_DIRECTORY", temp_d)
198-
with sv_run.Run("offline") as run:
198+
with sv_run.Run(mode="offline") as run:
199199
_temporary_directory = pathlib.Path(temp_d)
200200
yield run, setup_test_run(run, temp_dir=_temporary_directory, create_objects=False, request=request)
201201
clear_out_files()

0 commit comments

Comments
 (0)