deriva-ml 1.14.36__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.
@@ -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.36
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
@@ -2,7 +2,7 @@ deriva_ml/__init__.py,sha256=_aMdxGG4mRTcXodLZLNpXqH8v5uqMbqFUryE9KqNSB8,1158
2
2
  deriva_ml/bump_version.py,sha256=KpHmkpEztly2QHYL4dyaIGdEMyP4F0D89rawyh5EDTs,3982
3
3
  deriva_ml/demo_catalog.py,sha256=JjPAIac_hKPh5krEhGJydjXquRnivi7kQoR8W4Khp-s,14928
4
4
  deriva_ml/feature.py,sha256=6-aphkxdKjWa9oPSGFWxHcwAc_8hmWj-7I4M178YG5Y,8470
5
- deriva_ml/install_kernel.py,sha256=LHAdy7s-m2jIvzptMpxLdHHkHc62Tn16e9MUWSGIznA,1651
5
+ deriva_ml/install_kernel.py,sha256=Lzy7gYGOpPU4vtQGh-Buo2TFqPRXWeGOvCoINJzELZ0,2195
6
6
  deriva_ml/run_notebook.py,sha256=XPZPtGDLv0Ej6dcqIwA1dx_ya1Z9kzsP7um473WtLpU,6519
7
7
  deriva_ml/core/__init__.py,sha256=V_i90pc5PB1F4UdOO6DZWzpEFaZDTaPRU-EzKXQ19eI,787
8
8
  deriva_ml/core/base.py,sha256=uG7xyVk12fXXWipusRmaBGplxbdlnN9sIOGAEHWD8i8,61090
@@ -20,9 +20,9 @@ deriva_ml/dataset/history.py,sha256=FK5AYYz11p4E4FWMVg4r7UPWOD4eobrq3b3xMjWF59g,
20
20
  deriva_ml/dataset/upload.py,sha256=Ad5JDfGvkIvefE-plP8SN9pNAxHzYrBoid5isz_bnNs,16411
21
21
  deriva_ml/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  deriva_ml/execution/environment.py,sha256=B7nywqxFTRUWgyu8n7rFoKcVC9on422kjeFG2FPQfvg,9302
23
- deriva_ml/execution/execution.py,sha256=tXWkFLDoSre836x6MMkcmhtmr3zP5_VoSioQ72-XmvE,44298
23
+ deriva_ml/execution/execution.py,sha256=NJT4qzZvvBXAlh73NVM39VE-uinSVBu2mHtuZD35G1M,44591
24
24
  deriva_ml/execution/execution_configuration.py,sha256=Rw4VWkBCZN9yatvSKdTqEWTfu470lpcVKfHFR0uN0jI,6248
25
- deriva_ml/execution/workflow.py,sha256=AeCT4eYAnYvBIx-Ar-Cyg64YoPyIB8IJdg3lKkCiKCU,13390
25
+ deriva_ml/execution/workflow.py,sha256=-dX2Yyd9PWRO0Lcr-ji-e7KmlOShE795B5PvJKacz2Q,13293
26
26
  deriva_ml/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  deriva_ml/model/catalog.py,sha256=dzTBcRlqgEVkPY32AUax_iu75RgFiT4Pu5au7rmrv8k,14068
28
28
  deriva_ml/model/database.py,sha256=MlXQQFgFmGxZbRx-unRFoRttXwpJspV4v2AIgppttCU,14805
@@ -30,13 +30,13 @@ deriva_ml/model/sql_mapper.py,sha256=_0QsJEVSgSPtxrWKSgjfPZCQ1aMVcjR_Tk2OxLhWEvY
30
30
  deriva_ml/schema/__init__.py,sha256=yV-MfzCF3FA4OOz7mZwMM2q6-x1vgOJ057kUvikFF6E,130
31
31
  deriva_ml/schema/annotations.py,sha256=TuQ3vWFnK0160fRmtvsCkHx9qAcRa63MSyERB4x5a98,18197
32
32
  deriva_ml/schema/check_schema.py,sha256=6dadLYHPqRex6AYVClmsESI8WhC7-rb-XnGf2G298xw,3609
33
- deriva_ml/schema/create_schema.py,sha256=0ydJSZEg3C3-m8hWPN6k2MoUvm-RWxAlKFzVChxcx3I,12791
33
+ deriva_ml/schema/create_schema.py,sha256=IrnSfN0ufS3M31MD8M6ZWyfJidKllLPqDFBUDAIDPY0,12789
34
34
  deriva_ml/schema/deriva-ml-reference.json,sha256=AEOMIgwKO3dNMMWHb0lxaXyamvfAEbUPh8qw0aAtsUQ,242460
35
35
  deriva_ml/schema/policy.json,sha256=5ykB8nnZFl-oCHzlAwppCFKJHWJFIkYognUMVEanfY8,1826
36
36
  deriva_ml/schema/table_comments_utils.py,sha256=4flCqnZAaqg_uSZ9I18pNUWAZoLfmMCXbmI5uERY5vM,2007
37
- deriva_ml-1.14.36.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
- deriva_ml-1.14.36.dist-info/METADATA,sha256=SBoKT-S6Q7vm-F17PLTZmlCNmaBb9HGjLxTI7OF1ypQ,1122
39
- deriva_ml-1.14.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- deriva_ml-1.14.36.dist-info/entry_points.txt,sha256=XsHSbfp7S1cKMjHoPUdFIaFcp9lHXHS6CV1zb_MEXkg,463
41
- deriva_ml-1.14.36.dist-info/top_level.txt,sha256=I1Q1dkH96cRghdsFRVqwpa2M7IqJpR2QPUNNc5-Bnpw,10
42
- deriva_ml-1.14.36.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,,