Skip to content
Snippets Groups Projects
Commit fe2562b5 authored by Daniel CARRON's avatar Daniel CARRON :b:
Browse files

[test] Remove code to load test-database.zip

Databases should now be available on the CI, we do not rely on a zipped
db anymore.
parent 1f326f68
No related branches found
No related tags found
3 merge requests!19Fix Issues when running tests on the CI,!18Update tests,!16Make square centre-padding a model transform
Pipeline #84159 failed
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import os
import pathlib import pathlib
import tempfile
import typing import typing
import zipfile
import pytest import pytest
import tomli_w
import torch import torch
from torchvision.transforms.functional import to_pil_image from torchvision.transforms.functional import to_pil_image
...@@ -100,55 +96,6 @@ def temporary_basedir(tmp_path_factory): ...@@ -100,55 +96,6 @@ def temporary_basedir(tmp_path_factory):
return tmp_path_factory.mktemp("test-cli") return tmp_path_factory.mktemp("test-cli")
def pytest_sessionstart(session: pytest.Session) -> None:
"""Preset the session start to ensure the Montgomery dataset is always available.
Parameters
----------
session
The session to use.
"""
from mednet.utils.rc import load_rc
rc = load_rc()
database_dir = rc.get("datadir.montgomery")
if database_dir is not None:
# if the user downloaded it, use that copy
return
# else, we must extract the LFS component (we are likely on the CI)
archive = (
pathlib.Path(__file__).parents[0] / "data" / "lfs" / "test-database.zip"
)
assert archive.exists(), (
f"Neither datadir.montgomery is set on the global configuration, "
f"(typically ~/.config/mednet.toml), or it is possible to detect "
f"the presence of {archive}' (did you git submodule init --update "
f"this submodule?)"
)
montgomery_tempdir = tempfile.TemporaryDirectory()
rc.setdefault("datadir.montgomery", montgomery_tempdir.name)
with zipfile.ZipFile(archive) as zf:
zf.extractall(montgomery_tempdir.name)
config_filename = "mednet.toml"
with open(
os.path.join(montgomery_tempdir.name, config_filename), "wb"
) as f:
tomli_w.dump(rc.data, f)
f.flush()
os.environ["XDG_CONFIG_HOME"] = montgomery_tempdir.name
# stash the newly created temporary directory so we can erase it when the
key = pytest.StashKey[tempfile.TemporaryDirectory]()
session.stash[key] = montgomery_tempdir
class DatabaseCheckers: class DatabaseCheckers:
"""Helpers for database tests.""" """Helpers for database tests."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment