lamin_cli 1.4.1__tar.gz → 1.5.0__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.
Files changed (39) hide show
  1. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/PKG-INFO +1 -1
  2. lamin_cli-1.5.0/lamin_cli/__init__.py +3 -0
  3. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/__main__.py +9 -4
  4. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/_save.py +28 -4
  5. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_load.py +15 -0
  6. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_save_files.py +8 -2
  7. lamin_cli-1.4.1/lamin_cli/__init__.py +0 -3
  8. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/.github/workflows/build.yml +0 -0
  9. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/.github/workflows/doc-changes.yml +0 -0
  10. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/.gitignore +0 -0
  11. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/.pre-commit-config.yaml +0 -0
  12. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/LICENSE +0 -0
  13. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/README.md +0 -0
  14. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/_cache.py +0 -0
  15. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/_load.py +0 -0
  16. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/_migration.py +0 -0
  17. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/_settings.py +0 -0
  18. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/compute/__init__.py +0 -0
  19. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/lamin_cli/compute/modal.py +0 -0
  20. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/noxfile.py +0 -0
  21. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/pyproject.toml +0 -0
  22. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/conftest.py +0 -0
  23. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_cli.py +0 -0
  24. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_migrate.py +0 -0
  25. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_multi_process.py +0 -0
  26. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_parse_uid_from_code.py +0 -0
  27. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_save_notebooks.py +0 -0
  28. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_save_r_code.py +0 -0
  29. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/core/test_save_scripts.py +0 -0
  30. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/modal/test_modal.py +0 -0
  31. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/notebooks/not-initialized.ipynb +0 -0
  32. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
  33. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
  34. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/merely-import-lamindb.py +0 -0
  35. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/run-track-and-finish-sync-git.py +0 -0
  36. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/run-track-and-finish.py +0 -0
  37. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/run-track-with-params.py +0 -0
  38. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/run-track.R +0 -0
  39. {lamin_cli-1.4.1 → lamin_cli-1.5.0}/tests/scripts/run-track.qmd +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lamin_cli
3
- Version: 1.4.1
3
+ Version: 1.5.0
4
4
  Summary: Lamin CLI.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,3 @@
1
+ """Lamin CLI."""
2
+
3
+ __version__ = "1.5.0"
@@ -195,7 +195,7 @@ def connect(instance: str):
195
195
  from lamindb_setup import settings as settings_
196
196
 
197
197
  settings_.auto_connect = True
198
- return connect_(instance, _reload_lamindb=False)
198
+ return connect_(instance, _reload_lamindb=False, _write_settings=True)
199
199
 
200
200
 
201
201
  @main.command()
@@ -270,7 +270,7 @@ def load(entity: str, uid: str | None = None, key: str | None = None, with_env:
270
270
  # f"! please use: lamin connect {entity}"
271
271
  # )
272
272
  settings_.auto_connect = True
273
- return connect(entity, _reload_lamindb=False)
273
+ return connect(entity, _reload_lamindb=False, _write_settings=True)
274
274
  else:
275
275
  from lamin_cli._load import load as load_
276
276
 
@@ -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
- path, key=key, description=description, revises=revises
125
- ).save()
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
- ).save()
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)
@@ -21,6 +21,17 @@ def test_load_transform():
21
21
  import lamindb_setup as ln_setup
22
22
 
23
23
  print(ln_setup.settings.instance.slug)
24
+
25
+ # check via a renamed instance
26
+ result = subprocess.run(
27
+ "lamin load"
28
+ " 'https://lamin.ai/laminlabs/lamin-dev1072025/transform/EWKgIa9dJB0n'"
29
+ " --with-env",
30
+ shell=True,
31
+ capture_output=True,
32
+ )
33
+ assert result.returncode == 0
34
+
24
35
  result = subprocess.run(
25
36
  "lamin load"
26
37
  " 'https://lamin.ai/laminlabs/lamin-dev/transform/VFYCIuaw2GsX0000'"
@@ -39,6 +50,8 @@ def test_load_transform():
39
50
  assert path1.exists()
40
51
  assert path2.exists()
41
52
 
53
+ subprocess.run("lamin connect laminlabs/lamin-dev", shell=True)
54
+
42
55
  # below will fail because it will say "these files already exist"
43
56
  result = subprocess.run(
44
57
  "lamin load transform --uid VFYCIuaw2GsX --with-env",
@@ -77,6 +90,8 @@ def test_get_load_artifact():
77
90
  )
78
91
  assert result.returncode == 0
79
92
 
93
+ subprocess.run("lamin connect laminlabs/lamin-site-assets", shell=True)
94
+
80
95
  # partial uid
81
96
  result = subprocess.run(
82
97
  "lamin load artifact --uid e2G7k9EVul4JbfsEYA",
@@ -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",
@@ -1,3 +0,0 @@
1
- """Lamin CLI."""
2
-
3
- __version__ = "1.4.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes