lamin_cli 1.4.1__py2.py3-none-any.whl → 1.4.2__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 CHANGED
@@ -1,3 +1,3 @@
1
1
  """Lamin CLI."""
2
2
 
3
- __version__ = "1.4.1"
3
+ __version__ = "1.4.2"
lamin_cli/__main__.py CHANGED
@@ -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
 
lamin_cli/_save.py CHANGED
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lamin_cli
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: Lamin CLI.
5
5
  Author-email: Lamin Labs <open-source@lamin.ai>
6
6
  Description-Content-Type: text/markdown
@@ -1,14 +1,14 @@
1
- lamin_cli/__init__.py,sha256=4_vIM7YadBIkILkcPZp7oQ7MWMPbKniL-MvG9Pp3UYE,40
2
- lamin_cli/__main__.py,sha256=1GdJbaTQQmy_xPu-6QWglewBVkXdlGe37PbzSWPKCBM,12813
1
+ lamin_cli/__init__.py,sha256=a2cxUd26lWX3nVDezWjl4gCzUH4M4on-qIOC0gNE59s,40
2
+ lamin_cli/__main__.py,sha256=dlECexOeCvCm0nlW-B69wVD0bZzaJ3rWex6egfxV1i4,13357
3
3
  lamin_cli/_cache.py,sha256=oplwE8AcS_9PYptQUZxff2qTIdNFS81clGPkJNWk098,800
4
4
  lamin_cli/_load.py,sha256=ow9IPQog_mPvjoGj1Bn08l4AG1YyRNnEyBpQvQkfLZs,8182
5
5
  lamin_cli/_migration.py,sha256=xQi6mwnpBzY5wcv1-TJhveD7a3XJIlpiYx6Z3AJ1NF0,1063
6
- lamin_cli/_save.py,sha256=LvxEIXKgUPvpwhjgRyxi1MTDRcL6rlAMbMQLfPtfDhs,9047
6
+ lamin_cli/_save.py,sha256=wdTMmALkkNUpleUfXkNbh2Ila_pUIi5vhVbr30wLhEA,10069
7
7
  lamin_cli/_settings.py,sha256=O2tecCf5EIZu98ima4DTJujo4KuywckOLgw8c-Ke3dY,1142
8
8
  lamin_cli/compute/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  lamin_cli/compute/modal.py,sha256=QnR7GyyvWWWkLnou95HxS9xxSQfw1k-SiefM_qRVnU0,6010
10
- lamin_cli-1.4.1.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
11
- lamin_cli-1.4.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- lamin_cli-1.4.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
13
- lamin_cli-1.4.1.dist-info/METADATA,sha256=dsWrH1faO8QjfAYKW7bNArDHztc7UL7ptaE6p5_NTaw,337
14
- lamin_cli-1.4.1.dist-info/RECORD,,
10
+ lamin_cli-1.4.2.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
11
+ lamin_cli-1.4.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ lamin_cli-1.4.2.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
13
+ lamin_cli-1.4.2.dist-info/METADATA,sha256=sCS5vIk9ZwaAbmQ4nShVxCTKu5udT7gIw7ASXW8Ry34,337
14
+ lamin_cli-1.4.2.dist-info/RECORD,,