Skip to content

Wk9874/fixing tests 2.1.2 #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_client_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
run: >-
python -m pytest tests/functional/ -x
-m online -c /dev/null -p no:warnings
-m online -m "not eco" -c /dev/null -p no:warnings
-n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
offline_functional_tests:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions simvue/factory/proxy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def __init__(
self._logger = logging.getLogger(f"simvue.{self.__class__.__name__}")
self._suppress_errors: bool = suppress_errors
self._uuid: str = uniq_id
self._name: str | None = name
self._id: int | None = None
self.name: str | None = name
self.id: int | None = None
self._aborted: bool = False

def _error(self, message: str) -> None:
Expand Down
8 changes: 4 additions & 4 deletions simvue/factory/proxy/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def create_run(self, data) -> tuple[str, str | None]:
self._logger.error("No directory specified")
return (None, None)

if not self._name:
self._name = randomname.get_name()
if not self.name:
self.name = randomname.get_name()

try:
os.makedirs(self._directory, exist_ok=True)
Expand All @@ -98,7 +98,7 @@ def create_run(self, data) -> tuple[str, str | None]:
filename = f"{self._directory}/{status}"
create_file(filename)

return self._name, self._id
return self.name, self.id

@skip_if_failed("_aborted", "_suppress_errors", None)
def update(self, data) -> dict[str, typing.Any] | None:
Expand Down Expand Up @@ -171,7 +171,7 @@ def set_alert_state(
with open(_alert_file) as alert_in:
_alert_data = json.load(alert_in)

_alert_data |= {"run": self._id, "alert": alert_id, "status": status}
_alert_data |= {"run": self.id, "alert": alert_id, "status": status}

self._write_json(_alert_file, _alert_data)

Expand Down
22 changes: 11 additions & 11 deletions simvue/factory/proxy/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def __init__(
}
super().__init__(name, uniq_id, suppress_errors)

self._id = uniq_id
self.id = uniq_id

@skip_if_failed("_aborted", "_suppress_errors", None)
def list_tags(self) -> list[str]:
logger.debug("Retrieving existing tags")
try:
response = get(
f"{self._user_config.server.url}/runs/{self._id}", self._headers
f"{self._user_config.server.url}/runs/{self.id}", self._headers
)
except Exception as err:
self._error(f"Exception retrieving tags: {str(err)}")
Expand Down Expand Up @@ -120,12 +120,12 @@ def create_run(self, data) -> tuple[str, str | None]:
return (None, None)

if "name" in response.json():
self._name = response.json()["name"]
self.name = response.json()["name"]

if "id" in response.json():
self._id = response.json()["id"]
self.id = response.json()["id"]

return self._name, self._id
return self.name, self.id

@skip_if_failed("_aborted", "_suppress_errors", None)
def update(
Expand All @@ -134,8 +134,8 @@ def update(
"""
Update metadata, tags or status
"""
if self._id:
data["id"] = self._id
if self.id:
data["id"] = self.id

logger.debug('Updating run with data: "%s"', data)

Expand Down Expand Up @@ -296,7 +296,7 @@ def save_file(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None
return None

if storage_id:
path = f"{self._user_config.server.url}/runs/{self._id}/artifacts"
path = f"{self._user_config.server.url}/runs/{self.id}/artifacts"
data["storage"] = storage_id

try:
Expand Down Expand Up @@ -350,7 +350,7 @@ def set_alert_state(self, alert_id, status) -> dict[str, typing.Any] | None:
"""
Set alert state
"""
data = {"run": self._id, "alert": alert_id, "status": status}
data = {"run": self.id, "alert": alert_id, "status": status}
try:
response = put(
f"{self._user_config.server.url}/alerts/status", self._headers, data
Expand Down Expand Up @@ -445,7 +445,7 @@ def send_heartbeat(self) -> dict[str, typing.Any] | None:
response = put(
f"{self._user_config.server.url}/runs/heartbeat",
self._headers,
{"id": self._id},
{"id": self.id},
)
except Exception as err:
self._error(f"Exception creating run: {str(err)}")
Expand All @@ -465,7 +465,7 @@ def get_abort_status(self) -> bool:

try:
response = get(
f"{self._user_config.server.url}/runs/{self._id}/abort",
f"{self._user_config.server.url}/runs/{self.id}/abort",
self._headers_mp,
)
except Exception as err:
Expand Down
22 changes: 16 additions & 6 deletions simvue/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def __exit__(
) -> None:
logger.debug(
"Automatically closing run '%s' in status %s",
self.id if self._user_config.run.mode == "online" else "unregistered",
self.id
if self._user_config.run.mode == "online" and self._sv_obj
else "unregistered",
self._status,
)

Expand Down Expand Up @@ -940,7 +942,10 @@ def executor(self) -> Executor:
def name(self) -> str | None:
"""Return the name of the run"""
if not self._sv_obj:
raise RuntimeError("Run has not been initialised")
logger.warning(
"Attempted to get name on non initialized run - returning None"
)
return None
return self._sv_obj.name

@property
Expand All @@ -954,7 +959,10 @@ def status(
):
"""Return the status of the run"""
if not self._sv_obj:
raise RuntimeError("Run has not been initialised")
logger.warning(
"Attempted to get name on non initialized run - returning cached value"
)
return self._status
return self._sv_obj.status

@property
Expand All @@ -966,7 +974,10 @@ def uid(self) -> str:
def id(self) -> str | None:
"""Return the unique id of the run"""
if not self._sv_obj:
raise RuntimeError("Run has not been initialised")
logger.warning(
"Attempted to get name on non initialized run - returning None"
)
return None
return self._sv_obj.id

@skip_if_failed("_aborted", "_suppress_errors", False)
Expand All @@ -986,9 +997,8 @@ def reconnect(self, run_id: str) -> bool:
"""
self._status = "running"

self._id = run_id
self._sv_obj = RunObject(identifier=run_id, _read_only=False)
self._name = self._sv_obj.name

self._sv_obj.status = self._status
self._sv_obj.system = get_system()
self._sv_obj.commit()
Expand Down
Loading
Loading