Skip to content

Commit

Permalink
🚸 Check schema version upon instance init (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Mar 30, 2023
1 parent 621e4f4 commit b772dc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lamindb/_check_versions.py
Expand Up @@ -15,8 +15,8 @@

# Lamin GREATEREQ packages

if version.parse(lndb_v) < version.parse("0.38.1"):
raise RuntimeError("Upgrade lndb! pip install lndb>=0.38.1")
if version.parse(lndb_v) < version.parse("0.39.0"):
raise RuntimeError("Upgrade lndb! pip install lndb>=0.39.0")

if version.parse(nbproject_v) < version.parse("0.8.3"):
raise RuntimeError("lamindb needs nbproject>=0.8.3")
Expand Down
17 changes: 5 additions & 12 deletions lamindb/schema/__init__.py
Expand Up @@ -18,27 +18,20 @@
import importlib as _importlib

from lndb import settings as _settings
from lndb.dev._setup_schema import get_schema_module_name as _get_schema_module_name
from lndb.dev._setup_schema import (
check_schema_version_and_import as _check_schema_version_and_import,
)
from lnschema_core import Features, Project, Run, Storage
from lnschema_core import Transform as _Transform
from lnschema_core import User, dev
from packaging import version as _v

_check_v = {
"bionty": "0.14.0",
"wetlab": "0.15rc2",
}

from .. import _instance_setup


def _import_schema():
for name in _settings.instance.schema:
_module = _importlib.import_module(_get_schema_module_name(name))
if name in _check_v:
if _v.parse(_module.__version__) != _v.parse(_check_v[name]):
raise RuntimeError(f"lamindb needs lnschema_{name}=={_check_v[name]}")
globals()[_module._name] = _module
module = _check_schema_version_and_import(name)
globals()[module._name] = module


if _instance_setup:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -18,7 +18,7 @@ dependencies = [
"lndb_storage==0.2rc2",
"lnschema_core==0.30.0",
# Lamin GREATEREQ packages
"lndb>=0.38.1",
"lndb>=0.39.0",
"nbproject>=0.8.3",
# External packages
"hjson",
Expand Down

0 comments on commit b772dc8

Please sign in to comment.