lamin_cli 1.5.0__py2.py3-none-any.whl → 1.5.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 +1 -1
- lamin_cli/__main__.py +82 -8
- lamin_cli/_load.py +3 -2
- {lamin_cli-1.5.0.dist-info → lamin_cli-1.5.2.dist-info}/METADATA +1 -1
- {lamin_cli-1.5.0.dist-info → lamin_cli-1.5.2.dist-info}/RECORD +8 -8
- {lamin_cli-1.5.0.dist-info → lamin_cli-1.5.2.dist-info}/LICENSE +0 -0
- {lamin_cli-1.5.0.dist-info → lamin_cli-1.5.2.dist-info}/WHEEL +0 -0
- {lamin_cli-1.5.0.dist-info → lamin_cli-1.5.2.dist-info}/entry_points.txt +0 -0
lamin_cli/__init__.py
CHANGED
lamin_cli/__main__.py
CHANGED
|
@@ -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("
|
|
230
|
-
@click.option("--
|
|
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(
|
|
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
|
|
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
|
-
|
|
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()
|
lamin_cli/_load.py
CHANGED
|
@@ -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}"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
lamin_cli/__init__.py,sha256=
|
|
2
|
-
lamin_cli/__main__.py,sha256=
|
|
1
|
+
lamin_cli/__init__.py,sha256=8S1h5xBXifK8y1USGZGBHskI7LFAjrYeMRmTQMXgAqU,40
|
|
2
|
+
lamin_cli/__main__.py,sha256=1hYODyzurDvq198STsIZ2slp_t_xq_c7QS0oyts33PA,15528
|
|
3
3
|
lamin_cli/_cache.py,sha256=oplwE8AcS_9PYptQUZxff2qTIdNFS81clGPkJNWk098,800
|
|
4
|
-
lamin_cli/_load.py,sha256=
|
|
4
|
+
lamin_cli/_load.py,sha256=QqiFxGYmvFz2RjhvwKO5r1fmPWMZ5Ai4y1pJytdYKak,8301
|
|
5
5
|
lamin_cli/_migration.py,sha256=xQi6mwnpBzY5wcv1-TJhveD7a3XJIlpiYx6Z3AJ1NF0,1063
|
|
6
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.5.
|
|
11
|
-
lamin_cli-1.5.
|
|
12
|
-
lamin_cli-1.5.
|
|
13
|
-
lamin_cli-1.5.
|
|
14
|
-
lamin_cli-1.5.
|
|
10
|
+
lamin_cli-1.5.2.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
|
|
11
|
+
lamin_cli-1.5.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
lamin_cli-1.5.2.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
|
|
13
|
+
lamin_cli-1.5.2.dist-info/METADATA,sha256=etOomDY2o5Hw6h41jnObSNjubozaPdLn8d8dndiz2AE,337
|
|
14
|
+
lamin_cli-1.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|