lamin_cli 0.17.3__tar.gz → 0.17.5__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-0.17.3 → lamin_cli-0.17.5}/PKG-INFO +1 -1
- lamin_cli-0.17.5/lamin_cli/__init__.py +3 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/lamin_cli/__main__.py +6 -9
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/lamin_cli/_save.py +18 -10
- lamin_cli-0.17.5/tests/test_save_files.py +60 -0
- lamin_cli-0.17.3/lamin_cli/__init__.py +0 -3
- lamin_cli-0.17.3/tests/test_save_files.py +0 -33
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/.github/workflows/doc-changes.yml +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/.gitignore +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/.pre-commit-config.yaml +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/LICENSE +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/README.md +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/lamin_cli/_cache.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/lamin_cli/_get.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/lamin_cli/_migration.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/pyproject.toml +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/conftest.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/notebooks/not-initialized.ipynb +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/scripts/merely-import-lamindb.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/scripts/run-track-and-finish-sync-git.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/scripts/run-track-and-finish.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_cli.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_get.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_migrate.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_multi_process.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_save_notebooks.py +0 -0
- {lamin_cli-0.17.3 → lamin_cli-0.17.5}/tests/test_save_scripts.py +0 -0
|
@@ -152,14 +152,10 @@ def init(storage: str, db: Optional[str], schema: Optional[str], name: Optional[
|
|
|
152
152
|
|
|
153
153
|
# fmt: off
|
|
154
154
|
@main.command()
|
|
155
|
-
@click.argument("instance", type=str, default=None)
|
|
156
|
-
@click.option("--db", type=str, default=None, help="Update database URL.") # noqa: E501
|
|
157
|
-
@click.option("--storage", type=str, default=None, help="Update storage while loading.")
|
|
155
|
+
@click.argument("instance", type=str, default=None, required=False)
|
|
158
156
|
@click.option("--unload", is_flag=True, help="Unload the current instance.")
|
|
159
157
|
# fmt: on
|
|
160
|
-
def load(
|
|
161
|
-
instance: Optional[str], db: Optional[str], storage: Optional[str], unload: bool
|
|
162
|
-
):
|
|
158
|
+
def load(instance: Optional[str], unload: bool):
|
|
163
159
|
"""Load an instance for auto-connection.
|
|
164
160
|
|
|
165
161
|
Pass a slug (`account/name`) or URL
|
|
@@ -175,7 +171,7 @@ def load(
|
|
|
175
171
|
from lamindb_setup import settings, connect
|
|
176
172
|
|
|
177
173
|
settings.auto_connect = True
|
|
178
|
-
return connect(slug=instance
|
|
174
|
+
return connect(slug=instance)
|
|
179
175
|
|
|
180
176
|
|
|
181
177
|
@main.command()
|
|
@@ -237,11 +233,12 @@ def get(entity: str, uid: str = None, key: str = None, with_env: bool = False):
|
|
|
237
233
|
)
|
|
238
234
|
@click.option("--key", type=str, default=None)
|
|
239
235
|
@click.option("--description", type=str, default=None)
|
|
240
|
-
|
|
236
|
+
@click.option("--registry", type=str, default=None)
|
|
237
|
+
def save(filepath: str, key: str, description: str, registry: str):
|
|
241
238
|
"""Save file or folder."""
|
|
242
239
|
from lamin_cli._save import save_from_filepath_cli
|
|
243
240
|
|
|
244
|
-
if save_from_filepath_cli(filepath, key, description) is not None:
|
|
241
|
+
if save_from_filepath_cli(filepath, key, description, registry) is not None:
|
|
245
242
|
sys.exit(1)
|
|
246
243
|
|
|
247
244
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Union
|
|
4
4
|
import lamindb_setup as ln_setup
|
|
5
5
|
from lamin_utils import logger
|
|
6
6
|
import re
|
|
@@ -50,8 +50,11 @@ def get_stem_uid_and_version_from_file(
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def save_from_filepath_cli(
|
|
53
|
-
filepath: Union[str, Path],
|
|
54
|
-
|
|
53
|
+
filepath: Union[str, Path],
|
|
54
|
+
key: str | None,
|
|
55
|
+
description: str | None,
|
|
56
|
+
registry: str | None,
|
|
57
|
+
) -> str | None:
|
|
55
58
|
if not isinstance(filepath, Path):
|
|
56
59
|
filepath = Path(filepath)
|
|
57
60
|
|
|
@@ -65,21 +68,24 @@ def save_from_filepath_cli(
|
|
|
65
68
|
|
|
66
69
|
ln_setup.settings.auto_connect = auto_connect_state
|
|
67
70
|
|
|
68
|
-
if
|
|
71
|
+
if registry is None:
|
|
72
|
+
registry = "transform" if filepath.suffix in {".py", ".ipynb"} else "artifact"
|
|
73
|
+
|
|
74
|
+
if registry == "artifact":
|
|
75
|
+
ln.settings.creation.artifact_silence_missing_run_warning = True
|
|
69
76
|
if key is None and description is None:
|
|
70
77
|
logger.error("Please pass a key or description via --key or --description")
|
|
71
78
|
return "missing-key-or-description"
|
|
72
|
-
artifact = ln.Artifact(filepath, key=key, description=description)
|
|
73
|
-
artifact.save()
|
|
74
|
-
slug = ln_setup.settings.instance.slug
|
|
79
|
+
artifact = ln.Artifact(filepath, key=key, description=description).save()
|
|
75
80
|
logger.important(f"saved: {artifact}")
|
|
76
81
|
logger.important(f"storage path: {artifact.path}")
|
|
77
|
-
if ln_setup.settings.instance.is_remote:
|
|
78
|
-
logger.important(f"go to: https://lamin.ai/{slug}/artifact/{artifact.uid}")
|
|
79
82
|
if ln_setup.settings.storage.type == "s3":
|
|
80
83
|
logger.important(f"storage url: {artifact.path.to_url()}")
|
|
84
|
+
if ln_setup.settings.instance.is_remote:
|
|
85
|
+
slug = ln_setup.settings.instance.slug
|
|
86
|
+
logger.important(f"go to: https://lamin.ai/{slug}/artifact/{artifact.uid}")
|
|
81
87
|
return None
|
|
82
|
-
|
|
88
|
+
elif registry == "transform":
|
|
83
89
|
# consider notebooks & scripts a transform
|
|
84
90
|
uid, stem_uid, transform_version = get_stem_uid_and_version_from_file(filepath)
|
|
85
91
|
if uid is not None:
|
|
@@ -109,3 +115,5 @@ def save_from_filepath_cli(
|
|
|
109
115
|
filepath=filepath,
|
|
110
116
|
from_cli=True,
|
|
111
117
|
)
|
|
118
|
+
else:
|
|
119
|
+
raise SystemExit("Allowed values for '--registry' are: 'artifact', 'transform'")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
test_file = Path(__file__).parent.parent.resolve() / ".gitignore"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_save_file():
|
|
8
|
+
filepath = test_file
|
|
9
|
+
|
|
10
|
+
# neither key nor description
|
|
11
|
+
result = subprocess.run(
|
|
12
|
+
f"lamin save {filepath}",
|
|
13
|
+
shell=True,
|
|
14
|
+
capture_output=True,
|
|
15
|
+
)
|
|
16
|
+
print(result.stdout.decode())
|
|
17
|
+
print(result.stderr.decode())
|
|
18
|
+
assert (
|
|
19
|
+
"Please pass a key or description via --key or --description"
|
|
20
|
+
in result.stdout.decode()
|
|
21
|
+
)
|
|
22
|
+
assert result.returncode == 1
|
|
23
|
+
|
|
24
|
+
result = subprocess.run(
|
|
25
|
+
f"lamin save {filepath} --key mytest",
|
|
26
|
+
shell=True,
|
|
27
|
+
capture_output=True,
|
|
28
|
+
)
|
|
29
|
+
print(result.stdout.decode())
|
|
30
|
+
print(result.stderr.decode())
|
|
31
|
+
assert "key='mytest'" in result.stdout.decode()
|
|
32
|
+
assert "storage path:" in result.stdout.decode()
|
|
33
|
+
assert result.returncode == 0
|
|
34
|
+
|
|
35
|
+
# test passing the registry and saving the same file
|
|
36
|
+
result = subprocess.run(
|
|
37
|
+
f"lamin save {filepath} --key mytest --registry artifact",
|
|
38
|
+
shell=True,
|
|
39
|
+
capture_output=True,
|
|
40
|
+
)
|
|
41
|
+
print(result.stdout.decode())
|
|
42
|
+
print(result.stderr.decode())
|
|
43
|
+
assert "returning existing artifact with same hash" in result.stdout.decode()
|
|
44
|
+
assert "key='mytest'" in result.stdout.decode()
|
|
45
|
+
assert "storage path:" in result.stdout.decode()
|
|
46
|
+
assert result.returncode == 0
|
|
47
|
+
|
|
48
|
+
# test invalid registry param
|
|
49
|
+
result = subprocess.run(
|
|
50
|
+
f"lamin save {filepath} --key mytest --registry invalid",
|
|
51
|
+
shell=True,
|
|
52
|
+
capture_output=True,
|
|
53
|
+
)
|
|
54
|
+
print(result.stdout.decode())
|
|
55
|
+
print(result.stderr.decode())
|
|
56
|
+
assert (
|
|
57
|
+
"Allowed values for '--registry' are: 'artifact', 'transform'"
|
|
58
|
+
in result.stderr.decode()
|
|
59
|
+
)
|
|
60
|
+
assert result.returncode == 1
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
test_file = Path(__file__).parent.parent.resolve() / ".gitignore"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_save_file():
|
|
8
|
-
filepath = test_file
|
|
9
|
-
|
|
10
|
-
# neither key nor description
|
|
11
|
-
result = subprocess.run(
|
|
12
|
-
f"lamin save {filepath}",
|
|
13
|
-
shell=True,
|
|
14
|
-
capture_output=True,
|
|
15
|
-
)
|
|
16
|
-
print(result.stdout.decode())
|
|
17
|
-
print(result.stderr.decode())
|
|
18
|
-
assert (
|
|
19
|
-
"Please pass a key or description via --key or --description"
|
|
20
|
-
in result.stdout.decode()
|
|
21
|
-
)
|
|
22
|
-
assert result.returncode == 1
|
|
23
|
-
|
|
24
|
-
result = subprocess.run(
|
|
25
|
-
f"lamin save {filepath} --key mytest",
|
|
26
|
-
shell=True,
|
|
27
|
-
capture_output=True,
|
|
28
|
-
)
|
|
29
|
-
print(result.stdout.decode())
|
|
30
|
-
print(result.stderr.decode())
|
|
31
|
-
assert "key='mytest'" in result.stdout.decode()
|
|
32
|
-
assert "storage path:" in result.stdout.decode()
|
|
33
|
-
assert result.returncode == 0
|
|
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-0.17.3 → lamin_cli-0.17.5}/tests/notebooks/with-title-and-initialized-consecutive.ipynb
RENAMED
|
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
|