lamindb_setup 1.0a1__tar.gz → 1.0a5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/PKG-INFO +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/04-test-bionty.ipynb +3 -3
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-import-schema.ipynb +2 -2
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-init-load-local-anonymously.ipynb +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-invalid-schema.ipynb +3 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/notebooks.md +2 -2
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/__init__.py +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_close.py +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_connect_instance.py +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_exportdb.py +3 -3
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_importdb.py +2 -2
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_init_instance.py +22 -15
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_schema_metadata.py +5 -5
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_deprecated.py +12 -5
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_hub_utils.py +0 -9
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_instance.py +15 -6
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_load.py +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_setup_bionty_sources.py +3 -3
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/django.py +6 -4
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/noxfile.py +9 -7
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_init_instance.py +3 -3
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-local/test_update_schema_in_hub.py +4 -4
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/conftest.py +1 -1
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/.github/workflows/build.yml +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/.github/workflows/doc-changes.yml +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/.gitignore +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/.pre-commit-config.yaml +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/LICENSE +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/README.md +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/changelog.md +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/01-init-local-instance.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/02-connect-local-instance.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/03-add-managed-storage.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/05-init-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/06-connect-hosted-instance.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/07-keep-artifacts-local.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/08-test-multi-session.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-cloud/test_notebooks.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-cache-management.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-cloud-sync.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-connect-anonymously.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-empty-init.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-insufficient-user-info.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test-sqlite-lock.ipynb +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/hub-prod/test_notebooks2.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/index.md +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/docs/reference.md +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_cache.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_check.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_check_setup.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_delete.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_django.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_entry_points.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_migrate.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_register_instance.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_schema.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_set_managed_storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_setup_user.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/_silence_loggers.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/__init__.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_aws_credentials.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_aws_storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_docs.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_hub_client.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_hub_core.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_hub_crud.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_private_django_api.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_save.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_store.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/_settings_user.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/cloud_sqlite_locker.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/exceptions.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/hashing.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/types.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/lamindb_setup/core/upath.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/pyproject.toml +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/scripts/script-init-pass-user-no-writes.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/scripts/script-to-fail-managed-storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_connect_instance.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_delete_instance.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_edge_request.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_fail_managed_storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_init_pass_user_no_writes.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_login.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_migrate.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_set_storage.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-local/conftest.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-local/test_all.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/test_aws_credentials_manager.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/test_django.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/test_global_settings.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/test_switch_and_fallback_env.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-prod/test_upath.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_entry_point.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_hashing.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_storage_access.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_storage_basis.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_storage_stats.py +0 -0
- {lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/storage/test_to_url.py +0 -0
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"metadata": {},
|
|
34
34
|
"outputs": [],
|
|
35
35
|
"source": [
|
|
36
|
-
"ln_setup.init(storage=\"mydata2\",
|
|
36
|
+
"ln_setup.init(storage=\"mydata2\", modules=\"bionty\")"
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
{
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"metadata": {},
|
|
90
90
|
"outputs": [],
|
|
91
91
|
"source": [
|
|
92
|
-
"output = getoutput(\"lamin init --storage mydata2 --
|
|
92
|
+
"output = getoutput(\"lamin init --storage mydata2 --modules bionty\")\n",
|
|
93
93
|
"print(output)"
|
|
94
94
|
]
|
|
95
95
|
},
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"outputs": [],
|
|
108
108
|
"source": [
|
|
109
109
|
"ln_setup.settings.instance._get_settings_file().unlink()\n",
|
|
110
|
-
"output = getoutput(\"lamin init --storage mydata2 --
|
|
110
|
+
"output = getoutput(\"lamin init --storage mydata2 --modules bionty\")\n",
|
|
111
111
|
"print(output)"
|
|
112
112
|
]
|
|
113
113
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"id": "3e5867b4",
|
|
15
15
|
"metadata": {},
|
|
16
16
|
"source": [
|
|
17
|
-
"Also see the corresponding FAQ notebook in lamindb: `import-
|
|
17
|
+
"Also see the corresponding FAQ notebook in lamindb: `import-modules`.\n",
|
|
18
18
|
"\n",
|
|
19
19
|
"If you try to access an attribute (other than `model`), you'll load the instance in the same way as calling `import lamindb`."
|
|
20
20
|
]
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"outputs": [],
|
|
30
30
|
"source": [
|
|
31
|
-
"!lamin init --storage test-implicit-load --
|
|
31
|
+
"!lamin init --storage test-implicit-load --modules wetlab,bionty"
|
|
32
32
|
]
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"outputs": [],
|
|
25
25
|
"source": [
|
|
26
26
|
"with pytest.raises(ImportError):\n",
|
|
27
|
-
" ln_setup.init(
|
|
27
|
+
" ln_setup.init(\n",
|
|
28
|
+
" storage=\"./test-invalid-modules\", modules=\"bionty,invalid_module_name\"\n",
|
|
29
|
+
" )"
|
|
28
30
|
]
|
|
29
31
|
}
|
|
30
32
|
],
|
|
@@ -14,8 +14,8 @@ hub-cloud/test-multi-session
|
|
|
14
14
|
|
|
15
15
|
hub-prod/test-cache-management
|
|
16
16
|
hub-prod/test-empty-init
|
|
17
|
-
hub-prod/test-import-
|
|
18
|
-
hub-prod/test-invalid-
|
|
17
|
+
hub-prod/test-import-modules
|
|
18
|
+
hub-prod/test-invalid-modules
|
|
19
19
|
hub-prod/test-insufficient-user-info
|
|
20
20
|
hub-prod/test-init-load-local-anonymously
|
|
21
21
|
hub-prod/test-connect-anonymously
|
|
@@ -24,7 +24,7 @@ def close(mute: bool = False) -> None:
|
|
|
24
24
|
logger.warning("did not upload cache file - not enough permissions")
|
|
25
25
|
else:
|
|
26
26
|
raise e
|
|
27
|
-
if "bionty" in settings.instance.
|
|
27
|
+
if "bionty" in settings.instance.modules:
|
|
28
28
|
delete_bionty_sources_yaml()
|
|
29
29
|
current_instance_settings_file().unlink()
|
|
30
30
|
clear_locker()
|
|
@@ -160,7 +160,7 @@ def _connect_instance(
|
|
|
160
160
|
name=name,
|
|
161
161
|
storage=ssettings,
|
|
162
162
|
db=db_updated,
|
|
163
|
-
|
|
163
|
+
modules=instance_result["schema_str"],
|
|
164
164
|
git_repo=instance_result["git_repo"],
|
|
165
165
|
keep_artifacts_local=bool(instance_result["keep_artifacts_local"]),
|
|
166
166
|
is_on_hub=True,
|
|
@@ -12,7 +12,7 @@ MODELS = {
|
|
|
12
12
|
"User": False,
|
|
13
13
|
"Storage": False,
|
|
14
14
|
"Feature": False,
|
|
15
|
-
"
|
|
15
|
+
"Schema": False,
|
|
16
16
|
"ULabel": False,
|
|
17
17
|
},
|
|
18
18
|
# "bionty": {
|
|
@@ -57,9 +57,9 @@ def exportdb() -> None:
|
|
|
57
57
|
|
|
58
58
|
# export data to parquet files
|
|
59
59
|
print(f"\nexporting data to parquet files in: {directory}\n")
|
|
60
|
-
for
|
|
60
|
+
for module_name, models in MODELS.items():
|
|
61
61
|
for model_name in models.keys():
|
|
62
|
-
schema_module = import_module(f"lnschema_{
|
|
62
|
+
schema_module = import_module(f"lnschema_{module_name}")
|
|
63
63
|
registry = getattr(schema_module, model_name)
|
|
64
64
|
export_registry(registry, directory)
|
|
65
65
|
many_to_many_names = [field.name for field in registry._meta.many_to_many]
|
|
@@ -36,10 +36,10 @@ def importdb() -> None:
|
|
|
36
36
|
with engine.begin() as connection:
|
|
37
37
|
if ln_setup.settings.instance.dialect == "postgresql":
|
|
38
38
|
connection.execute(text("SET CONSTRAINTS ALL DEFERRED;"))
|
|
39
|
-
for
|
|
39
|
+
for module_name, models in MODELS.items():
|
|
40
40
|
for model_name in models.keys():
|
|
41
41
|
print(model_name)
|
|
42
|
-
schema_module = import_module(f"lnschema_{
|
|
42
|
+
schema_module = import_module(f"lnschema_{module_name}")
|
|
43
43
|
registry = getattr(schema_module, model_name)
|
|
44
44
|
import_registry(registry, directory, connection)
|
|
45
45
|
many_to_many_names = [
|
|
@@ -25,17 +25,17 @@ if TYPE_CHECKING:
|
|
|
25
25
|
from .core.types import UPathStr
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def get_schema_module_name(
|
|
28
|
+
def get_schema_module_name(module_name, raise_import_error: bool = True) -> str | None:
|
|
29
29
|
import importlib.util
|
|
30
30
|
|
|
31
|
-
if
|
|
31
|
+
if module_name == "core":
|
|
32
32
|
return "lamindb"
|
|
33
|
-
name_attempts = [f"lnschema_{
|
|
33
|
+
name_attempts = [f"lnschema_{module_name.replace('-', '_')}", module_name]
|
|
34
34
|
for name in name_attempts:
|
|
35
35
|
module_spec = importlib.util.find_spec(name)
|
|
36
36
|
if module_spec is not None:
|
|
37
37
|
return name
|
|
38
|
-
message = f"
|
|
38
|
+
message = f"schema module '{module_name}' is not installed → no access to its labels & registries (resolve via `pip install {module_name}`)"
|
|
39
39
|
if raise_import_error:
|
|
40
40
|
raise ImportError(message)
|
|
41
41
|
logger.warning(message.lower())
|
|
@@ -129,12 +129,21 @@ def process_connect_response(
|
|
|
129
129
|
return instance_id, instance_state
|
|
130
130
|
|
|
131
131
|
|
|
132
|
+
def process_modules_arg(modules: str | None = None) -> str:
|
|
133
|
+
if modules is None or modules == "":
|
|
134
|
+
return ""
|
|
135
|
+
# currently no actual validation, can add back if we see a need
|
|
136
|
+
# the following just strips white spaces
|
|
137
|
+
to_be_validated = [s.strip() for s in modules.split(",")]
|
|
138
|
+
return ",".join(to_be_validated)
|
|
139
|
+
|
|
140
|
+
|
|
132
141
|
def validate_init_args(
|
|
133
142
|
*,
|
|
134
143
|
storage: UPathStr,
|
|
135
144
|
name: str | None = None,
|
|
136
145
|
db: PostgresDsn | None = None,
|
|
137
|
-
|
|
146
|
+
modules: str | None = None,
|
|
138
147
|
_test: bool = False,
|
|
139
148
|
_write_settings: bool = True,
|
|
140
149
|
_user: UserSettings | None = None,
|
|
@@ -150,9 +159,6 @@ def validate_init_args(
|
|
|
150
159
|
str,
|
|
151
160
|
]:
|
|
152
161
|
from ._connect_instance import connect
|
|
153
|
-
from .core._hub_utils import (
|
|
154
|
-
validate_schema_arg,
|
|
155
|
-
)
|
|
156
162
|
|
|
157
163
|
if storage is None:
|
|
158
164
|
raise SystemExit("✗ `storage` argument can't be `None`")
|
|
@@ -178,7 +184,7 @@ def validate_init_args(
|
|
|
178
184
|
instance_id = None
|
|
179
185
|
if response is not None:
|
|
180
186
|
instance_id, instance_state = process_connect_response(response, instance_slug)
|
|
181
|
-
|
|
187
|
+
modules = process_modules_arg(modules)
|
|
182
188
|
return name_str, instance_id, instance_state, instance_slug
|
|
183
189
|
|
|
184
190
|
|
|
@@ -202,22 +208,23 @@ def init(
|
|
|
202
208
|
storage: UPathStr,
|
|
203
209
|
name: str | None = None,
|
|
204
210
|
db: PostgresDsn | None = None,
|
|
205
|
-
|
|
211
|
+
modules: str | None = None,
|
|
206
212
|
**kwargs,
|
|
207
213
|
) -> None:
|
|
208
214
|
"""Create and load a LaminDB instance.
|
|
209
215
|
|
|
210
216
|
Args:
|
|
211
|
-
storage: Either
|
|
212
|
-
remote folder (``"s3://..."`` or ``"gs://..."``).
|
|
217
|
+
storage: Either local or remote folder (`"s3://..."` or `"gs://..."`).
|
|
213
218
|
name: Instance name.
|
|
214
219
|
db: Database connection url, do not pass for SQLite.
|
|
215
|
-
|
|
220
|
+
modules: Comma-separated string of modules. None if the lamindb registries are enough.
|
|
216
221
|
"""
|
|
217
222
|
isettings = None
|
|
218
223
|
ssettings = None
|
|
219
224
|
|
|
220
225
|
_write_settings: bool = kwargs.get("_write_settings", True)
|
|
226
|
+
if modules is None:
|
|
227
|
+
modules = kwargs.get("schema", None)
|
|
221
228
|
_test: bool = kwargs.get("_test", False)
|
|
222
229
|
|
|
223
230
|
# use this user instead of settings.user
|
|
@@ -241,7 +248,7 @@ def init(
|
|
|
241
248
|
storage=storage,
|
|
242
249
|
name=name,
|
|
243
250
|
db=db,
|
|
244
|
-
|
|
251
|
+
modules=modules,
|
|
245
252
|
_test=_test,
|
|
246
253
|
_write_settings=_write_settings,
|
|
247
254
|
_user=_user, # will get from settings.user if _user is None
|
|
@@ -268,7 +275,7 @@ def init(
|
|
|
268
275
|
name=name_str,
|
|
269
276
|
storage=ssettings,
|
|
270
277
|
db=db,
|
|
271
|
-
|
|
278
|
+
modules=modules,
|
|
272
279
|
uid=ssettings.uid,
|
|
273
280
|
# to lock passed user in isettings._cloud_sqlite_locker.lock()
|
|
274
281
|
_locker_user=_user, # only has effect if cloud sqlite
|
|
@@ -238,15 +238,15 @@ class _ModelHandler:
|
|
|
238
238
|
model_name = field.model._meta.model_name
|
|
239
239
|
relation_type = self._get_relation_type(model, field)
|
|
240
240
|
if field.related_model is None:
|
|
241
|
-
schema_name = field.model.
|
|
241
|
+
schema_name = field.model.__get_module_name__()
|
|
242
242
|
related_model_name = None
|
|
243
243
|
related_schema_name = None
|
|
244
244
|
related_field_name = None
|
|
245
245
|
field_name = field.name
|
|
246
246
|
else:
|
|
247
247
|
related_model_name = field.related_model._meta.model_name
|
|
248
|
-
related_schema_name = field.related_model.
|
|
249
|
-
schema_name = field.model.
|
|
248
|
+
related_schema_name = field.related_model.__get_module_name__()
|
|
249
|
+
schema_name = field.model.__get_module_name__()
|
|
250
250
|
related_field_name = field.remote_field.name
|
|
251
251
|
field_name = field.name
|
|
252
252
|
|
|
@@ -362,7 +362,7 @@ class _ModelHandler:
|
|
|
362
362
|
|
|
363
363
|
class _SchemaHandler:
|
|
364
364
|
def __init__(self) -> None:
|
|
365
|
-
self.included_modules = ["core"] + list(settings.instance.
|
|
365
|
+
self.included_modules = ["core"] + list(settings.instance.modules)
|
|
366
366
|
self.modules = self._get_modules_metadata()
|
|
367
367
|
|
|
368
368
|
def to_dict(self, include_django_objects: bool = True):
|
|
@@ -391,7 +391,7 @@ class _SchemaHandler:
|
|
|
391
391
|
if model.__class__ is Registry
|
|
392
392
|
and model is not Record
|
|
393
393
|
and not model._meta.abstract
|
|
394
|
-
and model.
|
|
394
|
+
and model.__get_module_name__() == module_name
|
|
395
395
|
}
|
|
396
396
|
for module_name in self.included_modules
|
|
397
397
|
}
|
|
@@ -30,23 +30,30 @@ from functools import wraps
|
|
|
30
30
|
def deprecated(new_name: str):
|
|
31
31
|
"""Deprecated.
|
|
32
32
|
|
|
33
|
-
This is a decorator which can be used to mark functions
|
|
33
|
+
This is a decorator which can be used to mark functions, methods and properties
|
|
34
34
|
as deprecated. It will result in a warning being emitted
|
|
35
35
|
when the function is used.
|
|
36
|
+
|
|
37
|
+
It will also hide the function from the docs.
|
|
38
|
+
|
|
39
|
+
Example::
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
@deprecated("n_files")
|
|
43
|
+
def n_objects(self) -> int:
|
|
44
|
+
return self.n_files
|
|
45
|
+
|
|
36
46
|
"""
|
|
37
47
|
|
|
38
48
|
def decorator(func):
|
|
39
49
|
@wraps(func)
|
|
40
50
|
def new_func(*args, **kwargs):
|
|
41
|
-
# turn off filter
|
|
42
|
-
warnings.simplefilter("always", DeprecationWarning)
|
|
43
51
|
warnings.warn(
|
|
44
52
|
f"Use {new_name} instead of {func.__name__}, "
|
|
45
53
|
f"{func.__name__} will be removed in the future.",
|
|
46
|
-
category=
|
|
54
|
+
category=FutureWarning,
|
|
47
55
|
stacklevel=2,
|
|
48
56
|
)
|
|
49
|
-
warnings.simplefilter("default", DeprecationWarning) # reset filter
|
|
50
57
|
return func(*args, **kwargs)
|
|
51
58
|
|
|
52
59
|
setattr(new_func, "__deprecated", True)
|
|
@@ -7,15 +7,6 @@ from pydantic import BaseModel, Field, GetCoreSchemaHandler
|
|
|
7
7
|
from pydantic_core import CoreSchema, core_schema
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def validate_schema_arg(schema: str | None = None) -> str:
|
|
11
|
-
if schema is None or schema == "":
|
|
12
|
-
return ""
|
|
13
|
-
# currently no actual validation, can add back if we see a need
|
|
14
|
-
# the following just strips white spaces
|
|
15
|
-
to_be_validated = [s.strip() for s in schema.split(",")]
|
|
16
|
-
return ",".join(to_be_validated)
|
|
17
|
-
|
|
18
|
-
|
|
19
10
|
def validate_db_arg(db: str | None) -> None:
|
|
20
11
|
if db is not None:
|
|
21
12
|
LaminDsnModel(db=db)
|
|
@@ -8,6 +8,7 @@ from typing import TYPE_CHECKING, Literal
|
|
|
8
8
|
from django.db.utils import ProgrammingError
|
|
9
9
|
from lamin_utils import logger
|
|
10
10
|
|
|
11
|
+
from ._deprecated import deprecated
|
|
11
12
|
from ._hub_client import call_with_fallback
|
|
12
13
|
from ._hub_crud import select_account_handle_name_by_lnid
|
|
13
14
|
from ._hub_utils import LaminDsn, LaminDsnModel
|
|
@@ -53,7 +54,7 @@ class InstanceSettings:
|
|
|
53
54
|
keep_artifacts_local: bool = False, # default to local storage
|
|
54
55
|
uid: str | None = None, # instance uid/lnid
|
|
55
56
|
db: str | None = None, # DB URI
|
|
56
|
-
|
|
57
|
+
modules: str | None = None, # comma-separated string of module names
|
|
57
58
|
git_repo: str | None = None, # a git repo URL
|
|
58
59
|
is_on_hub: bool | None = None, # initialized from hub
|
|
59
60
|
api_url: str | None = None,
|
|
@@ -69,7 +70,7 @@ class InstanceSettings:
|
|
|
69
70
|
self._storage: StorageSettings = storage
|
|
70
71
|
validate_db_arg(db)
|
|
71
72
|
self._db: str | None = db
|
|
72
|
-
self._schema_str: str | None =
|
|
73
|
+
self._schema_str: str | None = modules
|
|
73
74
|
self._git_repo = None if git_repo is None else sanitize_git_repo_url(git_repo)
|
|
74
75
|
# local storage
|
|
75
76
|
self._keep_artifacts_local = keep_artifacts_local
|
|
@@ -84,7 +85,7 @@ class InstanceSettings:
|
|
|
84
85
|
def __repr__(self):
|
|
85
86
|
"""Rich string representation."""
|
|
86
87
|
representation = f"Current instance: {self.slug}"
|
|
87
|
-
attrs = ["owner", "name", "storage", "db", "
|
|
88
|
+
attrs = ["owner", "name", "storage", "db", "modules", "git_repo"]
|
|
88
89
|
for attr in attrs:
|
|
89
90
|
value = getattr(self, attr)
|
|
90
91
|
if attr == "storage":
|
|
@@ -271,12 +272,20 @@ class InstanceSettings:
|
|
|
271
272
|
return hash_and_encode_as_b62(self._id.hex)[:12]
|
|
272
273
|
|
|
273
274
|
@property
|
|
274
|
-
def
|
|
275
|
-
"""
|
|
275
|
+
def modules(self) -> set[str]:
|
|
276
|
+
"""The set of modules that defines the database schema.
|
|
277
|
+
|
|
278
|
+
The core schema contained in lamindb is not included in this set.
|
|
279
|
+
"""
|
|
276
280
|
if self._schema_str is None:
|
|
277
281
|
return {} # type: ignore
|
|
278
282
|
else:
|
|
279
|
-
return {
|
|
283
|
+
return {module for module in self._schema_str.split(",") if module != ""}
|
|
284
|
+
|
|
285
|
+
@property
|
|
286
|
+
@deprecated("modules")
|
|
287
|
+
def schema(self) -> set[str]:
|
|
288
|
+
return self.modules
|
|
280
289
|
|
|
281
290
|
@property
|
|
282
291
|
def _sqlite_file(self) -> UPath:
|
|
@@ -98,7 +98,7 @@ def setup_instance_from_store(store: InstanceSettingsStore) -> InstanceSettings:
|
|
|
98
98
|
name=store.name,
|
|
99
99
|
storage=ssettings,
|
|
100
100
|
db=_null_to_value(store.db),
|
|
101
|
-
|
|
101
|
+
modules=_null_to_value(store.schema_str),
|
|
102
102
|
git_repo=_null_to_value(store.git_repo),
|
|
103
103
|
keep_artifacts_local=store.keep_artifacts_local, # type: ignore
|
|
104
104
|
)
|
|
@@ -17,7 +17,7 @@ RENAME = {"name": "source", "description": "source_name"}
|
|
|
17
17
|
|
|
18
18
|
def write_bionty_sources(isettings: InstanceSettings) -> None:
|
|
19
19
|
"""Write bionty sources to Source table."""
|
|
20
|
-
if "bionty" not in isettings.
|
|
20
|
+
if "bionty" not in isettings.modules:
|
|
21
21
|
return None
|
|
22
22
|
import shutil
|
|
23
23
|
|
|
@@ -79,7 +79,7 @@ def load_bionty_sources(isettings: InstanceSettings | None = None):
|
|
|
79
79
|
# not setting up bionty sources
|
|
80
80
|
return None
|
|
81
81
|
if isettings is not None:
|
|
82
|
-
if "bionty" not in isettings.
|
|
82
|
+
if "bionty" not in isettings.modules:
|
|
83
83
|
# no need to setup anything
|
|
84
84
|
return None
|
|
85
85
|
|
|
@@ -96,7 +96,7 @@ def load_bionty_sources(isettings: InstanceSettings | None = None):
|
|
|
96
96
|
for kwargs in active_records:
|
|
97
97
|
for db_field, base_col in RENAME.items():
|
|
98
98
|
kwargs[base_col] = kwargs.pop(db_field)
|
|
99
|
-
# TODO: non-bionty
|
|
99
|
+
# TODO: non-bionty modules?
|
|
100
100
|
kwargs["entity"] = kwargs["entity"].replace("bionty.", "")
|
|
101
101
|
write_yaml(
|
|
102
102
|
parse_currently_used_sources(active_records),
|
|
@@ -52,14 +52,14 @@ def setup_django(
|
|
|
52
52
|
}
|
|
53
53
|
from .._init_instance import get_schema_module_name
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
module_names = ["core"] + list(isettings.modules)
|
|
56
56
|
raise_import_error = True if init else False
|
|
57
57
|
installed_apps = [
|
|
58
58
|
package_name
|
|
59
|
-
for
|
|
59
|
+
for name in module_names
|
|
60
60
|
if (
|
|
61
61
|
package_name := get_schema_module_name(
|
|
62
|
-
|
|
62
|
+
name, raise_import_error=raise_import_error
|
|
63
63
|
)
|
|
64
64
|
)
|
|
65
65
|
is not None
|
|
@@ -113,7 +113,9 @@ def setup_django(
|
|
|
113
113
|
elif init:
|
|
114
114
|
global IS_MIGRATING
|
|
115
115
|
IS_MIGRATING = True
|
|
116
|
-
call_command(
|
|
116
|
+
call_command(
|
|
117
|
+
"migrate", verbosity=2
|
|
118
|
+
) # may change back to verbosity 0 in the future
|
|
117
119
|
IS_MIGRATING = False
|
|
118
120
|
|
|
119
121
|
global IS_SETUP
|
|
@@ -27,24 +27,26 @@ def lint(session: nox.Session) -> None:
|
|
|
27
27
|
["hub-local", "hub-prod", "hub-cloud", "storage", "docs"],
|
|
28
28
|
)
|
|
29
29
|
def install(session: nox.Session, group: str) -> None:
|
|
30
|
-
no_deps_packages = "git+https://github.com/laminlabs/lamindb
|
|
31
|
-
|
|
30
|
+
no_deps_packages = "git+https://github.com/laminlabs/lamindb git+https://github.com/laminlabs/wetlab git+https://github.com/laminlabs/lamin-cli"
|
|
31
|
+
modules_deps = f"""uv pip install --system git+https://github.com/laminlabs/bionty
|
|
32
32
|
uv pip install --system --no-deps {no_deps_packages}
|
|
33
33
|
"""
|
|
34
34
|
if group == "hub-cloud":
|
|
35
|
-
cmds =
|
|
35
|
+
cmds = (
|
|
36
|
+
modules_deps + "uv pip install --system ./laminhub/rest-hub line_profiler"
|
|
37
|
+
)
|
|
36
38
|
elif group == "docs":
|
|
37
|
-
cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb
|
|
39
|
+
cmds = """uv pip install --system git+https://github.com/laminlabs/lamindb"""
|
|
38
40
|
elif group == "storage":
|
|
39
|
-
cmds =
|
|
41
|
+
cmds = modules_deps + "uv pip install --system gcsfs huggingface_hub"
|
|
40
42
|
elif group == "hub-prod":
|
|
41
43
|
# cmds = "git clone --depth 1 https://github.com/django/django\n"
|
|
42
44
|
# cmds += "uv pip install --system -e ./django\n"
|
|
43
45
|
cmds = ""
|
|
44
|
-
cmds +=
|
|
46
|
+
cmds += modules_deps.strip()
|
|
45
47
|
cmds += """\nuv pip install --system huggingface_hub"""
|
|
46
48
|
elif group == "hub-local":
|
|
47
|
-
cmds =
|
|
49
|
+
cmds = modules_deps.strip()
|
|
48
50
|
# current package
|
|
49
51
|
cmds += """\nuv pip install --system -e '.[aws,dev]'"""
|
|
50
52
|
|
|
@@ -199,7 +199,7 @@ def test_init_invalid_name():
|
|
|
199
199
|
# # with pytest.raises(RuntimeError):
|
|
200
200
|
# # ln_setup.init(
|
|
201
201
|
# # storage="s3://lamindb-ci",
|
|
202
|
-
# #
|
|
202
|
+
# # modules="retro, bionty",
|
|
203
203
|
# # db="postgresql://batman:robin@35.222.187.204:5432/retro",
|
|
204
204
|
# # )
|
|
205
205
|
|
|
@@ -211,6 +211,6 @@ def test_init_invalid_name():
|
|
|
211
211
|
# # ln_setup.init(storage="s3://lamindb-ci")
|
|
212
212
|
|
|
213
213
|
|
|
214
|
-
# def
|
|
214
|
+
# def test_value_error_modules():
|
|
215
215
|
# with pytest.raises(ModuleNotFoundError):
|
|
216
|
-
# ln_setup.init(storage="tmpstorage1",
|
|
216
|
+
# ln_setup.init(storage="tmpstorage1", modules="bionty, xyz1")
|
|
@@ -7,20 +7,20 @@ from lamindb_setup._schema_metadata import _dict_to_uuid, update_schema_in_hub
|
|
|
7
7
|
def setup_instance():
|
|
8
8
|
ln_setup.init(
|
|
9
9
|
storage="./test_storage",
|
|
10
|
-
|
|
10
|
+
modules="bionty,wetlab",
|
|
11
11
|
db="postgresql://postgres:postgres@127.0.0.1:54322/postgres",
|
|
12
|
-
name="test-update-
|
|
12
|
+
name="test-update-modules",
|
|
13
13
|
)
|
|
14
14
|
ln_setup.register()
|
|
15
15
|
yield
|
|
16
|
-
ln_setup.delete("test-update-
|
|
16
|
+
ln_setup.delete("test-update-modules", force=True)
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def test_update_schema_in_hub(setup_instance):
|
|
20
20
|
is_new, schema_uuid, schema = update_schema_in_hub()
|
|
21
21
|
|
|
22
22
|
# TODO: construct a test in which is_new is true
|
|
23
|
-
# currently it's false because the
|
|
23
|
+
# currently it's false because the modules is already registered
|
|
24
24
|
# via `lamin register` earlier in the test
|
|
25
25
|
assert not is_new
|
|
26
26
|
assert _dict_to_uuid(schema["schema_json"]) == schema_uuid
|
|
@@ -12,7 +12,7 @@ def pytest_sessionstart(session: pytest.Session):
|
|
|
12
12
|
assert lamindb_setup.settings.user.handle == "testuser2"
|
|
13
13
|
lamindb_setup.init(
|
|
14
14
|
storage="./default_storage",
|
|
15
|
-
|
|
15
|
+
modules="bionty",
|
|
16
16
|
name="lamindb-setup-unit-tests",
|
|
17
17
|
)
|
|
18
18
|
assert lamindb_setup.settings.instance._id == lamindb_instance_id
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lamindb_setup-1.0a1 → lamindb_setup-1.0a5}/tests/hub-cloud/test_init_pass_user_no_writes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|