lamin_cli 0.17.0__tar.gz → 0.17.1__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 (28) hide show
  1. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/PKG-INFO +1 -1
  2. lamin_cli-0.17.1/lamin_cli/__init__.py +3 -0
  3. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/lamin_cli/__main__.py +18 -2
  4. lamin_cli-0.17.1/tests/test_cli.py +42 -0
  5. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_save_notebooks.py +27 -20
  6. lamin_cli-0.17.0/lamin_cli/__init__.py +0 -3
  7. lamin_cli-0.17.0/tests/test_cli.py +0 -16
  8. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/.github/workflows/doc-changes.yml +0 -0
  9. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/.gitignore +0 -0
  10. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/.pre-commit-config.yaml +0 -0
  11. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/README.md +0 -0
  12. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/lamin_cli/_cache.py +0 -0
  13. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/lamin_cli/_get.py +0 -0
  14. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/lamin_cli/_migration.py +0 -0
  15. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/lamin_cli/_save.py +0 -0
  16. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/pyproject.toml +0 -0
  17. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/conftest.py +0 -0
  18. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/notebooks/not-initialized.ipynb +0 -0
  19. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
  20. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
  21. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/scripts/merely-import-lamindb.py +0 -0
  22. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/scripts/run-track-and-finish-sync-git.py +0 -0
  23. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/scripts/run-track-and-finish.py +0 -0
  24. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_get.py +0 -0
  25. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_migrate.py +0 -0
  26. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_multi_process.py +0 -0
  27. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_save_files.py +0 -0
  28. {lamin_cli-0.17.0 → lamin_cli-0.17.1}/tests/test_save_scripts.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamin_cli
3
- Version: 0.17.0
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,3 @@
1
+ """Lamin CLI."""
2
+
3
+ __version__ = "0.17.1"
@@ -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
@@ -0,0 +1,42 @@
1
+ import os
2
+ from datetime import datetime, timedelta, timezone
3
+ from lamindb_setup.core._hub_client import connect_hub_with_auth
4
+ from lamindb_setup.core._hub_core import create_api_key
5
+
6
+
7
+ def test_entrypoint():
8
+ exit_status = os.system("lamin --help")
9
+ assert exit_status == 0
10
+
11
+
12
+ def test_cli_login():
13
+ exit_status = os.system("lamin login testuser1")
14
+ assert exit_status == 0
15
+
16
+ exit_status = os.system(
17
+ "lamin login testuser1 --key cEvcwMJFX4OwbsYVaMt2Os6GxxGgDUlBGILs2RyS"
18
+ )
19
+ assert exit_status == 0
20
+
21
+
22
+ def test_cli_login_api_key():
23
+ expires_at = datetime.now(tz=timezone.utc) + timedelta(days=1)
24
+ api_key = create_api_key(
25
+ {
26
+ "expires_at": expires_at.strftime("%Y-%m-%d"),
27
+ "description": "test_cli_login_api_key",
28
+ }
29
+ )
30
+
31
+ exit_status = os.system(f"echo {api_key} | lamin login")
32
+ assert exit_status == 0
33
+
34
+ os.environ["LAMIN_API_KEY"] = api_key
35
+ exit_status = os.system("lamin login")
36
+ assert exit_status == 0
37
+
38
+ hub = connect_hub_with_auth()
39
+ hub.table("api_key").delete().eq("description", "test_cli_login_api_key").execute()
40
+ hub.auth.sign_out({"scope": "local"})
41
+
42
+ os.system("lamin login testuser1@lamin.ai")
@@ -40,20 +40,22 @@ def test_save_non_consecutive():
40
40
  version="1",
41
41
  name="My test notebook (non-consecutive)",
42
42
  type="notebook",
43
- )
44
- transform.save()
45
- run = ln.Run(transform=transform)
46
- run.save()
47
- result = subprocess.run(
48
- f"lamin save {notebook_path}", # noqa
43
+ ).save()
44
+ ln.Run(transform=transform).save()
45
+
46
+ process = subprocess.Popen(
47
+ f"lamin save {notebook_path}",
49
48
  shell=True,
50
- capture_output=True,
51
49
  env=env,
50
+ stdin=subprocess.PIPE,
51
+ stdout=subprocess.PIPE,
52
+ stderr=subprocess.PIPE,
53
+ text=True,
52
54
  )
53
- print(result.stdout.decode())
54
- print(result.stderr.decode())
55
- assert result.returncode == 1
56
- assert "were not run consecutively" in result.stdout.decode()
55
+ stdout, stderr = process.communicate("n")
56
+ assert "were not run consecutively" in stdout
57
+ assert "Do you still want to proceed with finishing?" in stdout
58
+ assert process.returncode == 1
57
59
 
58
60
 
59
61
  def test_save_consecutive():
@@ -134,29 +136,34 @@ print("my consecutive cell")
134
136
  assert transform.latest_run.environment.path.exists()
135
137
  assert transform._source_code_artifact is None
136
138
 
137
- # now, assume the user modifies the notebook
139
+ # edit the notebook
138
140
  nb = read_notebook(notebook_path)
139
- # simulate editing the notebook (here, duplicate last cell)
140
141
  new_cell = nb.cells[-1].copy()
141
142
  new_cell["execution_count"] += 1
142
- nb.cells.append(new_cell)
143
+ nb.cells.append(new_cell) # duplicate last cell
143
144
  write_notebook(nb, notebook_path)
144
145
 
145
- # try re-running - it fails
146
+ # attempt re-running - it fails
146
147
  with pytest.raises(CellExecutionError) as error:
147
148
  nbproject_test.execute_notebooks(notebook_path, print_outputs=True)
148
149
  # print(error.exconly())
149
150
  assert "UpdateContext" in error.exconly()
150
151
 
151
- # try re-saving - it works but will issue an interactive warning dialogue
152
- # that clarifies that the user is about to re-save the notebook
153
- result = subprocess.run(
152
+ # attempt re-saving - it works but the user needs to confirm overwriting
153
+ # source code and run report
154
+ process = subprocess.Popen(
154
155
  f"lamin save {notebook_path}",
155
156
  shell=True,
156
- capture_output=True,
157
157
  env=env,
158
+ stdin=subprocess.PIPE,
159
+ stdout=subprocess.PIPE,
160
+ stderr=subprocess.PIPE,
161
+ text=True,
158
162
  )
159
- assert result.returncode == 0
163
+ stdout, stderr = process.communicate("y\ny")
164
+ assert "You are about to overwrite existing source code" in stdout
165
+ assert "You are about to overwrite an existing report" in stdout
166
+ assert process.returncode == 0
160
167
  # the source code is overwritten with the edits, reflected in a new hash
161
168
  transform = ln.Transform.get("hlsFXswrJjtt0000")
162
169
  assert transform.latest_run.report.path.exists()
@@ -1,3 +0,0 @@
1
- """Lamin CLI."""
2
-
3
- __version__ = "0.17.0"
@@ -1,16 +0,0 @@
1
- import os
2
-
3
-
4
- def test_entrypoint():
5
- exit_status = os.system("lamin --help")
6
- assert exit_status == 0
7
-
8
-
9
- def test_login():
10
- exit_status = os.system("lamin login testuser1")
11
- assert exit_status == 0
12
-
13
- exit_status = os.system(
14
- "lamin login testuser1 --key cEvcwMJFX4OwbsYVaMt2Os6GxxGgDUlBGILs2RyS"
15
- )
16
- assert exit_status == 0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes