h5rdmtoolbox 2.5.3__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.
- h5rdmtoolbox/__init__.py +424 -0
- h5rdmtoolbox/_cfg.py +104 -0
- h5rdmtoolbox/_repr.py +747 -0
- h5rdmtoolbox/_version.py +6 -0
- h5rdmtoolbox/cli.py +61 -0
- h5rdmtoolbox/consts.py +3 -0
- h5rdmtoolbox/convention/__init__.py +41 -0
- h5rdmtoolbox/convention/cfg.py +2 -0
- h5rdmtoolbox/convention/consts.py +28 -0
- h5rdmtoolbox/convention/core.py +817 -0
- h5rdmtoolbox/convention/errors.py +34 -0
- h5rdmtoolbox/convention/generate.py +385 -0
- h5rdmtoolbox/convention/ontology/__init__.py +3 -0
- h5rdmtoolbox/convention/ontology/h5ontocls.py +133 -0
- h5rdmtoolbox/convention/ontology/hdf_datatypes.py +64 -0
- h5rdmtoolbox/convention/references.py +23 -0
- h5rdmtoolbox/convention/standard_attributes.py +383 -0
- h5rdmtoolbox/convention/toolbox_validators.py +175 -0
- h5rdmtoolbox/convention/utils.py +216 -0
- h5rdmtoolbox/data/def_icon.png +0 -0
- h5rdmtoolbox/data/fluid-v1.yml +36 -0
- h5rdmtoolbox/data/h5tbx.yaml +28 -0
- h5rdmtoolbox/data/id_icon.png +0 -0
- h5rdmtoolbox/data/iri_icon.png +0 -0
- h5rdmtoolbox/data/ld_icon.png +0 -0
- h5rdmtoolbox/data/piv-v1.yml +35 -0
- h5rdmtoolbox/data/style.css +216 -0
- h5rdmtoolbox/data/tutorial_convention.yaml +91 -0
- h5rdmtoolbox/data/tutorial_standard_name_table.yaml +390 -0
- h5rdmtoolbox/data/type_icon.png +0 -0
- h5rdmtoolbox/database/__init__.py +75 -0
- h5rdmtoolbox/database/hdfdb/__init__.py +4 -0
- h5rdmtoolbox/database/hdfdb/filedb.py +129 -0
- h5rdmtoolbox/database/hdfdb/objdb.py +520 -0
- h5rdmtoolbox/database/hdfdb/query.py +133 -0
- h5rdmtoolbox/database/hdfdb/utils.py +51 -0
- h5rdmtoolbox/database/interface.py +59 -0
- h5rdmtoolbox/database/lazy.py +183 -0
- h5rdmtoolbox/database/mongo.py +374 -0
- h5rdmtoolbox/errors.py +4 -0
- h5rdmtoolbox/extensions/__init__.py +0 -0
- h5rdmtoolbox/extensions/magnitude.py +67 -0
- h5rdmtoolbox/extensions/normalize.py +103 -0
- h5rdmtoolbox/extensions/onto.py +52 -0
- h5rdmtoolbox/extensions/units.py +48 -0
- h5rdmtoolbox/extensions/vector.py +138 -0
- h5rdmtoolbox/gui/__init__.py +0 -0
- h5rdmtoolbox/gui/fairify.py +446 -0
- h5rdmtoolbox/gui/src/__init__.py +0 -0
- h5rdmtoolbox/gui/src/main.py +131 -0
- h5rdmtoolbox/identifiers.py +257 -0
- h5rdmtoolbox/layout/__init__.py +4 -0
- h5rdmtoolbox/layout/core.py +624 -0
- h5rdmtoolbox/ld/__init__.py +129 -0
- h5rdmtoolbox/ld/globals.py +3 -0
- h5rdmtoolbox/ld/hdf/__init__.py +0 -0
- h5rdmtoolbox/ld/hdf/attributes.py +36 -0
- h5rdmtoolbox/ld/hdf/datasets.py +160 -0
- h5rdmtoolbox/ld/hdf/file.py +54 -0
- h5rdmtoolbox/ld/hdf/groups.py +47 -0
- h5rdmtoolbox/ld/rdf.py +883 -0
- h5rdmtoolbox/ld/shacl.py +221 -0
- h5rdmtoolbox/ld/user/__init__.py +0 -0
- h5rdmtoolbox/ld/user/attributes.py +241 -0
- h5rdmtoolbox/ld/user/datasets.py +22 -0
- h5rdmtoolbox/ld/user/file.py +58 -0
- h5rdmtoolbox/ld/user/groups.py +58 -0
- h5rdmtoolbox/ld/user/utils.py +8 -0
- h5rdmtoolbox/ld/utils.py +133 -0
- h5rdmtoolbox/plotting.py +168 -0
- h5rdmtoolbox/protected_attributes.py +9 -0
- h5rdmtoolbox/protocols.py +268 -0
- h5rdmtoolbox/repository/__init__.py +11 -0
- h5rdmtoolbox/repository/default_metamapper.py +55 -0
- h5rdmtoolbox/repository/interface.py +214 -0
- h5rdmtoolbox/repository/utils.py +131 -0
- h5rdmtoolbox/repository/zenodo/__init__.py +5 -0
- h5rdmtoolbox/repository/zenodo/core.py +616 -0
- h5rdmtoolbox/repository/zenodo/metadata.py +276 -0
- h5rdmtoolbox/repository/zenodo/tokens.py +118 -0
- h5rdmtoolbox/repository/zenodo/utils.py +16 -0
- h5rdmtoolbox/tutorial.py +374 -0
- h5rdmtoolbox/user.py +158 -0
- h5rdmtoolbox/utils.py +743 -0
- h5rdmtoolbox/wrapper/__init__.py +8 -0
- h5rdmtoolbox/wrapper/accessor.py +97 -0
- h5rdmtoolbox/wrapper/accessors/__init__.py +0 -0
- h5rdmtoolbox/wrapper/accessors/provenance.py +36 -0
- h5rdmtoolbox/wrapper/core.py +2528 -0
- h5rdmtoolbox/wrapper/ds_decoder.py +113 -0
- h5rdmtoolbox/wrapper/h5attr.py +519 -0
- h5rdmtoolbox/wrapper/h5ext.py +20 -0
- h5rdmtoolbox/wrapper/h5utils.py +32 -0
- h5rdmtoolbox/wrapper/h5yaml.py +116 -0
- h5rdmtoolbox/wrapper/jsonld.py +1189 -0
- h5rdmtoolbox/wrapper/xr2hdf.py +106 -0
- h5rdmtoolbox-2.5.3.dist-info/METADATA +379 -0
- h5rdmtoolbox-2.5.3.dist-info/RECORD +144 -0
- h5rdmtoolbox-2.5.3.dist-info/WHEEL +5 -0
- h5rdmtoolbox-2.5.3.dist-info/entry_points.txt +2 -0
- h5rdmtoolbox-2.5.3.dist-info/licenses/LICENSE +20 -0
- h5rdmtoolbox-2.5.3.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/clean_zenodo_sandbox.py +23 -0
- tests/conventions/__init__.py +0 -0
- tests/conventions/test_convention_vfuncs.py +98 -0
- tests/conventions/test_conventions.py +697 -0
- tests/conventions/test_engmeta.py +55 -0
- tests/conventions/test_references.py +22 -0
- tests/conventions/test_toolbox_validators.py +138 -0
- tests/conventions/test_utils.py +94 -0
- tests/database/__init__.py +0 -0
- tests/database/test_find_rdf.py +36 -0
- tests/database/test_hdfDB.py +619 -0
- tests/database/test_mongo.py +229 -0
- tests/layouts/__init__.py +0 -0
- tests/layouts/test_core.py +362 -0
- tests/layouts/test_docs.py +66 -0
- tests/ld/__init__.py +0 -0
- tests/ld/test_ld.py +904 -0
- tests/ld/test_rdf.py +688 -0
- tests/ld/test_shacl.py +223 -0
- tests/ld/test_user_graph.py +278 -0
- tests/ld/test_utils.py +13 -0
- tests/repository/__init__.py +0 -0
- tests/repository/test_zenodo.py +728 -0
- tests/test_cli.py +69 -0
- tests/test_config.py +80 -0
- tests/test_extensions.py +148 -0
- tests/test_identifiers.py +85 -0
- tests/test_plotting.py +155 -0
- tests/test_repr.py +114 -0
- tests/test_user.py +100 -0
- tests/test_utils.py +143 -0
- tests/test_version.py +72 -0
- tests/test_xarray_export.py +47 -0
- tests/wrapper/__init__.py +0 -0
- tests/wrapper/test_core.py +994 -0
- tests/wrapper/test_dump.py +77 -0
- tests/wrapper/test_file.py +411 -0
- tests/wrapper/test_h5ext.py +22 -0
- tests/wrapper/test_lazy.py +62 -0
- tests/wrapper/test_namespaces.py +46 -0
- tests/wrapper/test_xr2df.py +41 -0
h5rdmtoolbox/_version.py
ADDED
h5rdmtoolbox/cli.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@click.group(invoke_without_command=True)
|
|
7
|
+
@click.option('--fairify', type=str, help='Starts the app helping you to make the file FAIRer')
|
|
8
|
+
def h5tbx(fairify):
|
|
9
|
+
if fairify:
|
|
10
|
+
filename = pathlib.Path(fairify)
|
|
11
|
+
from h5rdmtoolbox.gui.fairify import start
|
|
12
|
+
print(f'Opening GUI to fairify the file {filename}')
|
|
13
|
+
start(filename=filename)
|
|
14
|
+
print(f'GUI closed')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@h5tbx.command()
|
|
18
|
+
@click.argument('filename', type=click.Path(exists=True))
|
|
19
|
+
@click.option(
|
|
20
|
+
'-o', '--output',
|
|
21
|
+
type=click.Path(exists=False),
|
|
22
|
+
help='Filename to write the JSON-LD data to.'
|
|
23
|
+
)
|
|
24
|
+
@click.option("--format", type=str, help="The output format, e.g. jsonld.",
|
|
25
|
+
default="ttl")
|
|
26
|
+
@click.option("--graph", is_flag=True,
|
|
27
|
+
help="Generates a graph and stores it in OUTPUT-graph.html. Uses pyvis and kglab. "
|
|
28
|
+
"Please Make sure it is installed")
|
|
29
|
+
def ld(filename, output, format, graph):
|
|
30
|
+
"""Linked-Data command"""
|
|
31
|
+
|
|
32
|
+
content = None
|
|
33
|
+
|
|
34
|
+
def _serialize(filename):
|
|
35
|
+
from h5rdmtoolbox import serialize
|
|
36
|
+
return serialize(filename, fmt=format, indent=2)
|
|
37
|
+
|
|
38
|
+
if output:
|
|
39
|
+
output = pathlib.Path(output)
|
|
40
|
+
if not format:
|
|
41
|
+
format = output.suffix[1:]
|
|
42
|
+
if output:
|
|
43
|
+
valid_extension = (".jsonld", ".json-ld", ".ttl", ".turtle")
|
|
44
|
+
if output.suffix not in valid_extension:
|
|
45
|
+
raise ValueError(f"Please use one of the following extensions: {valid_extension}")
|
|
46
|
+
if not content:
|
|
47
|
+
content = _serialize(filename)
|
|
48
|
+
with open(output, "w") as f:
|
|
49
|
+
f.write(content)
|
|
50
|
+
else:
|
|
51
|
+
if not content:
|
|
52
|
+
content = _serialize(filename)
|
|
53
|
+
print(content)
|
|
54
|
+
|
|
55
|
+
if graph:
|
|
56
|
+
from h5rdmtoolbox import build_pyvis_graph
|
|
57
|
+
build_pyvis_graph(filename, output_filename=filename.with_suffix("-graph.html"))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == '__main__':
|
|
61
|
+
h5tbx(obj={})
|
h5rdmtoolbox/consts.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
""""
|
|
2
|
+
|
|
3
|
+
This sub-package provides convention such as standard_names
|
|
4
|
+
|
|
5
|
+
The concept of standard_names is adopted from the climate forecast community (see cfconventions.org)
|
|
6
|
+
|
|
7
|
+
A convention (class `Convention` includes a set of standard attributes, which are defined in a YAML file.
|
|
8
|
+
|
|
9
|
+
Helpful functions:
|
|
10
|
+
- `get_registered_conventions`
|
|
11
|
+
- `get_current_convention`
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import pathlib
|
|
15
|
+
|
|
16
|
+
from .core import Convention, from_yaml, from_repo, get_current_convention, from_zenodo, get_registered_conventions, \
|
|
17
|
+
yaml2jsonld
|
|
18
|
+
from .standard_attributes import StandardAttribute
|
|
19
|
+
from .toolbox_validators import get_list_of_validators
|
|
20
|
+
from ..user import UserDir
|
|
21
|
+
|
|
22
|
+
__this_dir__ = pathlib.Path(__file__).parent
|
|
23
|
+
|
|
24
|
+
convention_user_dir = UserDir['convention'] / 'h5tbx'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def build_convention():
|
|
28
|
+
"""Build the toolbox convention from the yaml file"""
|
|
29
|
+
from . import generate
|
|
30
|
+
h5tbx_convention_yaml = __this_dir__.parent / f'data/h5tbx.yaml'
|
|
31
|
+
convention_user_dir.mkdir(parents=True, exist_ok=True)
|
|
32
|
+
generate.write_convention_module_from_yaml(h5tbx_convention_yaml)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if not (convention_user_dir / f'h5tbx.py').exists():
|
|
36
|
+
build_convention()
|
|
37
|
+
|
|
38
|
+
__all__ = ['Convention', 'from_yaml', 'from_zenodo', 'from_repo',
|
|
39
|
+
'get_current_convention', 'get_registered_conventions',
|
|
40
|
+
'from_zenodo', 'StandardAttribute', 'yaml2jsonld',
|
|
41
|
+
'get_list_of_validators']
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _SpecialDefaults(enum.Enum):
|
|
5
|
+
NONE = 0
|
|
6
|
+
EMPTY = 1
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DefaultValue:
|
|
10
|
+
"""Helper class to distinguish between optional and obligatory standard attributes."""
|
|
11
|
+
|
|
12
|
+
EMPTY = _SpecialDefaults.EMPTY
|
|
13
|
+
NONE = _SpecialDefaults.NONE
|
|
14
|
+
|
|
15
|
+
def __init__(self, value):
|
|
16
|
+
if value.lower() == '$none':
|
|
17
|
+
self.value = _SpecialDefaults.NONE
|
|
18
|
+
elif value.lower() == '$optional':
|
|
19
|
+
self.value = _SpecialDefaults.NONE
|
|
20
|
+
elif value.lower() == '$obligatory':
|
|
21
|
+
self.value = _SpecialDefaults.EMPTY
|
|
22
|
+
elif value == '$empty':
|
|
23
|
+
self.value = _SpecialDefaults.EMPTY
|
|
24
|
+
else:
|
|
25
|
+
self.value = value
|
|
26
|
+
|
|
27
|
+
def __eq__(self, other):
|
|
28
|
+
return self.value == other
|