lamin_cli 0.16.1__py2.py3-none-any.whl → 0.16.3__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 +14 -14
- lamin_cli/_cache.py +1 -1
- lamin_cli/_save.py +30 -19
- {lamin_cli-0.16.1.dist-info → lamin_cli-0.16.3.dist-info}/METADATA +1 -1
- lamin_cli-0.16.3.dist-info/RECORD +10 -0
- lamin_cli-0.16.1.dist-info/RECORD +0 -10
- {lamin_cli-0.16.1.dist-info → lamin_cli-0.16.3.dist-info}/WHEEL +0 -0
- {lamin_cli-0.16.1.dist-info → lamin_cli-0.16.3.dist-info}/entry_points.txt +0 -0
lamin_cli/__init__.py
CHANGED
lamin_cli/__main__.py
CHANGED
|
@@ -52,7 +52,7 @@ else:
|
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"name": "Configuration commands",
|
|
55
|
-
"commands": ["
|
|
55
|
+
"commands": ["cache", "set"],
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "Schema commands",
|
|
@@ -72,6 +72,7 @@ else:
|
|
|
72
72
|
@wraps(f)
|
|
73
73
|
def wrapper(*args, **kwargs):
|
|
74
74
|
return f(*args, **kwargs)
|
|
75
|
+
|
|
75
76
|
return wrapper
|
|
76
77
|
|
|
77
78
|
|
|
@@ -97,15 +98,22 @@ def main():
|
|
|
97
98
|
@main.command()
|
|
98
99
|
@click.argument("user", type=str)
|
|
99
100
|
@click.option("--key", type=str, default=None, help="API key")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
def login(user: str, key: Optional[str]):
|
|
102
|
+
"""Log into LaminHub.
|
|
103
|
+
|
|
104
|
+
Upon logging in the first time, you need to pass your API key via
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
lamin login myemail@acme.com --key YOUR_API_KEY
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
You'll find your API key in the top right corner under "Settings".
|
|
103
111
|
|
|
104
|
-
|
|
112
|
+
After this, you can either use `lamin login myhandle` or `lamin login myemail@acme.com`
|
|
105
113
|
"""
|
|
106
114
|
from lamindb_setup._setup_user import login
|
|
107
115
|
|
|
108
|
-
return login(user, key=key
|
|
116
|
+
return login(user, key=key)
|
|
109
117
|
|
|
110
118
|
|
|
111
119
|
# fmt: off
|
|
@@ -202,14 +210,6 @@ def save(filepath: str, key: str, description: str):
|
|
|
202
210
|
sys.exit(1)
|
|
203
211
|
|
|
204
212
|
|
|
205
|
-
@main.command()
|
|
206
|
-
def register():
|
|
207
|
-
"""Register an instance on the hub."""
|
|
208
|
-
from lamindb_setup._register_instance import register as register_
|
|
209
|
-
|
|
210
|
-
return register_()
|
|
211
|
-
|
|
212
|
-
|
|
213
213
|
main.add_command(cache)
|
|
214
214
|
|
|
215
215
|
|
lamin_cli/_cache.py
CHANGED
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.get(version=transform_version)
|
|
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=-VEBAkJGvngQDNsXIQb5tfZImdAMjJW8VcZ1T7rx834,41
|
|
2
|
+
lamin_cli/__main__.py,sha256=7mUJe-6Vq8WNNR90t2j0Pa_XLMNaS9rdctj7OEfhum0,7898
|
|
3
|
+
lamin_cli/_cache.py,sha256=6LrrWNrdZzH_BrohQ2n24xLFhUQ5EFan1bnzqMX_mIg,812
|
|
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=H_QQzWE3fId0GtM4LiIdNcgi81Wafvjh_V9B30SweBk,4821
|
|
7
|
+
lamin_cli-0.16.3.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
8
|
+
lamin_cli-0.16.3.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
9
|
+
lamin_cli-0.16.3.dist-info/METADATA,sha256=TMhHC2h49W_lpMqFg4TOu2JvdOxY9N4u2gJvNuDeO9E,336
|
|
10
|
+
lamin_cli-0.16.3.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
lamin_cli/__init__.py,sha256=0yhPWneaCpI0YddQjW0b_76vC9Td3W2SiDUC16eBKlg,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=6mu6sAVcXsq4-XW-tzcVxUVh-Gv7e9EFkTyMmdrCGNw,4291
|
|
7
|
-
lamin_cli-0.16.1.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
8
|
-
lamin_cli-0.16.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
9
|
-
lamin_cli-0.16.1.dist-info/METADATA,sha256=svDLkC_KV1xcYGK0H5GCWnQHVLm-h6x4P-NQnmZ6Owk,336
|
|
10
|
-
lamin_cli-0.16.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|