deriva-ml 1.14.35__py3-none-any.whl → 1.14.37__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.
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Release helper: seed initial semver tag if none exists, otherwise bump with bump-my-version.
4
+
5
+ Usage:
6
+ python release.py [patch|minor|major]
7
+
8
+ Env vars:
9
+ START - initial version if no tag exists (default: 0.1.0)
10
+ PREFIX - tag prefix (default: v)
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import argparse
16
+ import os
17
+ import shutil
18
+ import subprocess
19
+ import sys
20
+ from typing import Sequence
21
+
22
+
23
+ def run(
24
+ cmd: Sequence[str], check: bool = True, capture: bool = False, quiet: bool = False
25
+ ) -> subprocess.CompletedProcess:
26
+ if not quiet:
27
+ print(f"$ {' '.join(cmd)}")
28
+ return subprocess.run(
29
+ cmd,
30
+ check=check,
31
+ capture_output=capture,
32
+ text=True,
33
+ )
34
+
35
+
36
+ def in_git_repo() -> bool:
37
+ try:
38
+ run(["git", "rev-parse", "--is-inside-work-tree"], capture=True)
39
+ return True
40
+ except subprocess.CalledProcessError:
41
+ return False
42
+
43
+
44
+ def has_commits() -> bool:
45
+ try:
46
+ run(["git", "log", "-1"], capture=True)
47
+ return True
48
+ except subprocess.CalledProcessError:
49
+ return False
50
+
51
+
52
+ def latest_semver_tag(prefix: str) -> str | None:
53
+ # Use git's matcher to keep parity with Bash: prefix + x.y.z
54
+ pattern = f"{prefix}[0-9]*.[0-9]*.[0-9]*"
55
+ try:
56
+ cp = run(["git", "describe", "--tags", "--abbrev=0", "--match", pattern], capture=True, quiet=True)
57
+ tag = cp.stdout.strip()
58
+ return tag or None
59
+ except subprocess.CalledProcessError:
60
+ return None
61
+
62
+
63
+ def seed_initial_tag(tag: str) -> None:
64
+ print(f"No existing semver tag found. Seeding initial tag: {tag}")
65
+ run(["git", "tag", tag, "-m", f"Initial release {tag}"])
66
+ # Push tags (ignore failure to keep parity with bash's simple flow)
67
+ run(["git", "push", "--tags"])
68
+
69
+
70
+ def require_tool(name: str) -> None:
71
+ if shutil.which(name) is None:
72
+ print(f"Error: required tool '{name}' not found on PATH.", file=sys.stderr)
73
+ sys.exit(1)
74
+
75
+
76
+ def main() -> int:
77
+ parser = argparse.ArgumentParser(
78
+ description="Set a new version tag for the current repository, and push to remote."
79
+ )
80
+ parser.add_argument(
81
+ "bump", nargs="?", default="patch", choices=["patch", "minor", "major"], help="Which semver part to bump."
82
+ )
83
+ args = parser.parse_args()
84
+
85
+ start = os.environ.get("START", "0.1.0")
86
+ prefix = os.environ.get("PREFIX", "v")
87
+
88
+ # Sanity checks
89
+ require_tool("git")
90
+ require_tool("uv")
91
+
92
+ if not in_git_repo():
93
+ print("Not a git repo.", file=sys.stderr)
94
+ return 1
95
+
96
+ # Ensure tags visible in shallow clones
97
+ try:
98
+ run(["git", "fetch", "--tags", "--quiet"], check=False)
99
+ except Exception:
100
+ pass # non-fatal
101
+
102
+ if not has_commits():
103
+ print("No commits found. Commit something before tagging.", file=sys.stderr)
104
+ return 1
105
+
106
+ # Find latest semver tag with prefix
107
+ tag = latest_semver_tag(prefix)
108
+
109
+ if not tag:
110
+ seed_initial_tag(f"{prefix}{start}")
111
+ print(f"Seeded {prefix}{start}. Done.")
112
+ return 0
113
+
114
+ print(f"Bumping version: {args.bump}")
115
+
116
+ # Bump using bump-my-version via uv
117
+ # Mirrors: uv run bump-my-version bump $BUMP --verbose
118
+ try:
119
+ run(["uv", "run", "bump-my-version", "bump", args.bump, "--verbose"])
120
+ except subprocess.CalledProcessError as e:
121
+ print(e.stdout or "", end="")
122
+ print(e.stderr or "", end="", file=sys.stderr)
123
+ return e.returncode
124
+
125
+ # Push commits and tags
126
+ print("Pushing changes to remote repository...")
127
+ run(["git", "push", "--follow-tags"])
128
+
129
+ # Retrieve new version tag
130
+ try:
131
+ cp = run(["git", "describe", "--tags", "--abbrev=0"], capture=True)
132
+ new_tag = cp.stdout.strip()
133
+ print(f"New version tag: {new_tag}")
134
+ except subprocess.CalledProcessError:
135
+ print("Warning: unable to determine new tag via git describe.", file=sys.stderr)
136
+
137
+ print("Release process complete!")
138
+ return 0
139
+
140
+
141
+ if __name__ == "__main__":
142
+ sys.exit(main())
@@ -360,6 +360,14 @@ class Execution:
360
360
  with Path(cfile).open("w", encoding="utf-8") as config_file:
361
361
  json.dump(self.configuration.model_dump(), config_file)
362
362
 
363
+ lock_file = Path(self.configuration.workflow.git_root) / "uv.lock"
364
+ if lock_file.exists():
365
+ _ = self.asset_file_path(
366
+ MLAsset.execution_metadata,
367
+ lock_file,
368
+ ExecMetadataType.execution_config.value,
369
+ )
370
+
363
371
  for parameter_file in self.configuration.parameters:
364
372
  self.asset_file_path(
365
373
  MLAsset.execution_asset,
@@ -896,9 +904,7 @@ class Execution:
896
904
  asset_path.write_bytes(file_name.read_bytes())
897
905
 
898
906
  # Persist the asset types into a file
899
- with Path(
900
- asset_type_path(self._working_dir, self.execution_rid, asset_table)
901
- ).open("a") as asset_type_file:
907
+ with Path(asset_type_path(self._working_dir, self.execution_rid, asset_table)).open("a") as asset_type_file:
902
908
  asset_type_file.write(json.dumps({file_name.name: asset_types}) + "\n")
903
909
 
904
910
  return AssetFilePath(
@@ -84,6 +84,7 @@ class Workflow(BaseModel):
84
84
  rid: RID | None = None
85
85
  checksum: str | None = None
86
86
  is_notebook: bool = False
87
+ git_root: Path | None = None
87
88
 
88
89
  _logger: logging.Logger = PrivateAttr(default=10)
89
90
 
@@ -125,6 +126,7 @@ class Workflow(BaseModel):
125
126
  if not self.url:
126
127
  path, self.is_notebook = Workflow._get_python_script()
127
128
  self.url, self.checksum = Workflow.get_url_and_checksum(path)
129
+ self.git_root = Workflow._get_git_root(path)
128
130
 
129
131
  self._logger = logging.getLogger("deriva_ml")
130
132
  return self
@@ -315,12 +317,9 @@ class Workflow(BaseModel):
315
317
  ]
316
318
  # Get the caller's filename, which is two up the stack from here.
317
319
  filename = Path(stack[-1])
318
- if not filename.exists() or Workflow._in_repl():
320
+ if not (filename.exists() or Workflow._in_repl()):
319
321
  # Being called from the command line interpreter.
320
322
  filename = Path.cwd() / Path("REPL")
321
- # Get the caller's filename, which is two up the stack from here.
322
- else:
323
- raise DerivaMLException("Looking for caller failed") # Stack is too shallow
324
323
  return filename, is_notebook
325
324
 
326
325
  @staticmethod
@@ -1,9 +1,13 @@
1
1
  # your_pkg/install_kernel.py
2
- import sys
3
2
  import re
3
+ import sys
4
+ from argparse import ArgumentParser
4
5
  from importlib import metadata
6
+ from pathlib import Path
7
+
5
8
  from ipykernel.kernelspec import install as install_kernel
6
9
 
10
+
7
11
  def _dist_name_for_this_package() -> str:
8
12
  """
9
13
  Try to resolve the distribution name that provides this package.
@@ -20,6 +24,7 @@ def _dist_name_for_this_package() -> str:
20
24
  dist_name = dists[0] if dists else metadata.metadata(top_pkg).get("Name", top_pkg)
21
25
  return dist_name
22
26
 
27
+
23
28
  def _normalize_kernel_name(name: str) -> str:
24
29
  """
25
30
  Jupyter kernel directory names should be simple: lowercase, [-a-z0-9_].
@@ -28,19 +33,40 @@ def _normalize_kernel_name(name: str) -> str:
28
33
  name = re.sub(r"[^a-z0-9._-]+", "-", name)
29
34
  return name
30
35
 
36
+
37
+ def _name_for_this_venv() -> str:
38
+ config_path = Path(sys.prefix) / "pyvenv.cfg"
39
+ with config_path.open() as f:
40
+ m = re.search("prompt *= *(?P<prompt>.*)", f.read())
41
+ return m["prompt"] if m else ""
42
+
43
+
31
44
  def main() -> None:
32
- dist_name = _dist_name_for_this_package() # e.g., "deriva-model-template"
33
- kernel_name = _normalize_kernel_name(dist_name) # e.g., "deriva-model-template"
45
+ parser = ArgumentParser()
46
+ parser.add_argument(
47
+ "--install-local",
48
+ action="store_true",
49
+ help="Create kernal in local venv directory instead of sys.prefix.",
50
+ )
51
+
52
+ dist_name = _name_for_this_venv() # e.g., "deriva-model-template"
53
+ kernel_name = _normalize_kernel_name(dist_name) # e.g., "deriva-model-template"
34
54
  display_name = f"Python ({dist_name})"
35
55
 
36
56
  # Install into the current environment's prefix (e.g., .venv/share/jupyter/kernels/..)
57
+ prefix_arg = {}
58
+ install_local = False
59
+ if install_local:
60
+ prefix_arg = {"prefix": sys.prefix}
61
+
37
62
  install_kernel(
38
- user=False, # write under sys.prefix (the active env)
63
+ user=False, # write under sys.prefix (the active env)
39
64
  kernel_name=kernel_name,
40
65
  display_name=display_name,
41
- prefix=sys.prefix,
66
+ **prefix_arg,
42
67
  )
43
68
  print(f"Installed Jupyter kernel '{kernel_name}' with display name '{display_name}' under {sys.prefix!s}")
44
69
 
70
+
45
71
  if __name__ == "__main__":
46
- main()
72
+ main()
@@ -298,7 +298,7 @@ def initialize_ml_schema(model: Model, schema_name: str = "deriva-ml"):
298
298
  },
299
299
  {
300
300
  "Name": "Runtime_Env",
301
- "Description": "Information about the execution environment",
301
+ "Description": "Information about the runtime environment",
302
302
  },
303
303
  {
304
304
  "Name": "Execution_Metadata",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deriva-ml
3
- Version: 1.14.35
3
+ Version: 1.14.37
4
4
  Summary: Utilities to simplify use of Dervia and Pandas to create reproducable ML pipelines
5
5
  Author-email: ISRD <isrd-dev@isi.edu>
6
6
  Requires-Python: >=3.10
@@ -1,7 +1,8 @@
1
1
  deriva_ml/__init__.py,sha256=_aMdxGG4mRTcXodLZLNpXqH8v5uqMbqFUryE9KqNSB8,1158
2
+ deriva_ml/bump_version.py,sha256=KpHmkpEztly2QHYL4dyaIGdEMyP4F0D89rawyh5EDTs,3982
2
3
  deriva_ml/demo_catalog.py,sha256=JjPAIac_hKPh5krEhGJydjXquRnivi7kQoR8W4Khp-s,14928
3
4
  deriva_ml/feature.py,sha256=6-aphkxdKjWa9oPSGFWxHcwAc_8hmWj-7I4M178YG5Y,8470
4
- deriva_ml/install_kernel.py,sha256=LHAdy7s-m2jIvzptMpxLdHHkHc62Tn16e9MUWSGIznA,1651
5
+ deriva_ml/install_kernel.py,sha256=Lzy7gYGOpPU4vtQGh-Buo2TFqPRXWeGOvCoINJzELZ0,2195
5
6
  deriva_ml/run_notebook.py,sha256=XPZPtGDLv0Ej6dcqIwA1dx_ya1Z9kzsP7um473WtLpU,6519
6
7
  deriva_ml/core/__init__.py,sha256=V_i90pc5PB1F4UdOO6DZWzpEFaZDTaPRU-EzKXQ19eI,787
7
8
  deriva_ml/core/base.py,sha256=uG7xyVk12fXXWipusRmaBGplxbdlnN9sIOGAEHWD8i8,61090
@@ -19,9 +20,9 @@ deriva_ml/dataset/history.py,sha256=FK5AYYz11p4E4FWMVg4r7UPWOD4eobrq3b3xMjWF59g,
19
20
  deriva_ml/dataset/upload.py,sha256=Ad5JDfGvkIvefE-plP8SN9pNAxHzYrBoid5isz_bnNs,16411
20
21
  deriva_ml/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
22
  deriva_ml/execution/environment.py,sha256=B7nywqxFTRUWgyu8n7rFoKcVC9on422kjeFG2FPQfvg,9302
22
- deriva_ml/execution/execution.py,sha256=tXWkFLDoSre836x6MMkcmhtmr3zP5_VoSioQ72-XmvE,44298
23
+ deriva_ml/execution/execution.py,sha256=NJT4qzZvvBXAlh73NVM39VE-uinSVBu2mHtuZD35G1M,44591
23
24
  deriva_ml/execution/execution_configuration.py,sha256=Rw4VWkBCZN9yatvSKdTqEWTfu470lpcVKfHFR0uN0jI,6248
24
- deriva_ml/execution/workflow.py,sha256=AeCT4eYAnYvBIx-Ar-Cyg64YoPyIB8IJdg3lKkCiKCU,13390
25
+ deriva_ml/execution/workflow.py,sha256=-dX2Yyd9PWRO0Lcr-ji-e7KmlOShE795B5PvJKacz2Q,13293
25
26
  deriva_ml/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
27
  deriva_ml/model/catalog.py,sha256=dzTBcRlqgEVkPY32AUax_iu75RgFiT4Pu5au7rmrv8k,14068
27
28
  deriva_ml/model/database.py,sha256=MlXQQFgFmGxZbRx-unRFoRttXwpJspV4v2AIgppttCU,14805
@@ -29,13 +30,13 @@ deriva_ml/model/sql_mapper.py,sha256=_0QsJEVSgSPtxrWKSgjfPZCQ1aMVcjR_Tk2OxLhWEvY
29
30
  deriva_ml/schema/__init__.py,sha256=yV-MfzCF3FA4OOz7mZwMM2q6-x1vgOJ057kUvikFF6E,130
30
31
  deriva_ml/schema/annotations.py,sha256=TuQ3vWFnK0160fRmtvsCkHx9qAcRa63MSyERB4x5a98,18197
31
32
  deriva_ml/schema/check_schema.py,sha256=6dadLYHPqRex6AYVClmsESI8WhC7-rb-XnGf2G298xw,3609
32
- deriva_ml/schema/create_schema.py,sha256=0ydJSZEg3C3-m8hWPN6k2MoUvm-RWxAlKFzVChxcx3I,12791
33
+ deriva_ml/schema/create_schema.py,sha256=IrnSfN0ufS3M31MD8M6ZWyfJidKllLPqDFBUDAIDPY0,12789
33
34
  deriva_ml/schema/deriva-ml-reference.json,sha256=AEOMIgwKO3dNMMWHb0lxaXyamvfAEbUPh8qw0aAtsUQ,242460
34
35
  deriva_ml/schema/policy.json,sha256=5ykB8nnZFl-oCHzlAwppCFKJHWJFIkYognUMVEanfY8,1826
35
36
  deriva_ml/schema/table_comments_utils.py,sha256=4flCqnZAaqg_uSZ9I18pNUWAZoLfmMCXbmI5uERY5vM,2007
36
- deriva_ml-1.14.35.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
37
- deriva_ml-1.14.35.dist-info/METADATA,sha256=ozEBGEehEvA6IHHD2u_vf8cupR-tJIvNdr9QDHjObV0,1122
38
- deriva_ml-1.14.35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
- deriva_ml-1.14.35.dist-info/entry_points.txt,sha256=Fg8f56jlXzbxzAqnIix7ntqZWmGdqmD11m1OOgiCXDM,420
40
- deriva_ml-1.14.35.dist-info/top_level.txt,sha256=I1Q1dkH96cRghdsFRVqwpa2M7IqJpR2QPUNNc5-Bnpw,10
41
- deriva_ml-1.14.35.dist-info/RECORD,,
37
+ deriva_ml-1.14.37.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
+ deriva_ml-1.14.37.dist-info/METADATA,sha256=E_BHOiZCxJcYC6UBwuanetObG6g4WJNyoHh-tedBYmk,1122
39
+ deriva_ml-1.14.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ deriva_ml-1.14.37.dist-info/entry_points.txt,sha256=XsHSbfp7S1cKMjHoPUdFIaFcp9lHXHS6CV1zb_MEXkg,463
41
+ deriva_ml-1.14.37.dist-info/top_level.txt,sha256=I1Q1dkH96cRghdsFRVqwpa2M7IqJpR2QPUNNc5-Bnpw,10
42
+ deriva_ml-1.14.37.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  [console_scripts]
2
+ bump-version = deriva_ml.bump_version:main
2
3
  deriva-ml-alter-annotation = deriva_ml.schema_setup.alter_annotation:main
3
4
  deriva-ml-check-catalog-schema = deriva_ml.schema.check_schema:main
4
5
  deriva-ml-create-schema = deriva_ml.schema_setup.create_schema:main