Skip to content
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

Make tests/everest/test_api use a shared multiobj storage instead of saved seba db #9331

Open
yngve-sk opened this issue Nov 25, 2024 · 0 comments

Comments

@yngve-sk
Copy link
Contributor

yngve-sk commented Nov 25, 2024

Make it do exactly the same, but using the seba db from the shared case. Should be set up similar to the way we have a shared case for snake oil in some ERT tests.

Definition of done: Remove all use of mock_SebaSnapshot in test_api.py, it should instead get the seba snapshot from the seba db in the shared case.

Possible starting point:


@pytest.fixture
def _shared_multiobj_case(request, monkeypatch):
    """This fixture will run the multiobj case to populate storage,
    this is quite slow, but the results will be cached. If something comes
    out of sync, clear the cache and start again.
    """

    test_data_path = Path(
        relpath("..", "..", "test-data", "everest", "math_func")
    ).resolve()

    output_path = request.config.cache.mkdir(
        "multiobj_data" + os.environ.get("PYTEST_XDIST_WORKER", "")
    )

    if not os.path.exists(output_path / "test_data"):
        os.mkdir("test_data")
        shutil.copy(test_data_path / "config_multiobj.yml", "./test_data/config_multiobj.yml")
        shutil.copytree(test_data_path / "jobs", "./test_data/jobs")
        sys.argv = ["run", "--new-run", "./test_data/config_multiobj.yml"]
        from everest.bin.everest_script import everest_entry

        everest_entry()

    monkeypatch.chdir(output_path / "test_data")

    yield output_path / "test_data"


@pytest.fixture(
    name="copy_multiobj_case",
    params=[
        pytest.param(0, marks=pytest.mark.xdist_group(name="snake_oil_case_storage"))
    ],
)
def fixture_multiobj_case(_shared_multiobj_case, tmp_path, monkeypatch):
    monkeypatch.chdir(tmp_path)
    shutil.copytree(_shared_multiobj_case, "test_data")
    monkeypatch.chdir("test_data")
@yngve-sk yngve-sk moved this to Todo in SCOUT Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant