lamin_cli 0.16.0__py2.py3-none-any.whl → 0.16.2__py2.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.
- lamin_cli/__init__.py +1 -1
- lamin_cli/__main__.py +12 -5
- lamin_cli/_save.py +30 -19
- {lamin_cli-0.16.0.dist-info → lamin_cli-0.16.2.dist-info}/METADATA +1 -1
- lamin_cli-0.16.2.dist-info/RECORD +10 -0
- lamin_cli-0.16.0.dist-info/RECORD +0 -10
- {lamin_cli-0.16.0.dist-info → lamin_cli-0.16.2.dist-info}/WHEEL +0 -0
- {lamin_cli-0.16.0.dist-info → lamin_cli-0.16.2.dist-info}/entry_points.txt +0 -0
lamin_cli/__init__.py
CHANGED
lamin_cli/__main__.py
CHANGED
|
@@ -5,6 +5,7 @@ from collections import OrderedDict
|
|
|
5
5
|
import inspect
|
|
6
6
|
from importlib.metadata import PackageNotFoundError, version
|
|
7
7
|
from typing import Optional, Mapping
|
|
8
|
+
from functools import wraps
|
|
8
9
|
|
|
9
10
|
# https://github.com/ewels/rich-click/issues/19
|
|
10
11
|
# Otherwise rich-click takes over the formatting.
|
|
@@ -60,12 +61,18 @@ else:
|
|
|
60
61
|
]
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
lamin_group_decorator
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
def lamin_group_decorator(f):
|
|
65
|
+
@click.rich_config(
|
|
66
|
+
help_config=click.RichHelpConfiguration(
|
|
67
|
+
command_groups=COMMAND_GROUPS,
|
|
68
|
+
style_commands_table_column_width_ratio=(1, 13),
|
|
69
|
+
)
|
|
67
70
|
)
|
|
68
|
-
|
|
71
|
+
@click.group()
|
|
72
|
+
@wraps(f)
|
|
73
|
+
def wrapper(*args, **kwargs):
|
|
74
|
+
return f(*args, **kwargs)
|
|
75
|
+
return wrapper
|
|
69
76
|
|
|
70
77
|
|
|
71
78
|
from click import Command, Context
|
lamin_cli/_save.py
CHANGED
|
@@ -6,17 +6,21 @@ from lamin_utils import logger
|
|
|
6
6
|
import re
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def get_stem_uid_and_version_from_file(
|
|
9
|
+
def get_stem_uid_and_version_from_file(
|
|
10
|
+
file_path: Path,
|
|
11
|
+
) -> tuple[str | None, str | None, str | None]:
|
|
10
12
|
# line-by-line matching might be faster, but let's go with this for now
|
|
11
13
|
with open(file_path) as file:
|
|
12
14
|
content = file.read()
|
|
13
15
|
|
|
14
16
|
if file_path.suffix == ".py":
|
|
17
|
+
uid_pattern = re.compile(r'\.context\.uid\s*=\s*["\']([^"\']+)["\']')
|
|
15
18
|
stem_uid_pattern = re.compile(
|
|
16
19
|
r'\.transform\.stem_uid\s*=\s*["\']([^"\']+)["\']'
|
|
17
20
|
)
|
|
18
21
|
version_pattern = re.compile(r'\.transform\.version\s*=\s*["\']([^"\']+)["\']')
|
|
19
22
|
elif file_path.suffix == ".ipynb":
|
|
23
|
+
uid_pattern = re.compile(r'\.context\.uid\s*=\s*\\["\']([^"\']+)\\["\']')
|
|
20
24
|
stem_uid_pattern = re.compile(
|
|
21
25
|
r'\.transform\.stem_uid\s*=\s*\\["\']([^"\']+)\\["\']'
|
|
22
26
|
)
|
|
@@ -27,20 +31,22 @@ def get_stem_uid_and_version_from_file(file_path: Path) -> tuple[str, str]:
|
|
|
27
31
|
raise ValueError("Only .py and .ipynb files are supported.")
|
|
28
32
|
|
|
29
33
|
# Search for matches in the entire file content
|
|
34
|
+
uid_match = uid_pattern.search(content)
|
|
30
35
|
stem_uid_match = stem_uid_pattern.search(content)
|
|
31
36
|
version_match = version_pattern.search(content)
|
|
32
37
|
|
|
33
38
|
# Extract values if matches are found
|
|
39
|
+
uid = uid_match.group(1) if uid_match else None
|
|
34
40
|
stem_uid = stem_uid_match.group(1) if stem_uid_match else None
|
|
35
41
|
version = version_match.group(1) if version_match else None
|
|
36
42
|
|
|
37
|
-
if stem_uid is None or version is None:
|
|
43
|
+
if uid is None and (stem_uid is None or version is None):
|
|
38
44
|
raise SystemExit(
|
|
39
|
-
"ln.
|
|
40
|
-
f" set in {file_path}\nCall ln.track() and copy/paste the output
|
|
41
|
-
" notebook"
|
|
45
|
+
"ln.context.uid isn't"
|
|
46
|
+
f" set in {file_path}\nCall ln.context.track() and copy/paste the output"
|
|
47
|
+
" into the notebook"
|
|
42
48
|
)
|
|
43
|
-
return stem_uid, version
|
|
49
|
+
return uid, stem_uid, version
|
|
44
50
|
|
|
45
51
|
|
|
46
52
|
def save_from_filepath_cli(
|
|
@@ -55,7 +61,7 @@ def save_from_filepath_cli(
|
|
|
55
61
|
ln_setup.settings.auto_connect = True
|
|
56
62
|
|
|
57
63
|
import lamindb as ln
|
|
58
|
-
from lamindb._finish import
|
|
64
|
+
from lamindb._finish import save_context_core
|
|
59
65
|
|
|
60
66
|
ln_setup.settings.auto_connect = auto_connect_state
|
|
61
67
|
|
|
@@ -75,17 +81,22 @@ def save_from_filepath_cli(
|
|
|
75
81
|
return None
|
|
76
82
|
else:
|
|
77
83
|
# consider notebooks & scripts a transform
|
|
78
|
-
stem_uid, transform_version = get_stem_uid_and_version_from_file(filepath)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
uid, stem_uid, transform_version = get_stem_uid_and_version_from_file(filepath)
|
|
85
|
+
if uid is not None:
|
|
86
|
+
transform = ln.Transform.filter(uid=uid).one_or_none()
|
|
87
|
+
if transform is None:
|
|
88
|
+
logger.error(
|
|
89
|
+
f"Did not find uid '{uid}'"
|
|
90
|
+
" in Transform registry. Did you run ln.context.track()?"
|
|
91
|
+
)
|
|
92
|
+
return "not-tracked-in-transform-registry"
|
|
93
|
+
# refactor this, save_context_core should not depend on transform_family
|
|
94
|
+
transform_family = transform.versions
|
|
95
|
+
else:
|
|
96
|
+
# the corresponding transform family in the transform table
|
|
97
|
+
transform_family = ln.Transform.filter(uid__startswith=stem_uid).all()
|
|
98
|
+
# the specific version
|
|
99
|
+
transform = transform_family.filter(version=transform_version).one()
|
|
89
100
|
# latest run of this transform by user
|
|
90
101
|
run = ln.Run.filter(transform=transform).order_by("-started_at").first()
|
|
91
102
|
if run.created_by.id != ln_setup.settings.user.id:
|
|
@@ -95,7 +106,7 @@ def save_from_filepath_cli(
|
|
|
95
106
|
)
|
|
96
107
|
if response != "y":
|
|
97
108
|
return "aborted-save-notebook-created-by-different-user"
|
|
98
|
-
return
|
|
109
|
+
return save_context_core(
|
|
99
110
|
run=run,
|
|
100
111
|
transform=transform,
|
|
101
112
|
filepath=filepath,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
lamin_cli/__init__.py,sha256=crsjcR_B06Sik0bsq8ZMipKFmOk_AehyoD__l5IV20c,41
|
|
2
|
+
lamin_cli/__main__.py,sha256=B2zUf8d7vcoCN-SuEo7dtlJg-waJgYyd-Y--ZZatP2E,7988
|
|
3
|
+
lamin_cli/_cache.py,sha256=WMDUkJyATVdN8pMqgqw1DZLVym-CaBjCHEoRimI69LQ,813
|
|
4
|
+
lamin_cli/_get.py,sha256=MXcR9PTW0FzY3uIPa-50SLCrtuRElxgDB3Vkfo-TFT0,1616
|
|
5
|
+
lamin_cli/_migration.py,sha256=dULOvbpJ4VBiXuxPAM8jFGnBkh7pQGqE5eP-UC6uxWc,1055
|
|
6
|
+
lamin_cli/_save.py,sha256=LP-5ykImaWDad2walTTU9wiWUHt8LyNmrxr3qedKu7Y,4830
|
|
7
|
+
lamin_cli-0.16.2.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
8
|
+
lamin_cli-0.16.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
9
|
+
lamin_cli-0.16.2.dist-info/METADATA,sha256=i76L8XLfj-w-LpBmrw5ThHqyQILIrIg_BFcP90j3rTM,336
|
|
10
|
+
lamin_cli-0.16.2.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
lamin_cli/__init__.py,sha256=ywCiO8sjaEgq6RmyOv4ubgOrE_UIXqs2_mGwLeaJtPU,41
|
|
2
|
-
lamin_cli/__main__.py,sha256=kyK2tFuGbk-aR-25sO5Rta_pkzDknBkGyd7ElPYjaNU,7800
|
|
3
|
-
lamin_cli/_cache.py,sha256=WMDUkJyATVdN8pMqgqw1DZLVym-CaBjCHEoRimI69LQ,813
|
|
4
|
-
lamin_cli/_get.py,sha256=MXcR9PTW0FzY3uIPa-50SLCrtuRElxgDB3Vkfo-TFT0,1616
|
|
5
|
-
lamin_cli/_migration.py,sha256=dULOvbpJ4VBiXuxPAM8jFGnBkh7pQGqE5eP-UC6uxWc,1055
|
|
6
|
-
lamin_cli/_save.py,sha256=6mu6sAVcXsq4-XW-tzcVxUVh-Gv7e9EFkTyMmdrCGNw,4291
|
|
7
|
-
lamin_cli-0.16.0.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
8
|
-
lamin_cli-0.16.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
9
|
-
lamin_cli-0.16.0.dist-info/METADATA,sha256=HGnHx539zZLJNhpwcH3yO_aVkKtEPjGxI-4BET5Eh6k,336
|
|
10
|
-
lamin_cli-0.16.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|