lamindb_setup 1.8.3__py3-none-any.whl → 1.9.1__py3-none-any.whl

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.
Files changed (39) hide show
  1. lamindb_setup/__init__.py +107 -107
  2. lamindb_setup/_cache.py +87 -87
  3. lamindb_setup/_check_setup.py +166 -166
  4. lamindb_setup/_connect_instance.py +328 -342
  5. lamindb_setup/_delete.py +141 -141
  6. lamindb_setup/_disconnect.py +32 -32
  7. lamindb_setup/_init_instance.py +440 -440
  8. lamindb_setup/_migrate.py +266 -259
  9. lamindb_setup/_register_instance.py +35 -35
  10. lamindb_setup/_schema_metadata.py +441 -441
  11. lamindb_setup/_set_managed_storage.py +70 -70
  12. lamindb_setup/_setup_user.py +133 -133
  13. lamindb_setup/core/__init__.py +21 -21
  14. lamindb_setup/core/_aws_options.py +223 -211
  15. lamindb_setup/core/_hub_client.py +248 -243
  16. lamindb_setup/core/_hub_core.py +665 -663
  17. lamindb_setup/core/_hub_crud.py +227 -227
  18. lamindb_setup/core/_private_django_api.py +83 -83
  19. lamindb_setup/core/_settings.py +377 -364
  20. lamindb_setup/core/_settings_instance.py +569 -568
  21. lamindb_setup/core/_settings_load.py +141 -141
  22. lamindb_setup/core/_settings_save.py +95 -95
  23. lamindb_setup/core/_settings_storage.py +429 -429
  24. lamindb_setup/core/_settings_store.py +91 -91
  25. lamindb_setup/core/_settings_user.py +55 -55
  26. lamindb_setup/core/_setup_bionty_sources.py +44 -44
  27. lamindb_setup/core/cloud_sqlite_locker.py +240 -240
  28. lamindb_setup/core/django.py +305 -291
  29. lamindb_setup/core/exceptions.py +1 -1
  30. lamindb_setup/core/hashing.py +134 -134
  31. lamindb_setup/core/types.py +1 -1
  32. lamindb_setup/core/upath.py +1013 -1009
  33. lamindb_setup/errors.py +70 -70
  34. lamindb_setup/types.py +20 -20
  35. {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.1.dist-info}/METADATA +1 -1
  36. lamindb_setup-1.9.1.dist-info/RECORD +50 -0
  37. lamindb_setup-1.8.3.dist-info/RECORD +0 -50
  38. {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.1.dist-info}/LICENSE +0 -0
  39. {lamindb_setup-1.8.3.dist-info → lamindb_setup-1.9.1.dist-info}/WHEEL +0 -0
lamindb_setup/__init__.py CHANGED
@@ -1,107 +1,107 @@
1
- """Setup & configure LaminDB.
2
-
3
- Many functions in this "setup API" have a matching command in the :doc:`docs:cli` CLI.
4
-
5
- Guide: :doc:`docs:setup`.
6
-
7
- Basic operations:
8
-
9
- .. autosummary::
10
- :toctree:
11
-
12
- login
13
- logout
14
- init
15
- disconnect
16
- delete
17
-
18
- Instance operations:
19
-
20
- .. autosummary::
21
- :toctree:
22
-
23
- migrate
24
-
25
- Modules & settings:
26
-
27
- .. autosummary::
28
- :toctree:
29
-
30
- settings
31
- core
32
- django
33
- errors
34
- types
35
-
36
- """
37
-
38
- __version__ = "1.8.3" # denote a release candidate for 0.1.0 with 0.1rc1
39
-
40
- import os
41
-
42
- from packaging import version as packaging_version
43
-
44
- from . import core, errors, types
45
- from ._check_setup import _check_instance_setup
46
- from ._connect_instance import connect
47
- from ._delete import delete
48
- from ._disconnect import disconnect
49
- from ._django import django
50
- from ._entry_points import call_registered_entry_points as _call_registered_entry_points
51
- from ._init_instance import init
52
- from ._migrate import migrate
53
- from ._register_instance import register
54
- from ._setup_user import login, logout
55
- from .core._settings import settings
56
-
57
- # check that the version of s3fs is higher than the lower bound
58
- # needed because spatialdata installs old versions of s3fs
59
- try:
60
- from s3fs import __version__ as s3fs_version
61
-
62
- if packaging_version.parse(s3fs_version) < packaging_version.parse("2023.12.2"):
63
- raise RuntimeError(
64
- f"The version of s3fs you have ({s3fs_version}) is impompatible "
65
- "with lamindb, please upgrade it: pip install s3fs>=2023.12.2"
66
- )
67
- except ImportError:
68
- # might be not installed
69
- pass
70
-
71
-
72
- def _is_CI_environment() -> bool:
73
- ci_env_vars = [
74
- "LAMIN_TESTING", # Set by our nox configurations
75
- "CI", # Commonly set by many CI systems
76
- "TRAVIS", # Travis CI
77
- "GITHUB_ACTIONS", # GitHub Actions
78
- "GITLAB_CI", # GitLab CI/CD
79
- "CIRCLECI", # CircleCI
80
- "JENKINS_URL", # Jenkins
81
- "TEAMCITY_VERSION", # TeamCity
82
- "BUILDKITE", # Buildkite
83
- "BITBUCKET_BUILD_NUMBER", # Bitbucket Pipelines
84
- "APPVEYOR", # AppVeyor
85
- "AZURE_HTTP_USER_AGENT", # Azure Pipelines
86
- "BUDDY", # Buddy
87
- "DRONE", # Drone CI
88
- "HUDSON_URL", # Hudson
89
- "CF_BUILD_ID", # Codefresh
90
- "WERCKER", # Wercker
91
- "NOW_BUILDER", # ZEIT Now
92
- "TASKCLUSTER_ROOT_URL", # TaskCluster
93
- "SEMAPHORE", # Semaphore CI
94
- "BUILD_ID", # Generic build environments
95
- ]
96
- return any(env_var in os.environ for env_var in ci_env_vars)
97
-
98
-
99
- _TESTING = _is_CI_environment()
100
-
101
- # provide a way for other packages to run custom code on import
102
- _call_registered_entry_points("lamindb_setup.on_import")
103
-
104
- settings.__doc__ = """Global :class:`~lamindb.setup.core.SetupSettings`."""
105
-
106
-
107
- close = disconnect # backward compatibility
1
+ """Setup & configure LaminDB.
2
+
3
+ Many functions in this "setup API" have a matching command in the :doc:`docs:cli` CLI.
4
+
5
+ Guide: :doc:`docs:setup`.
6
+
7
+ Basic operations:
8
+
9
+ .. autosummary::
10
+ :toctree:
11
+
12
+ login
13
+ logout
14
+ init
15
+ disconnect
16
+ delete
17
+
18
+ Instance operations:
19
+
20
+ .. autosummary::
21
+ :toctree:
22
+
23
+ migrate
24
+
25
+ Modules & settings:
26
+
27
+ .. autosummary::
28
+ :toctree:
29
+
30
+ settings
31
+ core
32
+ django
33
+ errors
34
+ types
35
+
36
+ """
37
+
38
+ __version__ = "1.9.1" # denote a release candidate for 0.1.0 with 0.1rc1
39
+
40
+ import os
41
+
42
+ from packaging import version as packaging_version
43
+
44
+ from . import core, errors, types
45
+ from ._check_setup import _check_instance_setup
46
+ from ._connect_instance import connect
47
+ from ._delete import delete
48
+ from ._disconnect import disconnect
49
+ from ._django import django
50
+ from ._entry_points import call_registered_entry_points as _call_registered_entry_points
51
+ from ._init_instance import init
52
+ from ._migrate import migrate
53
+ from ._register_instance import register
54
+ from ._setup_user import login, logout
55
+ from .core._settings import settings
56
+
57
+ # check that the version of s3fs is higher than the lower bound
58
+ # needed because spatialdata installs old versions of s3fs
59
+ try:
60
+ from s3fs import __version__ as s3fs_version
61
+
62
+ if packaging_version.parse(s3fs_version) < packaging_version.parse("2023.12.2"):
63
+ raise RuntimeError(
64
+ f"The version of s3fs you have ({s3fs_version}) is impompatible "
65
+ "with lamindb, please upgrade it: pip install s3fs>=2023.12.2"
66
+ )
67
+ except ImportError:
68
+ # might be not installed
69
+ pass
70
+
71
+
72
+ def _is_CI_environment() -> bool:
73
+ ci_env_vars = [
74
+ "LAMIN_TESTING", # Set by our nox configurations
75
+ "CI", # Commonly set by many CI systems
76
+ "TRAVIS", # Travis CI
77
+ "GITHUB_ACTIONS", # GitHub Actions
78
+ "GITLAB_CI", # GitLab CI/CD
79
+ "CIRCLECI", # CircleCI
80
+ "JENKINS_URL", # Jenkins
81
+ "TEAMCITY_VERSION", # TeamCity
82
+ "BUILDKITE", # Buildkite
83
+ "BITBUCKET_BUILD_NUMBER", # Bitbucket Pipelines
84
+ "APPVEYOR", # AppVeyor
85
+ "AZURE_HTTP_USER_AGENT", # Azure Pipelines
86
+ "BUDDY", # Buddy
87
+ "DRONE", # Drone CI
88
+ "HUDSON_URL", # Hudson
89
+ "CF_BUILD_ID", # Codefresh
90
+ "WERCKER", # Wercker
91
+ "NOW_BUILDER", # ZEIT Now
92
+ "TASKCLUSTER_ROOT_URL", # TaskCluster
93
+ "SEMAPHORE", # Semaphore CI
94
+ "BUILD_ID", # Generic build environments
95
+ ]
96
+ return any(env_var in os.environ for env_var in ci_env_vars)
97
+
98
+
99
+ _TESTING = _is_CI_environment()
100
+
101
+ # provide a way for other packages to run custom code on import
102
+ _call_registered_entry_points("lamindb_setup.on_import")
103
+
104
+ settings.__doc__ = """Global :class:`~lamindb.setup.core.SetupSettings`."""
105
+
106
+
107
+ close = disconnect # backward compatibility
lamindb_setup/_cache.py CHANGED
@@ -1,87 +1,87 @@
1
- from __future__ import annotations
2
-
3
- import shutil
4
- from pathlib import Path
5
-
6
- from dotenv import dotenv_values
7
- from lamin_utils import logger
8
-
9
- from .core._settings_save import save_platform_user_storage_settings
10
- from .core._settings_store import system_settings_file
11
-
12
-
13
- def clear_cache_dir():
14
- from lamindb_setup import disconnect, settings
15
-
16
- try:
17
- if settings.instance._is_cloud_sqlite:
18
- logger.warning(
19
- "disconnecting the current instance to update the cloud sqlite database."
20
- )
21
- disconnect()
22
- except SystemExit as e:
23
- if str(e) != "No instance connected! Call `lamin connect` or `lamin init`":
24
- raise e
25
-
26
- cache_dir = settings.cache_dir
27
- if cache_dir.exists():
28
- shutil.rmtree(cache_dir)
29
- cache_dir.mkdir()
30
- logger.success("the cache directory was cleared")
31
- else:
32
- logger.warning("the cache directory doesn't exist")
33
-
34
-
35
- def get_cache_dir():
36
- from lamindb_setup import settings
37
-
38
- return settings.cache_dir.as_posix()
39
-
40
-
41
- def set_cache_dir(cache_dir: str):
42
- from lamindb_setup.core._settings import (
43
- DEFAULT_CACHE_DIR,
44
- _process_cache_path,
45
- settings,
46
- )
47
-
48
- old_cache_dir = settings.cache_dir
49
- new_cache_dir = _process_cache_path(cache_dir)
50
-
51
- system_cache_dir = None
52
- if (system_settings := system_settings_file()).exists():
53
- system_cache_dir = dotenv_values(system_settings).get(
54
- "lamindb_cache_path", None
55
- )
56
- system_cache_dir = (
57
- Path(system_cache_dir) if system_cache_dir is not None else None
58
- )
59
-
60
- need_reset = False
61
- if new_cache_dir is None:
62
- need_reset = True
63
- new_cache_dir = (
64
- DEFAULT_CACHE_DIR if system_cache_dir is None else system_cache_dir
65
- )
66
-
67
- if new_cache_dir != old_cache_dir:
68
- if old_cache_dir.exists():
69
- shutil.copytree(old_cache_dir, new_cache_dir, dirs_exist_ok=True)
70
- logger.info(
71
- f"the current cache directory was copied to {new_cache_dir.as_posix()} "
72
- )
73
- if old_cache_dir != system_cache_dir:
74
- shutil.rmtree(old_cache_dir)
75
- logger.info(
76
- f"cleared the old cache directory {old_cache_dir.as_posix()}"
77
- )
78
- else:
79
- logger.info(
80
- f"didn't clear the system cache directory {system_cache_dir.as_posix()}, "
81
- "please clear it manually if you need"
82
- )
83
- else:
84
- new_cache_dir.mkdir(parents=True, exist_ok=True)
85
- new_cache_dir = new_cache_dir.resolve()
86
- save_platform_user_storage_settings(None if need_reset else new_cache_dir)
87
- settings._cache_dir = new_cache_dir
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ from pathlib import Path
5
+
6
+ from dotenv import dotenv_values
7
+ from lamin_utils import logger
8
+
9
+ from .core._settings_save import save_platform_user_storage_settings
10
+ from .core._settings_store import system_settings_file
11
+
12
+
13
+ def clear_cache_dir():
14
+ from lamindb_setup import disconnect, settings
15
+
16
+ try:
17
+ if settings.instance._is_cloud_sqlite:
18
+ logger.warning(
19
+ "disconnecting the current instance to update the cloud sqlite database."
20
+ )
21
+ disconnect()
22
+ except SystemExit as e:
23
+ if str(e) != "No instance connected! Call `lamin connect` or `lamin init`":
24
+ raise e
25
+
26
+ cache_dir = settings.cache_dir
27
+ if cache_dir.exists():
28
+ shutil.rmtree(cache_dir)
29
+ cache_dir.mkdir()
30
+ logger.success("the cache directory was cleared")
31
+ else:
32
+ logger.warning("the cache directory doesn't exist")
33
+
34
+
35
+ def get_cache_dir():
36
+ from lamindb_setup import settings
37
+
38
+ return settings.cache_dir.as_posix()
39
+
40
+
41
+ def set_cache_dir(cache_dir: str):
42
+ from lamindb_setup.core._settings import (
43
+ DEFAULT_CACHE_DIR,
44
+ _process_cache_path,
45
+ settings,
46
+ )
47
+
48
+ old_cache_dir = settings.cache_dir
49
+ new_cache_dir = _process_cache_path(cache_dir)
50
+
51
+ system_cache_dir = None
52
+ if (system_settings := system_settings_file()).exists():
53
+ system_cache_dir = dotenv_values(system_settings).get(
54
+ "lamindb_cache_path", None
55
+ )
56
+ system_cache_dir = (
57
+ Path(system_cache_dir) if system_cache_dir is not None else None
58
+ )
59
+
60
+ need_reset = False
61
+ if new_cache_dir is None:
62
+ need_reset = True
63
+ new_cache_dir = (
64
+ DEFAULT_CACHE_DIR if system_cache_dir is None else system_cache_dir
65
+ )
66
+
67
+ if new_cache_dir != old_cache_dir:
68
+ if old_cache_dir.exists():
69
+ shutil.copytree(old_cache_dir, new_cache_dir, dirs_exist_ok=True)
70
+ logger.info(
71
+ f"the current cache directory was copied to {new_cache_dir.as_posix()} "
72
+ )
73
+ if old_cache_dir != system_cache_dir:
74
+ shutil.rmtree(old_cache_dir)
75
+ logger.info(
76
+ f"cleared the old cache directory {old_cache_dir.as_posix()}"
77
+ )
78
+ else:
79
+ logger.info(
80
+ f"didn't clear the system cache directory {system_cache_dir.as_posix()}, "
81
+ "please clear it manually if you need"
82
+ )
83
+ else:
84
+ new_cache_dir.mkdir(parents=True, exist_ok=True)
85
+ new_cache_dir = new_cache_dir.resolve()
86
+ save_platform_user_storage_settings(None if need_reset else new_cache_dir)
87
+ settings._cache_dir = new_cache_dir