lamin_cli 1.4.0__tar.gz → 1.4.2__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.
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/PKG-INFO +1 -1
- lamin_cli-1.4.2/lamin_cli/__init__.py +3 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/__main__.py +7 -2
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/_save.py +28 -4
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/conftest.py +4 -4
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_migrate.py +3 -3
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_save_files.py +10 -4
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_save_notebooks.py +1 -1
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_save_scripts.py +1 -1
- lamin_cli-1.4.0/lamin_cli/__init__.py +0 -3
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/.github/workflows/build.yml +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/.github/workflows/doc-changes.yml +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/.gitignore +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/.pre-commit-config.yaml +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/LICENSE +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/README.md +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/_cache.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/_load.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/_migration.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/_settings.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/compute/__init__.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/lamin_cli/compute/modal.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/noxfile.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/pyproject.toml +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_cli.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_load.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_multi_process.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_parse_uid_from_code.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/core/test_save_r_code.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/modal/test_modal.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/notebooks/not-initialized.ipynb +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/merely-import-lamindb.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/run-track-and-finish-sync-git.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/run-track-and-finish.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/run-track-with-params.py +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/run-track.R +0 -0
- {lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/scripts/run-track.qmd +0 -0
|
@@ -314,8 +314,10 @@ def get(entity: str, uid: str | None = None, key: str | None = None):
|
|
|
314
314
|
@click.option("--description", type=str, default=None, help="A description of the artifact or transform.")
|
|
315
315
|
@click.option("--stem-uid", type=str, default=None, help="The stem uid of the artifact or transform.")
|
|
316
316
|
@click.option("--project", type=str, default=None, help="A valid project name or uid.")
|
|
317
|
+
@click.option("--space", type=str, default=None, help="A valid space name or uid.")
|
|
318
|
+
@click.option("--branch", type=str, default=None, help="A valid branch name or uid.")
|
|
317
319
|
@click.option("--registry", type=str, default=None, help="Either 'artifact' or 'transform'. If not passed, chooses based on path suffix.")
|
|
318
|
-
def save(path: str, key: str, description: str, stem_uid: str, project: str, registry: str):
|
|
320
|
+
def save(path: str, key: str, description: str, stem_uid: str, project: str, space: str, branch: str, registry: str):
|
|
319
321
|
"""Save a file or folder.
|
|
320
322
|
|
|
321
323
|
Example: Given a valid project name "my_project".
|
|
@@ -324,13 +326,16 @@ def save(path: str, key: str, description: str, stem_uid: str, project: str, reg
|
|
|
324
326
|
lamin save my_table.csv --key my_tables/my_table.csv --project my_project
|
|
325
327
|
```
|
|
326
328
|
|
|
329
|
+
By passing a `--project` identifier, the artifact will be labeled with the corresponding project.
|
|
330
|
+
If you pass a `--space` or `--branch` identifier, you save the artifact in the corresponding {class}`~lamindb.Space` or on the corresponding {class}`~lamindb.Branch`.
|
|
331
|
+
|
|
327
332
|
Note: Defaults to saving `.py`, `.ipynb`, `.R`, `.Rmd`, and `.qmd` as {class}`~lamindb.Transform` and
|
|
328
333
|
other file types and folders as {class}`~lamindb.Artifact`. You can enforce saving a file as
|
|
329
334
|
an {class}`~lamindb.Artifact` by passing `--registry artifact`.
|
|
330
335
|
"""
|
|
331
336
|
from lamin_cli._save import save_from_path_cli
|
|
332
337
|
|
|
333
|
-
if save_from_path_cli(path, key, description, stem_uid, project, registry) is not None:
|
|
338
|
+
if save_from_path_cli(path=path, key=key, description=description, stem_uid=stem_uid, project=project, space=space, branch=branch, registry=registry) is not None:
|
|
334
339
|
sys.exit(1)
|
|
335
340
|
|
|
336
341
|
|
|
@@ -52,6 +52,8 @@ def save_from_path_cli(
|
|
|
52
52
|
description: str | None,
|
|
53
53
|
stem_uid: str | None,
|
|
54
54
|
project: str | None,
|
|
55
|
+
space: str | None,
|
|
56
|
+
branch: str | None,
|
|
55
57
|
registry: str | None,
|
|
56
58
|
) -> str | None:
|
|
57
59
|
import lamindb_setup as ln_setup
|
|
@@ -97,6 +99,20 @@ def save_from_path_cli(
|
|
|
97
99
|
raise ln.errors.InvalidArgument(
|
|
98
100
|
f"Project '{project}' not found, either create it with `ln.Project(name='...').save()` or fix typos."
|
|
99
101
|
)
|
|
102
|
+
if space is not None:
|
|
103
|
+
space_record = ln.Space.filter(ln.Q(name=space) | ln.Q(uid=space)).one_or_none()
|
|
104
|
+
if space_record is None:
|
|
105
|
+
raise ln.errors.InvalidArgument(
|
|
106
|
+
f"Space '{space}' not found, either create it on LaminHub or fix typos."
|
|
107
|
+
)
|
|
108
|
+
if branch is not None:
|
|
109
|
+
branch_record = ln.Branch.filter(
|
|
110
|
+
ln.Q(name=branch) | ln.Q(uid=branch)
|
|
111
|
+
).one_or_none()
|
|
112
|
+
if branch_record is None:
|
|
113
|
+
raise ln.errors.InvalidArgument(
|
|
114
|
+
f"Branch '{branch}' not found, either create it with `ln.Branch(name='...').save()` or fix typos."
|
|
115
|
+
)
|
|
100
116
|
|
|
101
117
|
is_cloud_path = not isinstance(path, LocalPathClasses)
|
|
102
118
|
|
|
@@ -120,9 +136,12 @@ def save_from_path_cli(
|
|
|
120
136
|
logger.error("Please pass a key or description via --key or --description")
|
|
121
137
|
return "missing-key-or-description"
|
|
122
138
|
|
|
123
|
-
artifact = ln.Artifact(
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
artifact = ln.Artifact(path, key=key, description=description, revises=revises)
|
|
140
|
+
if space is not None:
|
|
141
|
+
artifact.space = space_record
|
|
142
|
+
if branch is not None:
|
|
143
|
+
artifact.branch = branch_record
|
|
144
|
+
artifact.save()
|
|
126
145
|
logger.important(f"saved: {artifact}")
|
|
127
146
|
logger.important(f"storage path: {artifact.path}")
|
|
128
147
|
if ln_setup.settings.storage.type == "s3":
|
|
@@ -208,7 +227,12 @@ def save_from_path_cli(
|
|
|
208
227
|
key=path.name,
|
|
209
228
|
type="script" if path.suffix in {".R", ".py"} else "notebook",
|
|
210
229
|
revises=revises,
|
|
211
|
-
)
|
|
230
|
+
)
|
|
231
|
+
if space is not None:
|
|
232
|
+
transform.space = space_record
|
|
233
|
+
if branch is not None:
|
|
234
|
+
transform.branch = branch_record
|
|
235
|
+
transform.save()
|
|
212
236
|
logger.important(f"created Transform('{transform.uid}')")
|
|
213
237
|
if project is not None:
|
|
214
238
|
transform.projects.add(project_record)
|
|
@@ -7,13 +7,13 @@ from lamin_utils import logger
|
|
|
7
7
|
|
|
8
8
|
def pytest_sessionstart(session: pytest.Session):
|
|
9
9
|
ln.setup.init(
|
|
10
|
-
storage="./
|
|
11
|
-
name="
|
|
10
|
+
storage="./default_storage_cli",
|
|
11
|
+
name="lamin-cli-unit-tests",
|
|
12
12
|
)
|
|
13
13
|
ln.setup.settings.auto_connect = True
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def pytest_sessionfinish(session: pytest.Session):
|
|
17
17
|
logger.set_verbosity(1)
|
|
18
|
-
shutil.rmtree("./
|
|
19
|
-
ln.setup.delete("
|
|
18
|
+
shutil.rmtree("./default_storage_cli")
|
|
19
|
+
ln.setup.delete("lamin-cli-unit-tests", force=True)
|
|
@@ -5,9 +5,9 @@ import os
|
|
|
5
5
|
# import lamindb_setup as ln_setup
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def test_migrate_create():
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
# def test_migrate_create():
|
|
9
|
+
# exit_status = os.system("lamin migrate create")
|
|
10
|
+
# assert exit_status == 0
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def test_migrate_deploy():
|
|
@@ -24,10 +24,12 @@ def test_save_local_file():
|
|
|
24
24
|
)
|
|
25
25
|
assert result.returncode == 1
|
|
26
26
|
|
|
27
|
-
ln.Project(name="test_project").save()
|
|
27
|
+
project = ln.Project(name="test_project").save()
|
|
28
|
+
# cannot define Space with regular user, is defined in lamindb/tests/permissions
|
|
29
|
+
branch = ln.Branch(name="contrib1").save()
|
|
28
30
|
|
|
29
31
|
result = subprocess.run(
|
|
30
|
-
f"lamin save {filepath} --key mytest --project test_project",
|
|
32
|
+
f"lamin save {filepath} --key mytest --project test_project --branch contrib1",
|
|
31
33
|
shell=True,
|
|
32
34
|
capture_output=True,
|
|
33
35
|
)
|
|
@@ -38,6 +40,10 @@ def test_save_local_file():
|
|
|
38
40
|
assert "labeled with project: test_project" in result.stdout.decode()
|
|
39
41
|
assert result.returncode == 0
|
|
40
42
|
|
|
43
|
+
artifact = ln.Artifact.get(key="mytest")
|
|
44
|
+
assert artifact.branch == branch
|
|
45
|
+
assert project in artifact.projects.all()
|
|
46
|
+
|
|
41
47
|
# test passing the registry and saving the same file
|
|
42
48
|
result = subprocess.run(
|
|
43
49
|
f"lamin save {filepath} --key mytest --registry artifact",
|
|
@@ -69,14 +75,14 @@ def test_save_local_file():
|
|
|
69
75
|
def test_save_cloud_file():
|
|
70
76
|
# should be no key for cloud paths
|
|
71
77
|
result = subprocess.run(
|
|
72
|
-
"lamin save s3://
|
|
78
|
+
"lamin save s3://cellxgene-data-public/cell-census/2024-07-01/h5ads/fe1a73ab-a203-45fd-84e9-0f7fd19efcbd.h5ad --key wrongkey.h5ad",
|
|
73
79
|
shell=True,
|
|
74
80
|
check=False,
|
|
75
81
|
)
|
|
76
82
|
assert result.returncode == 1
|
|
77
83
|
|
|
78
84
|
result = subprocess.run(
|
|
79
|
-
"lamin save s3://
|
|
85
|
+
"lamin save s3://cellxgene-data-public/cell-census/2024-07-01/h5ads/fe1a73ab-a203-45fd-84e9-0f7fd19efcbd.h5ad",
|
|
80
86
|
shell=True,
|
|
81
87
|
check=True,
|
|
82
88
|
)
|
|
@@ -196,7 +196,7 @@ print("my consecutive cell")
|
|
|
196
196
|
# get the the source code via command line
|
|
197
197
|
result = subprocess.run(
|
|
198
198
|
"yes | lamin load"
|
|
199
|
-
f" https://lamin.ai/{ln.setup.settings.user.handle}/
|
|
199
|
+
f" https://lamin.ai/{ln.setup.settings.user.handle}/lamin-cli-unit-tests/transform/hlsFXswrJjtt0001",
|
|
200
200
|
shell=True,
|
|
201
201
|
capture_output=True,
|
|
202
202
|
)
|
|
@@ -187,7 +187,7 @@ if __name__ == "__main__":
|
|
|
187
187
|
# try to get the source code via command line
|
|
188
188
|
result = subprocess.run(
|
|
189
189
|
"yes | lamin load"
|
|
190
|
-
f" https://lamin.ai/{settings.user.handle}/
|
|
190
|
+
f" https://lamin.ai/{settings.user.handle}/lamin-cli-unit-tests/transform/m5uCHTTpJnjQ0000",
|
|
191
191
|
shell=True,
|
|
192
192
|
capture_output=True,
|
|
193
193
|
)
|
|
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
|
{lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/notebooks/with-title-and-initialized-consecutive.ipynb
RENAMED
|
File without changes
|
{lamin_cli-1.4.0 → lamin_cli-1.4.2}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|