lamin_cli 0.20.1__py2.py3-none-any.whl → 0.21.0__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/_save.py +58 -15
- {lamin_cli-0.20.1.dist-info → lamin_cli-0.21.0.dist-info}/METADATA +1 -1
- {lamin_cli-0.20.1.dist-info → lamin_cli-0.21.0.dist-info}/RECORD +7 -7
- {lamin_cli-0.20.1.dist-info → lamin_cli-0.21.0.dist-info}/LICENSE +0 -0
- {lamin_cli-0.20.1.dist-info → lamin_cli-0.21.0.dist-info}/WHEEL +0 -0
- {lamin_cli-0.20.1.dist-info → lamin_cli-0.21.0.dist-info}/entry_points.txt +0 -0
lamin_cli/__init__.py
CHANGED
lamin_cli/_save.py
CHANGED
|
@@ -27,28 +27,40 @@ def parse_uid_from_code(
|
|
|
27
27
|
version_pattern = re.compile(
|
|
28
28
|
r'\.transform\.version\s*=\s*\\["\']([^"\']+)\\["\']'
|
|
29
29
|
)
|
|
30
|
+
elif suffix in {".R", ".qmd", ".Rmd"}:
|
|
31
|
+
track_pattern = re.compile(r'track\(\s*[\'"]([a-zA-Z0-9]{16})[\'"]')
|
|
32
|
+
uid_pattern = None
|
|
33
|
+
stem_uid_pattern = None
|
|
34
|
+
version_pattern = None
|
|
30
35
|
else:
|
|
31
|
-
raise
|
|
36
|
+
raise SystemExit(
|
|
37
|
+
"Only .py, .ipynb, .R, .qmd, .Rmd files are supported for saving"
|
|
38
|
+
" transforms."
|
|
39
|
+
)
|
|
32
40
|
|
|
33
41
|
# Search for matches in the entire file content
|
|
34
42
|
uid_match = track_pattern.search(content)
|
|
35
43
|
uid = uid_match.group(1) if uid_match else None
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
stem_uid_match = stem_uid_pattern.search(content)
|
|
39
|
-
version_match = version_pattern.search(content)
|
|
44
|
+
stem_uid = None
|
|
45
|
+
version = None
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
if uid_pattern is not None and uid is None:
|
|
48
|
+
uid_match = uid_pattern.search(content)
|
|
49
|
+
uid = uid_match.group(1) if uid_match else None
|
|
50
|
+
if stem_uid_pattern is not None:
|
|
51
|
+
stem_uid_match = stem_uid_pattern.search(content)
|
|
52
|
+
stem_uid = stem_uid_match.group(1) if stem_uid_match else None
|
|
53
|
+
if version_pattern is not None:
|
|
54
|
+
version_match = version_pattern.search(content)
|
|
55
|
+
version = version_match.group(1) if version_match else None
|
|
45
56
|
|
|
46
57
|
if uid is None and (stem_uid is None or version is None):
|
|
58
|
+
target = "script" if suffix == ".py" else "notebook"
|
|
47
59
|
raise SystemExit(
|
|
48
60
|
"Cannot infer transform uid."
|
|
49
|
-
"\nCall `ln.track()` and copy/paste the output"
|
|
50
|
-
" into the notebook"
|
|
61
|
+
f"\nCall `ln.track()` and copy/paste the output into the {target}."
|
|
51
62
|
)
|
|
63
|
+
|
|
52
64
|
return uid, stem_uid, version
|
|
53
65
|
|
|
54
66
|
|
|
@@ -71,8 +83,27 @@ def save_from_filepath_cli(
|
|
|
71
83
|
|
|
72
84
|
ln_setup.settings.auto_connect = auto_connect_state
|
|
73
85
|
|
|
86
|
+
suffixes_transform = {
|
|
87
|
+
"py": set([".py", ".ipynb"]),
|
|
88
|
+
"R": set([".R", ".qmd", ".Rmd"]),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
filepath.suffix in {".qmd", ".Rmd"}
|
|
93
|
+
and not filepath.with_suffix(".html").exists()
|
|
94
|
+
):
|
|
95
|
+
raise SystemExit(
|
|
96
|
+
f"Please export your {filepath.suffix} file as an html file here"
|
|
97
|
+
f" {filepath.with_suffix('.html')}"
|
|
98
|
+
)
|
|
99
|
+
|
|
74
100
|
if registry is None:
|
|
75
|
-
registry =
|
|
101
|
+
registry = (
|
|
102
|
+
"transform"
|
|
103
|
+
if filepath.suffix
|
|
104
|
+
in suffixes_transform["py"].union(suffixes_transform["R"])
|
|
105
|
+
else "artifact"
|
|
106
|
+
)
|
|
76
107
|
|
|
77
108
|
if registry == "artifact":
|
|
78
109
|
ln.settings.creation.artifact_silence_missing_run_warning = True
|
|
@@ -107,16 +138,28 @@ def save_from_filepath_cli(
|
|
|
107
138
|
run = ln.Run.filter(transform=transform).order_by("-started_at").first()
|
|
108
139
|
if run.created_by.id != ln_setup.settings.user.id:
|
|
109
140
|
response = input(
|
|
110
|
-
"You are trying to save a transform created by another user: Source
|
|
111
|
-
" report files will be tagged with *your* user id. Proceed?
|
|
141
|
+
"You are trying to save a transform created by another user: Source"
|
|
142
|
+
" and report files will be tagged with *your* user id. Proceed?"
|
|
143
|
+
" (y/n)"
|
|
112
144
|
)
|
|
113
145
|
if response != "y":
|
|
114
146
|
return "aborted-save-notebook-created-by-different-user"
|
|
115
|
-
|
|
147
|
+
return_code = save_context_core(
|
|
116
148
|
run=run,
|
|
117
149
|
transform=transform,
|
|
118
150
|
filepath=filepath,
|
|
119
151
|
from_cli=True,
|
|
120
152
|
)
|
|
153
|
+
if filepath.suffix in {".qmd", ".Rmd"}:
|
|
154
|
+
report_file = ln.Artifact(
|
|
155
|
+
filepath.with_suffix(".html"), # validated at the top that this exists
|
|
156
|
+
description=f"Report of run {run.uid}",
|
|
157
|
+
visibility=0, # hidden file
|
|
158
|
+
run=False,
|
|
159
|
+
)
|
|
160
|
+
report_file.save(upload=True, print_progress=False)
|
|
161
|
+
run.report = report_file
|
|
162
|
+
run.save()
|
|
163
|
+
return return_code
|
|
121
164
|
else:
|
|
122
165
|
raise SystemExit("Allowed values for '--registry' are: 'artifact', 'transform'")
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
lamin_cli/__init__.py,sha256=
|
|
1
|
+
lamin_cli/__init__.py,sha256=l58JBVXTnppQV3BQhZAl6MnYMXTuBJjdstE6eavYM0g,41
|
|
2
2
|
lamin_cli/__main__.py,sha256=-QAfgrYKcPjl0qkiWr8Tfm5wRaaZ99rW2atjIBnBn9Y,9900
|
|
3
3
|
lamin_cli/_cache.py,sha256=kW8rqlMwQeOngm9uq2gjzPVl3EBrwh6W2F2AvyBFABY,799
|
|
4
4
|
lamin_cli/_load.py,sha256=n0_qHTCXsZQIUy87rVdPvT89fx60N-KZgn_dL8nsvEA,5523
|
|
5
5
|
lamin_cli/_migration.py,sha256=xTbad6aDUwuK0QvWCmDW3f8-xaqwisS-Cqf-LbD1WRI,1071
|
|
6
|
-
lamin_cli/_save.py,sha256=
|
|
6
|
+
lamin_cli/_save.py,sha256=eId1DYClPEt_pxccjzp6EYpevp3rIBRPXC3DETKPxOQ,6395
|
|
7
7
|
lamin_cli/_settings.py,sha256=iS37mcQUHKRWxi2sHnAojEI6sWk3w232qwG-GeY2_Qc,1141
|
|
8
|
-
lamin_cli-0.
|
|
9
|
-
lamin_cli-0.
|
|
10
|
-
lamin_cli-0.
|
|
11
|
-
lamin_cli-0.
|
|
12
|
-
lamin_cli-0.
|
|
8
|
+
lamin_cli-0.21.0.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
9
|
+
lamin_cli-0.21.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
10
|
+
lamin_cli-0.21.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
11
|
+
lamin_cli-0.21.0.dist-info/METADATA,sha256=pjXGmeJ4QwXxAtpreQmCUVWM0V-TwUS8CUqXKwYrSvE,375
|
|
12
|
+
lamin_cli-0.21.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|