lamin_cli 0.13.0__tar.gz → 0.13.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 (26) hide show
  1. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/PKG-INFO +1 -1
  2. lamin_cli-0.13.1/lamin_cli/__init__.py +3 -0
  3. lamin_cli-0.13.1/tests/scripts/run-track-and-finish.py +14 -0
  4. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_multi_process.py +1 -1
  5. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_save_notebooks.py +13 -11
  6. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_save_scripts.py +42 -2
  7. lamin_cli-0.13.0/lamin_cli/__init__.py +0 -3
  8. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/.gitignore +0 -0
  9. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/.pre-commit-config.yaml +0 -0
  10. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/README.md +0 -0
  11. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/lamin_cli/__main__.py +0 -0
  12. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/lamin_cli/_cache.py +0 -0
  13. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/lamin_cli/_get.py +0 -0
  14. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/lamin_cli/_migration.py +0 -0
  15. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/lamin_cli/_save.py +0 -0
  16. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/pyproject.toml +0 -0
  17. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/conftest.py +0 -0
  18. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/notebooks/not-initialized.ipynb +0 -0
  19. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/notebooks/with-title-and-initialized-consecutive.ipynb +0 -0
  20. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/notebooks/with-title-and-initialized-non-consecutive.ipynb +0 -0
  21. /lamin_cli-0.13.0/tests/scripts/initialized-no-git-sync.py → /lamin_cli-0.13.1/tests/scripts/merely-import-lamindb.py +0 -0
  22. /lamin_cli-0.13.0/tests/scripts/initialized.py → /lamin_cli-0.13.1/tests/scripts/run-track-and-finish-sync-git.py +0 -0
  23. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_cli.py +0 -0
  24. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_get.py +0 -0
  25. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_migrate.py +0 -0
  26. {lamin_cli-0.13.0 → lamin_cli-0.13.1}/tests/test_save_files.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lamin_cli
3
- Version: 0.13.0
3
+ Version: 0.13.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.13.1"
@@ -0,0 +1,14 @@
1
+ import lamindb as ln
2
+
3
+ ln.settings.transform.stem_uid = "VFYCIuaw2GsX"
4
+ ln.settings.transform.version = "1"
5
+
6
+ if __name__ == "__main__":
7
+ # we're using new_run here to mock the notebook situation
8
+ # and cover the look up of an existing run in the tests
9
+ # new_run = True is trivial
10
+ ln.track(new_run=False)
11
+
12
+ print("hello!")
13
+
14
+ ln.finish()
@@ -6,7 +6,7 @@ scripts_dir = Path(__file__).parent.resolve() / "scripts"
6
6
 
7
7
 
8
8
  def run_script():
9
- filepath = scripts_dir / "initialized-no-git-sync.py"
9
+ filepath = scripts_dir / "merely-import-lamindb.py"
10
10
  result = subprocess.run(
11
11
  f"python {filepath}",
12
12
  shell=True,
@@ -3,6 +3,7 @@ import subprocess
3
3
  from pathlib import Path
4
4
  import nbproject_test
5
5
  import pytest
6
+ from nbproject.dev import read_notebook, write_notebook
6
7
  from nbclient.exceptions import CellExecutionError
7
8
  import lamindb as ln
8
9
 
@@ -99,23 +100,26 @@ def test_save_consecutive():
99
100
  assert transform is not None
100
101
  assert transform.latest_report.path.exists()
101
102
  assert transform.latest_run.report.path == transform.latest_report.path
102
- print(transform.source_code.path.read_text())
103
103
  assert transform.source_code.hash == "5nc_HMjPvT9n26OWrjq6uQ"
104
104
  assert transform.latest_run.environment.path.exists()
105
105
  assert transform.source_code.path.exists()
106
106
 
107
- # now, assume the user modifies the notebook and saves
108
- # it without changing stem uid or version
109
- # outside of tests, this triggers a dialogue
110
- # within tests, it automatically overwrites the source
111
- from nbproject.dev import read_notebook, write_notebook
112
-
107
+ # now, assume the user modifies the notebook
113
108
  nb = read_notebook(notebook_path)
114
109
  # simulate editing the notebook (here, duplicate last cell)
115
110
  new_cell = nb.cells[-1].copy()
116
111
  new_cell["execution_count"] += 1
117
112
  nb.cells.append(new_cell)
118
113
  write_notebook(nb, notebook_path)
114
+
115
+ # try re-running - it fails
116
+ with pytest.raises(CellExecutionError) as error:
117
+ nbproject_test.execute_notebooks(notebook_path, print_outputs=True)
118
+ print(error.exconly())
119
+ assert "UpdateTransformSettings" in error.exconly()
120
+
121
+ # try re-saving - it works but will issue an interactive warning dialogue
122
+ # that clarifies that the user is about to re-save the notebook
119
123
  result = subprocess.run(
120
124
  f"lamin save {notebook_path}",
121
125
  shell=True,
@@ -124,10 +128,8 @@ def test_save_consecutive():
124
128
  )
125
129
  assert result.returncode == 0
126
130
  assert "saved transform" in result.stdout.decode()
127
-
128
- # now, the source code should be overwritten
129
- transform = ln.Transform.filter(uid="hlsFXswrJjtt5zKv").one_or_none()
130
- assert transform is not None
131
+ # the source code is overwritten with the edits, reflected in a new hash
132
+ transform = ln.Transform.get("hlsFXswrJjtt5zKv")
131
133
  assert transform.latest_report.path.exists()
132
134
  assert transform.latest_run.report.path == transform.latest_report.path
133
135
  assert transform.source_code.hash == "ocLybD0Hv_L3NhhXgTyQcw"
@@ -11,10 +11,9 @@ scripts_dir = Path(__file__).parent.resolve() / "scripts"
11
11
  def test_run_save_cache():
12
12
  env = os.environ
13
13
  env["LAMIN_TESTING"] = "true"
14
+ filepath = scripts_dir / "run-track-and-finish-sync-git.py"
14
15
 
15
- filepath = scripts_dir / "initialized.py"
16
16
  # attempt to save the script without it yet being run
17
- # lamin save sub/lamin-cli/tests/scripts/initialized.py
18
17
  result = subprocess.run(
19
18
  f"lamin save {filepath}",
20
19
  shell=True,
@@ -34,6 +33,7 @@ def test_run_save_cache():
34
33
  print(result.stderr.decode())
35
34
  assert result.returncode == 0
36
35
  assert "saved: Transform" in result.stdout.decode()
36
+ assert "m5uCHTTpJnjQ5zKv" in result.stdout.decode()
37
37
  assert "saved: Run" in result.stdout.decode()
38
38
 
39
39
  transform = ln.Transform.get("m5uCHTTpJnjQ")
@@ -51,6 +51,46 @@ def test_run_save_cache():
51
51
  print(result.stdout.decode())
52
52
  print(result.stderr.decode())
53
53
  assert result.returncode == 0
54
+ assert "loaded: Transform" in result.stdout.decode()
55
+ assert "m5uCHTTpJnjQ5zKv" in result.stdout.decode()
56
+ assert "loaded: Run" in result.stdout.decode()
57
+
58
+ # edit the script
59
+ content = filepath.read_text() + "\n # edited"
60
+ filepath.write_text(content)
61
+
62
+ # re-run the script
63
+ result = subprocess.run(
64
+ f"python {filepath}",
65
+ shell=True,
66
+ capture_output=True,
67
+ env=env,
68
+ )
69
+ print(result.stdout.decode())
70
+ print(result.stderr.decode())
71
+ assert result.returncode == 1
72
+ assert "Did not find blob hash" in result.stderr.decode()
73
+
74
+ # edit the script to remove the git integration
75
+ content = filepath.read_text()
76
+ content_lines = content.split("\n")
77
+ content_lines.remove(
78
+ 'ln.settings.sync_git_repo = "https://github.com/laminlabs/lamin-cli"'
79
+ )
80
+ content = "\n".join(content_lines)
81
+ filepath.write_text(content)
82
+
83
+ # re-run the script
84
+ result = subprocess.run(
85
+ f"python {filepath}",
86
+ shell=True,
87
+ capture_output=True,
88
+ env=env,
89
+ )
90
+ print(result.stdout.decode())
91
+ print(result.stderr.decode())
92
+ assert result.returncode == 1
93
+ assert "Please update your transform settings as follows" in result.stderr.decode()
54
94
 
55
95
  # try to get the the source code via command line
56
96
  result = subprocess.run(
@@ -1,3 +0,0 @@
1
- """Lamin CLI."""
2
-
3
- __version__ = "0.13.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes