lamin_cli 0.16.3__py2.py3-none-any.whl → 0.17.1__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__ = "0.16.3"
3
+ __version__ = "0.17.1"
lamin_cli/__main__.py CHANGED
@@ -96,7 +96,7 @@ def main():
96
96
 
97
97
 
98
98
  @main.command()
99
- @click.argument("user", type=str)
99
+ @click.argument("user", type=str, default=None, required=False)
100
100
  @click.option("--key", type=str, default=None, help="API key")
101
101
  def login(user: str, key: Optional[str]):
102
102
  """Log into LaminHub.
@@ -110,10 +110,26 @@ def login(user: str, key: Optional[str]):
110
110
  You'll find your API key in the top right corner under "Settings".
111
111
 
112
112
  After this, you can either use `lamin login myhandle` or `lamin login myemail@acme.com`
113
+
114
+ You can also use
115
+
116
+ ```
117
+ lamin login
118
+ ```
119
+
120
+ and type your beta API key in the terminal
113
121
  """
114
122
  from lamindb_setup._setup_user import login
115
123
 
116
- return login(user, key=key)
124
+ if user is None:
125
+ if "LAMIN_API_KEY" in os.environ:
126
+ api_key = os.environ["LAMIN_API_KEY"]
127
+ else:
128
+ api_key = input("Your API key: ")
129
+ else:
130
+ api_key = None
131
+
132
+ return login(user, key=key, api_key=api_key)
117
133
 
118
134
 
119
135
  # fmt: off
lamin_cli/_get.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
  from typing import Tuple
3
3
  from lamin_utils import logger
4
4
  import lamindb_setup as ln_setup
5
+ from pathlib import Path
5
6
 
6
7
 
7
8
  def decompose_url(url: str) -> Tuple[str, str, str]:
@@ -25,6 +26,7 @@ def get(url: str):
25
26
  ln_setup.settings.auto_connect = False
26
27
 
27
28
  import lamindb as ln
29
+ from lamindb._finish import script_to_notebook
28
30
 
29
31
  ln_setup.settings.auto_connect = auto_connect
30
32
  ln.connect(instance_slug)
@@ -32,12 +34,23 @@ def get(url: str):
32
34
 
33
35
  if entity == "transform":
34
36
  transform = ln.Transform.get(uid)
35
- filepath_cache = transform._source_code_artifact.cache()
36
37
  target_filename = transform.key
37
- if not target_filename.endswith(transform._source_code_artifact.suffix):
38
- target_filename += transform._source_code_artifact.suffix
39
- filepath_cache.rename(target_filename)
40
- logger.success(f"cached source code of transform {uid} as {target_filename}")
38
+ if transform._source_code_artifact_id is not None:
39
+ # backward compat
40
+ filepath_cache = transform._source_code_artifact.cache()
41
+ if not target_filename.endswith(transform._source_code_artifact.suffix):
42
+ target_filename += transform._source_code_artifact.suffix
43
+ filepath_cache.rename(target_filename)
44
+ elif transform.source_code is not None:
45
+ if transform.key.endswith(".ipynb"):
46
+ script_to_notebook(transform, target_filename)
47
+ else:
48
+ Path(target_filename).write_text(transform.source_code)
49
+ else:
50
+ raise ValueError("No source code available for this transform.")
51
+ logger.success(
52
+ f"downloaded source code of transform {uid} as {target_filename}"
53
+ )
41
54
  elif entity == "artifact":
42
55
  artifact = ln.Artifact.get(uid)
43
56
  cache_path = artifact.cache()
lamin_cli/_save.py CHANGED
@@ -90,13 +90,10 @@ def save_from_filepath_cli(
90
90
  " in Transform registry. Did you run ln.context.track()?"
91
91
  )
92
92
  return "not-tracked-in-transform-registry"
93
- # refactor this, save_context_core should not depend on transform_family
94
- transform_family = transform.versions
95
93
  else:
96
- # the corresponding transform family in the transform table
97
- transform_family = ln.Transform.filter(uid__startswith=stem_uid).all()
98
- # the specific version
99
- transform = transform_family.get(version=transform_version)
94
+ transform = ln.Transform.get(
95
+ uid__startswith=stem_uid, version=transform_version
96
+ )
100
97
  # latest run of this transform by user
101
98
  run = ln.Run.filter(transform=transform).order_by("-started_at").first()
102
99
  if run.created_by.id != ln_setup.settings.user.id:
@@ -110,6 +107,5 @@ def save_from_filepath_cli(
110
107
  run=run,
111
108
  transform=transform,
112
109
  filepath=filepath,
113
- transform_family=transform_family,
114
110
  from_cli=True,
115
111
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamin_cli
3
- Version: 0.16.3
3
+ Version: 0.17.1
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,10 @@
1
+ lamin_cli/__init__.py,sha256=9M1QA0UP8g1FbKx988qbUJ0qtITf8KdTWJKdDp8ObIs,41
2
+ lamin_cli/__main__.py,sha256=RS5pFYEznk3XmQyNAJYW36TnyrcJsFv9zr1_oWy3kdU,8255
3
+ lamin_cli/_cache.py,sha256=6LrrWNrdZzH_BrohQ2n24xLFhUQ5EFan1bnzqMX_mIg,812
4
+ lamin_cli/_get.py,sha256=wym5KQCsS02ttejFaVMlc2ZPK5SSnYNNbUqnj3nHSfg,2164
5
+ lamin_cli/_migration.py,sha256=dULOvbpJ4VBiXuxPAM8jFGnBkh7pQGqE5eP-UC6uxWc,1055
6
+ lamin_cli/_save.py,sha256=Wmio1l4QWpd2u_GIpmoeOukJujas2qtuB1BQfe7jyE4,4501
7
+ lamin_cli-0.17.1.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
8
+ lamin_cli-0.17.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
9
+ lamin_cli-0.17.1.dist-info/METADATA,sha256=5L5_bk2goWgdiVSdWgPVlE88bSsDz3SUNxBvxU22AFI,336
10
+ lamin_cli-0.17.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- lamin_cli/__init__.py,sha256=-VEBAkJGvngQDNsXIQb5tfZImdAMjJW8VcZ1T7rx834,41
2
- lamin_cli/__main__.py,sha256=7mUJe-6Vq8WNNR90t2j0Pa_XLMNaS9rdctj7OEfhum0,7898
3
- lamin_cli/_cache.py,sha256=6LrrWNrdZzH_BrohQ2n24xLFhUQ5EFan1bnzqMX_mIg,812
4
- lamin_cli/_get.py,sha256=MXcR9PTW0FzY3uIPa-50SLCrtuRElxgDB3Vkfo-TFT0,1616
5
- lamin_cli/_migration.py,sha256=dULOvbpJ4VBiXuxPAM8jFGnBkh7pQGqE5eP-UC6uxWc,1055
6
- lamin_cli/_save.py,sha256=H_QQzWE3fId0GtM4LiIdNcgi81Wafvjh_V9B30SweBk,4821
7
- lamin_cli-0.16.3.dist-info/entry_points.txt,sha256=Qms85i9cZPlu-U7RnVZhFsF7vJ9gaLZUFkCjcGcXTpg,49
8
- lamin_cli-0.16.3.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
9
- lamin_cli-0.16.3.dist-info/METADATA,sha256=TMhHC2h49W_lpMqFg4TOu2JvdOxY9N4u2gJvNuDeO9E,336
10
- lamin_cli-0.16.3.dist-info/RECORD,,