deriva-ml 1.13.3__py3-none-any.whl → 1.14.0__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.
deriva_ml/dataset.py CHANGED
@@ -21,7 +21,7 @@ import requests
21
21
  from tempfile import TemporaryDirectory
22
22
  from typing import Any, Callable, Optional, Iterable, Iterator, TYPE_CHECKING
23
23
 
24
-
24
+ from .history import iso_to_snap
25
25
  from deriva.core.ermrest_model import Table
26
26
  from deriva.core.utils.core_utils import tag as deriva_tags, format_exception
27
27
  import deriva.core.utils.hash_utils as hash_utils
@@ -168,6 +168,21 @@ class Dataset:
168
168
  ]
169
169
  )
170
170
 
171
+ def _set_version_snapshot(self):
172
+ dataset_version_path = (
173
+ self._model.catalog.getPathBuilder()
174
+ .schemas[self._ml_schema]
175
+ .tables["Dataset_Version"]
176
+ )
177
+ versions = dataset_version_path.entities().fetch()
178
+ dataset_version_path.update(
179
+ [
180
+ {"RID": h["RID"], "Snapshot": iso_to_snap(h["RCT"])}
181
+ for h in versions
182
+ if not h["Snapshot"]
183
+ ]
184
+ )
185
+
171
186
  def dataset_history(self, dataset_rid: RID) -> list[DatasetHistory]:
172
187
  """Return a list of DatasetHistory objects representing the dataset
173
188
 
@@ -8,10 +8,11 @@ import warnings
8
8
  from datetime import date
9
9
  from enum import Enum
10
10
  from pathlib import Path
11
- from typing import Any, Iterable, Optional, Annotated, Generator
11
+ from typing import Any, Iterable, Optional, Annotated, Generator, Iterator
12
12
 
13
13
  import deriva.core.ermrest_model as em
14
14
  import deriva.core.utils.hash_utils as hash_utils
15
+ import json
15
16
  from urllib.parse import urlparse
16
17
  from deriva.core.ermrest_model import builtin_types
17
18
  from pydantic import (
@@ -192,6 +193,24 @@ class FileSpec(BaseModel):
192
193
 
193
194
  return (create_spec(file, description) for file in list_all_files(path))
194
195
 
196
+ @staticmethod
197
+ def read_filespec(path: Path | str) -> Iterator[FileSpec]:
198
+ """Get FileSpecs from a JSON lines file.
199
+
200
+ Arguments:
201
+ path: Path to the .jsonl file (string or Path).
202
+
203
+ Yields:
204
+ A FileSpec object.
205
+ """
206
+ path = Path(path)
207
+ with path.open("r", encoding="utf-8") as f:
208
+ for line in f:
209
+ line = line.strip()
210
+ if not line:
211
+ continue
212
+ yield FileSpec(**json.loads(line))
213
+
195
214
 
196
215
  class VocabularyTerm(BaseModel):
197
216
  """An entry in a vocabulary table.
deriva_ml/history.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from datetime import datetime
2
+ from dateutil.parser import isoparse
2
3
  from deriva.core import urlquote
3
4
 
4
5
 
@@ -57,7 +58,7 @@ def datetime_epoch_us(dt):
57
58
 
58
59
 
59
60
  def iso_to_snap(iso_datetime):
60
- rmt = datetime.fromisoformat(iso_datetime)
61
+ rmt = isoparse(iso_datetime) # datetime.fromisoformat(iso_datetime)
61
62
  return urlb32_encode(datetime_epoch_us(rmt))
62
63
 
63
64
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deriva-ml
3
- Version: 1.13.3
3
+ Version: 1.14.0
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,17 +1,17 @@
1
1
  deriva_ml/__init__.py,sha256=GfneBq7xDphMqUQY96sW9ixRj74M3UTUCmD4KMIRSaM,1101
2
2
  deriva_ml/database_model.py,sha256=D5vY0HqsCzWzbQVuK5jsImeEfjgg9wMe6fjDz8ucZqc,14695
3
- deriva_ml/dataset.py,sha256=UmVX3CQxjvi3pVudnbdpAddE4MJz230QnepICAb5Rag,60136
3
+ deriva_ml/dataset.py,sha256=NVyIRzy33QHnYvi5fZoxEIuUf-F2bHDCdIb6Zzchdpk,60649
4
4
  deriva_ml/dataset_aux_classes.py,sha256=IyPAbZUoVWjnm4hcpLet2mkJvKHRGN__IEwcAIrH-u4,6597
5
5
  deriva_ml/dataset_bag.py,sha256=yS8oYVshfFtRDyhGPRqtbvxjyd3ZFF29lrB783OP4vM,11849
6
6
  deriva_ml/demo_catalog.py,sha256=NBBsnF955jGpsGTgYFjeBn2580MjRuzC1MqqdrkaHAU,12081
7
- deriva_ml/deriva_definitions.py,sha256=3rkl0TsOoVR3QdZdAHvR--Zgt1FvW1et3BEL-_bjLVM,10768
7
+ deriva_ml/deriva_definitions.py,sha256=LhreMYY_1a_MgpmmtG_ABVzK6psbfbiUcYf47KxNIGc,11309
8
8
  deriva_ml/deriva_ml_base.py,sha256=FQirlTQvOUs25G0WGxnlVj3uF3PQbMX96nNj9s9arTI,38565
9
9
  deriva_ml/deriva_model.py,sha256=yMuJ3C8-anl1qf7lFBkiswVMWcheI_TUV5G_GvlzVCk,13565
10
10
  deriva_ml/execution.py,sha256=qcxqkF0gxmPfwLQb-ooyagFawgO9sK4CQfzJOfBmMp4,38330
11
11
  deriva_ml/execution_configuration.py,sha256=7fiIbtzz9nmkxA9-GTiN6Ln2twfaOLivwJwGZb8gAL0,14163
12
12
  deriva_ml/execution_environment.py,sha256=bCRKrCELDbGQDo7_FKfw7e8iMzVjSRZK3baKkqH5-_0,3264
13
13
  deriva_ml/feature.py,sha256=07g0uSrhumdopJluWuWSRMrzagaikAOihqB09bzXBP4,5475
14
- deriva_ml/history.py,sha256=XRZ_mmxOnspUJAoC_XEH_DhSgfLLW8Kiub3CxpQPftw,2830
14
+ deriva_ml/history.py,sha256=qP1fSAYUrMHdssT_0u2hzfgwb3X8-ZhI89q6xnVxTvI,2893
15
15
  deriva_ml/run_notebook.py,sha256=vhmij4P1Va52MIj8hOc-WmjLRp3sTmK6p7LXCWrzejc,6308
16
16
  deriva_ml/test_functions.py,sha256=-eqLHjjCQCLBNAr1ofbZekNiCOfMISSACRxT_YHER8I,4396
17
17
  deriva_ml/test_notebook.ipynb,sha256=_5D6rkSGbmENPJZbDgfZ6-yt94BNEwxytVUDmG3RE3w,10166
@@ -23,9 +23,9 @@ deriva_ml/schema_setup/policy.json,sha256=5ykB8nnZFl-oCHzlAwppCFKJHWJFIkYognUMVE
23
23
  deriva_ml/schema_setup/table_comments_utils.py,sha256=-2_ubEpoH7ViLVb-ZfW9wZbQ26DTKNgjkCABMzGu4i4,2140
24
24
  deriva_ml/test-files/execution-parameters.json,sha256=1vBqXlaMa0cysonE20TweVDfTGRdSi9CUuAkW1xiYNo,36
25
25
  deriva_ml/test-files/notebook-parameters.json,sha256=7uEE2sLQSrSc9cEGQ_RKE7t5dwkEYv0qLo5mRbzo8Og,108
26
- deriva_ml-1.13.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
- deriva_ml-1.13.3.dist-info/METADATA,sha256=D4ar2arJ8tkT9-YTAWl-r_CsJJA42rb2RKqcD8tOkF8,999
28
- deriva_ml-1.13.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- deriva_ml-1.13.3.dist-info/entry_points.txt,sha256=cJnALMa6pjdk6RQCt4HFbKHqALpVa0k6wPeQDPedLJI,295
30
- deriva_ml-1.13.3.dist-info/top_level.txt,sha256=I1Q1dkH96cRghdsFRVqwpa2M7IqJpR2QPUNNc5-Bnpw,10
31
- deriva_ml-1.13.3.dist-info/RECORD,,
26
+ deriva_ml-1.14.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
+ deriva_ml-1.14.0.dist-info/METADATA,sha256=DAIaEfvbsypLwhnNYZoYFnKi3jNln1je4n5KR4fiwvY,999
28
+ deriva_ml-1.14.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ deriva_ml-1.14.0.dist-info/entry_points.txt,sha256=cJnALMa6pjdk6RQCt4HFbKHqALpVa0k6wPeQDPedLJI,295
30
+ deriva_ml-1.14.0.dist-info/top_level.txt,sha256=I1Q1dkH96cRghdsFRVqwpa2M7IqJpR2QPUNNc5-Bnpw,10
31
+ deriva_ml-1.14.0.dist-info/RECORD,,