Skip to content

Commit d0eddbe

Browse files
Support numpy and apply fixes along the way (#26)
# v2.4.0-rc.1 - allow numpy 2.x versions - extend support for python 3.13 - upgrade pint to 0.25 - upgrade pint-xarray up to 0.6.0 - upgrading to ontolutils 0.21.1 - fixing linting issues - RDF-subjects set for dataset and group are modelled with property schema:about to express that a dataset or group is described by the RDF subject. This is more in line with semantic web standards.
1 parent f73b7d9 commit d0eddbe

38 files changed

+400
-330
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
push:
77
branches:
88
- main
9-
- dev
9+
- develop
1010

1111
jobs:
1212
test:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
1616
os: [ ubuntu-latest, macos-latest, windows-latest ]
17-
python-version: [ '3.9', '3.12']
17+
python-version: [ '3.9', '3.10', '3.12', '3.13' ]
1818
mongodb-version: ['5.0', ]
1919

2020
steps:

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
Log of changes in the versions
44

5+
## v2.4.0-rc.1
6+
7+
- allow numpy 2.x versions
8+
- extend support for python 3.13
9+
- upgrade pint to 0.25
10+
- upgrade pint-xarray up to 0.6.0
11+
- upgrading to ontolutils 0.21.1
12+
- fixing linting issues
13+
- RDF-subjects set for dataset and group are modelled with property schema:about to express that a dataset or group is
14+
described by the RDF subject. This is more in line with semantic web standards.
15+
516
## v2.3.1
617

718
- fixing error in parsing obj name. "/" is safed and will not be converted anymore
819

9-
1020
## v2.3.0
1121

1222
- hotfix avoiding blank nodes for hdf filter

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors:
1111
given-names: "Lucas"
1212
orcid: "https://orcid.org/0000-0002-4116-0065"
1313
title: "h5rdmtoolbox - HDF5 Research Data Management Toolbox"
14-
version: 2.3.1
15-
doi: 10.5281/zenodo.17063344
16-
date-released: 2025-09-01
14+
version: 2.4.0-rc.1
15+
doi: 10.5281/zenodo.17088483
16+
date-released: 2025-10-12
1717
url: "https://github.com/matthiasprobst/h5rdmtoolbox"

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![Tests](https://github.com/matthiasprobst/h5RDMtoolbox/actions/workflows/tests.yml/badge.svg)
44
[![codecov](https://codecov.io/gh/matthiasprobst/h5RDMtoolbox/graph/badge.svg?token=IVG4AQEW47)](https://codecov.io/gh/matthiasprobst/h5RDMtoolbox)
55
[![Documentation Status](https://readthedocs.org/projects/h5rdmtoolbox/badge/?version=latest)](https://h5rdmtoolbox.readthedocs.io/en/latest/?badge=latest)
6-
![pyvers](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
6+
![pyvers](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
77

88
*Note, that the project is still under development!*
99

@@ -99,6 +99,10 @@ package via pip:
9999

100100
pip install h5RDMtoolbox
101101

102+
or if you prefer `uv`:
103+
104+
uv install h5RDMtoolbox
105+
102106
### Install from source:
103107

104108
Developers may clone the repository and install the package from source. Clone the repository first:
@@ -131,7 +135,7 @@ specific to the features of the package:
131135

132136
**Specific to the package are ...**
133137

134-
- `h5py=3.7.0`: HDF5 file interface
138+
- `h5py~=3.8`: HDF5 file interface
135139
- `xarray>=2022.3.0`: Working with scientific arrays in combination with attributes. Allows carrying metadata from HDF5
136140
to user
137141
- `pint>=0.19.2`: Allows working with units

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "https://spdx.org/licenses/MIT",
55
"codeRepository": "git+https://github.com/matthiasprobst/h5RDMtoolbox.git",
66
"name": "h5RDMtoolbox",
7-
"version": "2.3.1",
7+
"version": "2.4.0-rc.1",
88
"description": "Supporting a FAIR Research Data lifecycle using Python and HDF5.",
99
"applicationCategory": "Engineering",
1010
"programmingLanguage": [

docs/colab/quickstart.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scrolled": true
88
},
99
"outputs": [],
10-
"source": "# !pip install h5rdmtoolbox==2.3.1"
10+
"source": "# !pip install h5rdmtoolbox==2.4.0rc1"
1111
},
1212
{
1313
"cell_type": "code",

docs/gettingstarted/quickoverview.ipynb

Lines changed: 115 additions & 110 deletions
Large diffs are not rendered by default.

h5rdmtoolbox/__init__.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
__author_orcid__ = 'https://orcid.org/0000-0001-8729-0482'
6363

6464

65-
def get_package_meta():
65+
def get_package_meta() -> Dict:
6666
"""Reads codemeta.json and returns it as dict"""
6767
with open(__this_dir__ / '../codemeta.json', 'r') as f:
6868
codemeta = json.loads(f.read())
@@ -172,7 +172,6 @@ def dump_jsonld_depr(hdf_filename: Union[str, pathlib.Path],
172172
skipND: int = 1,
173173
structural: bool = True,
174174
contextual: bool = True,
175-
resolve_keys: bool = True,
176175
context: Optional[Dict] = None,
177176
blank_node_iri_base: Optional[str] = None
178177
) -> str:
@@ -189,19 +188,12 @@ def dump_jsonld_depr(hdf_filename: Union[str, pathlib.Path],
189188
considered if structural=True.
190189
structural : bool=True
191190
Include structural information in the JSON-LD output.
192-
semantic : bool=True
193-
Include semantic information in the JSON-LD output.
194-
resolve_keys : bool=True
195-
Resolve keys in the JSON-LD output. This is used when semantic=True.
196-
If resolve_keys is False and an attribute name in the HDF5 file, which has
197-
a predicate is different in its name from the predicate, the attribute name is used.
198-
Example: an attribute "name" is associated with "foaf:lastName", then "name" is used
199-
and "name": "http://xmlns.com/foaf/0.1/lastName" is added to the context.
191+
contextual : bool=True
192+
Include contextual information in the JSON-LD output.
200193
context: Optional[Dict]
201194
context in form of {prefix: IRI}, e.g. "ssno": "https://matthiasprobst.github.io/ssno#"
202-
If resolve_keys is True, this is added to the built-in look-up table to be used in the
203-
context part of JSON-LD
204-
195+
blank_node_iri_base: Optional[str]
196+
IRI base used for blank nodes
205197
"""
206198
if blank_node_iri_base is not None:
207199
if not isinstance(blank_node_iri_base, (str, HttpUrl)):
@@ -212,20 +204,18 @@ def dump_jsonld_depr(hdf_filename: Union[str, pathlib.Path],
212204

213205
from h5rdmtoolbox.ld.hdf.file import get_serialized_ld
214206
if structural and not contextual:
215-
return get_serialized_ld(hdf_filename, blank_node_iri_base, format="json-ld", context=context,
216-
contextual=contextual, skipND=skipND)
217-
return get_serialized_ld(hdf_filename, blank_node_iri_base, format="json-ld", context=context,
218-
contextual=contextual, skipND=skipND)
219-
# with File(hdf_filename) as h5:
220-
# return jsonld.dumps(
221-
# h5,
222-
# structural=structural,
223-
# resolve_keys=resolve_keys,
224-
# context=context,
225-
# blank_node_iri_base=blank_node_iri_base,
226-
# skipND=skipND,
227-
# **kwargs
228-
# )
207+
return get_serialized_ld(
208+
hdf_filename,
209+
blank_node_iri_base,
210+
format="json-ld",
211+
context=context,
212+
skipND=skipND)
213+
return get_serialized_ld(
214+
hdf_filename,
215+
blank_node_iri_base,
216+
format="json-ld",
217+
context=context,
218+
skipND=skipND)
229219

230220

231221
def serialize(hdf_filename,
@@ -257,7 +247,7 @@ def build_pyvis_graph(hdf_filename, output_filename="kg-graph.html", notebook=Fa
257247
kg = kglab.KnowledgeGraph().load_rdf_text(
258248
serialize(hdf_filename, fmt="ttl", structural=structural, contextual=contextual)
259249
)
260-
VIS_STYLE = style or {
250+
vis_style = style or {
261251
"hdf": {
262252
"color": "orange",
263253
"size": 40,
@@ -268,7 +258,7 @@ def build_pyvis_graph(hdf_filename, output_filename="kg-graph.html", notebook=Fa
268258
},
269259
}
270260
subgraph = kglab.SubgraphTensor(kg)
271-
pyvis_graph = subgraph.build_pyvis_graph(notebook=notebook, style=VIS_STYLE)
261+
pyvis_graph = subgraph.build_pyvis_graph(notebook=notebook, style=vis_style)
272262
pyvis_graph.force_atlas_2based()
273263
pyvis_graph.show(output_filename)
274264
return pyvis_graph
@@ -372,4 +362,5 @@ def clean_temp_data(full: bool = False):
372362
'File', 'Group', 'Dataset', 'Attribute',
373363
'dump', 'dumps', 'cv_h5py', 'lower', 'Lower',
374364
'set_config', 'get_config', 'get_ureg',
375-
'Convention', 'jsonld', 'lazy', 'DownloadFileManager')
365+
'Convention', 'jsonld', 'lazy', 'DownloadFileManager',
366+
'get_package_meta', 'clean_temp_data')

h5rdmtoolbox/_cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, **kwargs):
7373
raise KeyError(f'Not a configuration key: "{k}"')
7474
self.old[k] = CONFIG[k]
7575
if k == 'ureg_format':
76-
get_ureg().default_format = str(v)
76+
get_ureg().formatter.default_format = str(v)
7777
self._update(kwargs)
7878

7979
def __enter__(self):

h5rdmtoolbox/convention/core.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from pydoc import locate
1414
from typing import Union, List, Dict, Tuple, Any
1515

16+
from forge import kwargs
17+
1618
from h5rdmtoolbox import errors
1719
from h5rdmtoolbox.repository import RepositoryInterface
1820
from h5rdmtoolbox.wrapper import ds_decoder
@@ -696,24 +698,19 @@ def from_json(filename: Union[str, pathlib.Path], overwrite: bool = False) -> Co
696698

697699

698700
def from_repo(repo_interface: RepositoryInterface,
699-
name: str,
700-
take_existing: bool = True,
701-
force_download: bool = False):
702-
"""Download a YAML file from a repository"""
703-
# check if file exists:
704-
# path_compatible_doi = repo_interface.get_doi().replace('/', '_')
705-
# estimated_filename = UserDir['cache'] / f'{path_compatible_doi}' / name
706-
# estimated_filename.parent.mkdir(parents=True, exist_ok=True)
707-
# if estimated_filename.exists():
708-
# if not take_existing:
709-
# raise FileExistsError(f'File {name} exists in cache but take_existing is set to False.')
710-
# if take_existing and not force_download:
711-
# return from_file(estimated_filename)
701+
name: str):
702+
"""Download a YAML file from a repository
712703
704+
Parameters
705+
----------
706+
repo_interface: RepositoryInterface
707+
The repository interface to use for downloading the file
708+
name: str
709+
Name of the file to download
710+
"""
711+
logger.debug(f"Downloading file {name} from repository {repo_interface}")
713712
filename = repo_interface.download_file(name)
714-
# if estimated_filename.exists():
715-
# estimated_filename.unlink()
716-
# filename.rename(estimated_filename)
713+
logger.debug(f"File downloaded to {filename}. Now loading convention from file.")
717714
return from_file(filename)
718715

719716

@@ -723,7 +720,7 @@ def from_zenodo(doi_or_recid: str,
723720
force_download: bool = False) -> Convention:
724721
"""Download a YAML file from a zenodo repository
725722
726-
Depreciated. Use `from_repo` in future.
723+
Depreciated. Use `from_repo` in the future.
727724
728725
Parameters
729726
----------

0 commit comments

Comments
 (0)