Skip to content

Commit

Permalink
fix: random test failures
Browse files Browse the repository at this point in the history
Deleting the job manager when the cli finishes explicitly avoids random issues in the tests when the cli is called repeatedly.
  • Loading branch information
183amir committed Jul 8, 2024
1 parent 6ba44e8 commit c98c07a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gridtk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def cli(ctx, database, logs_dir):
ctx.meta["job_manager"] = JobManager(database=database, logs_dir=logs_dir)


@cli.result_callback()
def process_result(result, **kwargs):
"""Delete the job manager from the context."""
ctx = click.get_current_context()
del ctx.meta["job_manager"]


@cli.command(
epilog="""\b
Example:
Expand Down
2 changes: 2 additions & 0 deletions src/gridtk/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def update_jobs(self) -> None:
for grid_id, job in jobs_by_grid_id.items():
if grid_id in job_statuses:
job.update(job_statuses[grid_id])
self.session.flush()

def list_jobs(
self,
Expand Down Expand Up @@ -200,3 +201,4 @@ def __del__(self):
Path(self.database).unlink()
if self.logs_dir.exists() and len(os.listdir(self.logs_dir)) == 0:
shutil.rmtree(self.logs_dir)
self.engine.dispose()

0 comments on commit c98c07a

Please sign in to comment.