Skip to content

Commit

Permalink
Fix everest fixture for caching testcase results
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Jan 31, 2025
1 parent 050077c commit 15575ad
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/everest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,17 @@ def create_evaluator_server_config(run_model):


@pytest.fixture
def cached_example(pytestconfig, evaluator_server_config_generator):
def cached_example(pytestconfig: pytest.Config, evaluator_server_config_generator):
cache = pytestconfig.cache

def run_config(test_data_case: str):
if cache.get(f"cached_example:{test_data_case}", None) is None:
if (
cache.get(
f"cached_example:{test_data_case}:{os.environ.get('PYTEST_XDIST_WORKER', '')}",
None,
)
is None
):
my_tmpdir = Path(tempfile.mkdtemp())
config_path = (
Path(__file__) / f"../../../test-data/everest/{test_data_case}"
Expand All @@ -187,12 +193,13 @@ def run_config(test_data_case: str):
}

cache.set(
f"cached_example:{test_data_case}",
f"cached_example:{test_data_case}:{os.environ.get('PYTEST_XDIST_WORKER', '')}",
(str(result_path), config_file, optimal_result_json),
)

result_path, config_file, optimal_result_json = cache.get(
f"cached_example:{test_data_case}", (None, None, None)
f"cached_example:{test_data_case}:{os.environ.get('PYTEST_XDIST_WORKER', '')}",
(None, None, None),
)

copied_tmpdir = tempfile.mkdtemp()
Expand Down

0 comments on commit 15575ad

Please sign in to comment.