lamin_cli 1.5.0__tar.gz → 1.5.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.
Files changed (40) hide show
  1. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/PKG-INFO +1 -1
  2. lamin_cli-1.5.2/lamin_cli/__init__.py +3 -0
  3. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/__main__.py +82 -8
  4. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/_load.py +3 -2
  5. lamin_cli-1.5.2/tests/core/test_create_switch_delete_list.py +29 -0
  6. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_save_scripts.py +4 -5
  7. lamin_cli-1.5.0/lamin_cli/__init__.py +0 -3
  8. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/.github/workflows/build.yml +0 -0
  9. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/.github/workflows/doc-changes.yml +0 -0
  10. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/.gitignore +0 -0
  11. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/.pre-commit-config.yaml +0 -0
  12. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/LICENSE +0 -0
  13. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/README.md +0 -0
  14. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/_cache.py +0 -0
  15. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/_migration.py +0 -0
  16. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/_save.py +0 -0
  17. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/_settings.py +0 -0
  18. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/compute/__init__.py +0 -0
  19. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/lamin_cli/compute/modal.py +0 -0
  20. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/noxfile.py +0 -0
  21. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/pyproject.toml +0 -0
  22. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/conftest.py +0 -0
  23. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_load.py +0 -0
  24. /lamin_cli-1.5.0/tests/core/test_cli.py → /lamin_cli-1.5.2/tests/core/test_login.py +0 -0
  25. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_migrate.py +0 -0
  26. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_multi_process.py +0 -0
  27. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_parse_uid_from_code.py +0 -0
  28. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_save_files.py +0 -0
  29. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_save_notebooks.py +0 -0
  30. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/core/test_save_r_code.py +0 -0
  31. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/modal/test_modal.py +0 -0
  32. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/notebooks/not-initialized.ipynb +0 -0
  33. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
  34. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
  35. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/scripts/merely-import-lamindb.py +0 -0
  36. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/scripts/run-track-and-finish-sync-git.py +0 -0
  37. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/scripts/run-track-and-finish.py +0 -0
  38. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/scripts/run-track-with-params.py +0 -0
  39. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/tests/scripts/run-track.R +0 -0
  40. {lamin_cli-1.5.0 → lamin_cli-1.5.2}/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.5.0
3
+ Version: 1.5.2
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.2"
@@ -9,8 +9,9 @@ from collections import OrderedDict
9
9
  from functools import wraps
10
10
  from importlib.metadata import PackageNotFoundError, version
11
11
  from pathlib import Path
12
- from typing import TYPE_CHECKING
12
+ from typing import TYPE_CHECKING, Literal
13
13
 
14
+ from lamin_utils import logger
14
15
  from lamindb_setup._init_instance import (
15
16
  DOC_DB,
16
17
  DOC_INSTANCE_NAME,
@@ -54,11 +55,11 @@ else:
54
55
  },
55
56
  {
56
57
  "name": "Read & write data",
57
- "commands": ["load", "save", "get", "delete"],
58
+ "commands": ["load", "save", "get", "delete", "create", "list"],
58
59
  },
59
60
  {
60
61
  "name": "Configure",
61
- "commands": ["cache", "settings", "migrate"],
62
+ "commands": ["checkout", "switch", "cache", "settings", "migrate"],
62
63
  },
63
64
  {
64
65
  "name": "Auth",
@@ -209,6 +210,66 @@ def disconnect():
209
210
  return close_()
210
211
 
211
212
 
213
+ # fmt: off
214
+ @main.command()
215
+ @click.argument("entity", type=str)
216
+ @click.option("--name", type=str, default=None, help="A name.")
217
+ # fmt: on
218
+ def create(entity: Literal["branch"], name: str | None = None):
219
+ """Create a record for an entity.
220
+
221
+ Currently only supports creating a branch.
222
+
223
+ ```
224
+ lamin create branch --name my_branch
225
+ ```
226
+ """
227
+ assert entity == "branch", "Currently only supports creating a branch."
228
+
229
+ from lamindb.models import Branch
230
+
231
+ branch = Branch(name=name).save()
232
+ logger.important(f"created branch: {branch.name}")
233
+
234
+
235
+ # fmt: off
236
+ @main.command(name="list")
237
+ @click.argument("entity", type=str)
238
+ @click.option("--name", type=str, default=None, help="A name.")
239
+ # fmt: on
240
+ def list_(entity: Literal["branch"], name: str | None = None):
241
+ """List records for an entity.
242
+
243
+ ```
244
+ lamin list branch
245
+ lamin list space
246
+ ```
247
+ """
248
+ assert entity in {"branch", "space"}, "Currently only supports listing branches and spaces."
249
+
250
+ from lamindb.models import Branch, Space
251
+
252
+ if entity == "branch":
253
+ print(Branch.df())
254
+ else:
255
+ print(Space.df())
256
+
257
+
258
+ # fmt: off
259
+ @main.command()
260
+ @click.option("--branch", type=str, default=None, help="A valid branch name or uid.")
261
+ @click.option("--space", type=str, default=None, help="A valid branch name or uid.")
262
+ # fmt: on
263
+ def switch(branch: str | None = None, space: str | None = None):
264
+ """Switch between branches or spaces.
265
+
266
+ Currently only supports creating a branch.
267
+ """
268
+ from lamindb.setup import switch as switch_
269
+
270
+ switch_(branch=branch, space=space)
271
+
272
+
212
273
  @main.command()
213
274
  @click.option("--schema", is_flag=True, help="View database schema.")
214
275
  def info(schema: bool):
@@ -226,17 +287,30 @@ def info(schema: bool):
226
287
 
227
288
  # fmt: off
228
289
  @main.command()
229
- @click.argument("instance", type=str, default=None)
230
- @click.option("--force", is_flag=True, default=False, help="Do not ask for confirmation.")
290
+ @click.argument("entity", type=str)
291
+ @click.option("--name", type=str, default=None)
292
+ @click.option("--slug", type=str, default=None)
293
+ @click.option("--force", is_flag=True, default=False, help="Do not ask for confirmation (only relevant for instance).")
231
294
  # fmt: on
232
- def delete(instance: str, force: bool = False):
295
+ def delete(entity: str, name: str | None = None, slug: str | None = None, force: bool = False):
233
296
  """Delete an entity.
234
297
 
235
- Currently only supports instance deletion.
298
+ Currently supported: `branch` and `instance`.
299
+
300
+ ```
301
+ lamin delete instance --slug account/name
302
+ lamin delete branch --name my_branch
303
+ ```
236
304
  """
305
+ from lamindb import Branch
237
306
  from lamindb_setup._delete import delete
238
307
 
239
- return delete(instance, force=force)
308
+ if entity == "branch":
309
+ Branch.get(name=name).delete()
310
+ elif entity == "instance":
311
+ return delete(slug, force=force)
312
+ else: # backwars compatibility
313
+ return delete(entity, force=force)
240
314
 
241
315
 
242
316
  @main.command()
@@ -163,10 +163,11 @@ def load(
163
163
 
164
164
  # we don't use .get here because DoesNotExist is hard to catch
165
165
  # due to private django API
166
+ # we use `.objects` here because we don't want to exclude kind = __lamindb_run__ artifacts
166
167
  if query_by_uid:
167
- entities = EntityClass.filter(uid__startswith=uid)
168
+ entities = EntityClass.objects.filter(uid__startswith=uid)
168
169
  else:
169
- entities = EntityClass.filter(key=key)
170
+ entities = EntityClass.objects.filter(key=key)
170
171
 
171
172
  if (n_entities := len(entities)) == 0:
172
173
  err_msg = f"uid={uid}" if query_by_uid else f"key={key}"
@@ -0,0 +1,29 @@
1
+ import os
2
+
3
+ import lamindb as ln
4
+ import lamindb_setup as ln_setup
5
+
6
+
7
+ def test_branch():
8
+ exit_status = os.system("lamin switch --branch archive")
9
+ assert exit_status == 0
10
+ assert ln_setup.settings.branch.uid == 12 * "a"
11
+ exit_status = os.system("lamin switch --branch main")
12
+ assert exit_status == 0
13
+ assert ln_setup.settings.branch.uid == 12 * "m"
14
+ exit_status = os.system("lamin create branch --name testbranch")
15
+ exit_status = os.system("lamin switch --branch testbranch")
16
+ assert exit_status == 0
17
+ exit_status = os.system("lamin list branch")
18
+ assert exit_status == 0
19
+ exit_status = os.system("lamin delete branch --name testbranch")
20
+ assert exit_status == 0
21
+ exit_status = os.system("lamin switch --branch main")
22
+
23
+
24
+ def test_space():
25
+ exit_status = os.system("lamin switch --space non_existent")
26
+ assert exit_status == 256
27
+ exit_status = os.system("lamin switch --space all")
28
+ assert exit_status == 0
29
+ assert ln_setup.settings.space.uid == 12 * "a"
@@ -51,8 +51,8 @@ def test_run_save_cache_with_git_and_uid():
51
51
  shell=True,
52
52
  capture_output=True,
53
53
  )
54
- print(result.stdout.decode())
55
- print(result.stderr.decode())
54
+ # print(result.stdout.decode())
55
+ # print(result.stderr.decode())
56
56
  assert result.returncode == 0
57
57
  assert "loaded Transform" in result.stdout.decode()
58
58
  assert "m5uCHTTp" in result.stdout.decode()
@@ -172,7 +172,7 @@ if __name__ == "__main__":
172
172
  capture_output=True,
173
173
  env=env,
174
174
  )
175
- # re-run the script through the second user
175
+ # re-run the script through a second user
176
176
  result = subprocess.run(
177
177
  f"python {filepath}",
178
178
  shell=True,
@@ -181,8 +181,7 @@ if __name__ == "__main__":
181
181
  )
182
182
  # print(result.stdout.decode())
183
183
  # print(result.stderr.decode())
184
- assert result.returncode == 1
185
- assert "already works on this draft" in result.stderr.decode()
184
+ assert result.returncode == 0
186
185
 
187
186
  # try to get the source code via command line
188
187
  result = subprocess.run(
@@ -1,3 +0,0 @@
1
- """Lamin CLI."""
2
-
3
- __version__ = "1.5.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes