Skip to content

Commit fb7447c

Browse files
🧪 Add timeout to cleanup fcn (#129)
* update workflow before publishing python package * fix dependency issue and bump version * point to website in project description * fix broken dependency * improve doc * add github token to download artifacts * ensure only read-access @wvangeit * yet another attempt at downloading artifacts * make sure to use repo that ran the trigger wf * another attempt at fixing * change owner * allow publishing to testpypi also when pr * minor change * revert minor (but breaking) change * minor fix * add debug messages * another debug message * hopefully the final version * final fix * minor fix * move master and tag to individual jobs * add debug messages * dev->post * add python script for determining semantic version * minor changes * minor changes * improve error handling and add version file to artifacts * check if release * minor fix * ensure to enter venv * also when tagging * source venv in publishin workflow * ensure only master * add script for testing 'pure' semver * adapt workflows to new python script * minor change * attempt to evaluate expressions correctly * several fixes to fix tests * ensure repo is checked out in publish workflow * several small fixes * cleanup * debug * minor cleanup * mionr changes * add debug message * minor change * minor change * yet another try * minor change * minor change * minor change * mionr change * minor changes * correct workflow run id * cosmetic change * avoid using gh * change to a single job for publishing * minor cleanup * add retry to clean up * improve clean up fcn
1 parent 4506969 commit fb7447c

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

‎clients/python/test/e2e/ci/e2e/e2e/postprocess.py‎

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import configparser
22
import warnings
3+
from datetime import timedelta
34
from pathlib import Path
45
from typing import Optional
56
from urllib.parse import urlparse
@@ -8,6 +9,13 @@
89
import pandas as pd
910
import pytest
1011
import typer
12+
from pydantic import PositiveInt
13+
from tenacity import (
14+
Retrying,
15+
retry_if_exception_type,
16+
stop_after_attempt,
17+
stop_after_delay,
18+
)
1119

1220
from ._models import Artifacts, ClientSettings, PytestIniFile, ServerSettings
1321
from ._utils import E2eExitCodes, E2eScriptFailure, handle_validation_error
@@ -188,7 +196,7 @@ def log_dir(pytest_ini: Optional[Path] = None):
188196

189197

190198
@cli.command()
191-
def clean_up_jobs(artifacts_dir: Path):
199+
def clean_up_jobs(artifacts_dir: Path, retry_minutes: Optional[PositiveInt] = None):
192200
"""Loop through all users defined in pytest.ini files
193201
in artifacts_dir and stop+delete all jobs.
194202
"""
@@ -202,22 +210,31 @@ def clean_up_jobs(artifacts_dir: Path):
202210
cfg = {s: dict(obj.items(s)) for s in obj.sections()}
203211
server_config = ServerSettings.model_validate(cfg.get("server"))
204212
servers.add(server_config)
205-
for server_config in servers:
206-
config = osparc.Configuration(
207-
host=server_config.host,
208-
username=server_config.key,
209-
password=server_config.secret,
210-
)
211-
typer.echo(
212-
f"Cleaning up jobs for user:\n{server_config.model_dump_json(indent=1)}"
213-
)
214-
with osparc.ApiClient(config) as api_client:
215-
solvers_api = osparc.SolversApi(api_client)
216-
assert isinstance(solvers := solvers_api.list_solvers_releases(), list)
217-
for solver in solvers:
218-
assert isinstance(solver, osparc.Solver)
219-
assert (id_ := solver.id) is not None
220-
assert (version := solver.version) is not None
221-
for job in solvers_api.jobs(id_, version):
222-
assert isinstance(job, osparc.Job)
223-
solvers_api.delete_job(id_, version, job.id)
213+
for attempt in Retrying(
214+
retry=retry_if_exception_type(osparc.ApiException),
215+
stop=stop_after_delay(timedelta(minutes=retry_minutes))
216+
if retry_minutes
217+
else stop_after_attempt(1),
218+
):
219+
with attempt:
220+
for server_config in servers:
221+
config = osparc.Configuration(
222+
host=server_config.host,
223+
username=server_config.key,
224+
password=server_config.secret,
225+
)
226+
msg = "Cleaning up jobs for user: "
227+
msg += f"\n{server_config.model_dump_json(indent=1)}"
228+
typer.echo(msg)
229+
with osparc.ApiClient(config) as api_client:
230+
solvers_api = osparc.SolversApi(api_client)
231+
assert isinstance(
232+
solvers := solvers_api.list_solvers_releases(), list
233+
)
234+
for solver in solvers:
235+
assert isinstance(solver, osparc.Solver)
236+
assert (id_ := solver.id) is not None
237+
assert (version := solver.version) is not None
238+
for job in solvers_api.jobs(id_, version):
239+
assert isinstance(job, osparc.Job)
240+
solvers_api.delete_job(id_, version, job.id)

‎clients/python/test/e2e/ci/e2e/pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pydantic-settings = "^2.1"
1414
pytest = "^7.4"
1515
python = "^3.9"
1616
typer = {extras = ["all"], version = "^0.9.0"}
17+
tenacity = "^8.2.3"
1718

1819
[tool.poetry.scripts]
1920
e2e = "e2e.cli:cli"

0 commit comments

Comments
 (0)