Skip to content

Commit

Permalink
Renamed the dataset subpackage to datadoc (#298)
Browse files Browse the repository at this point in the history
# Description
Renamed the dataset subpackage to datadoc
  • Loading branch information
jesper-friis authored Jan 8, 2025
1 parent 624351a commit fd937aa
Show file tree
Hide file tree
Showing 29 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Sub-packages
------------
Additional functionality beyond interfacing triplestore backends is provided by specialised sub-package:

* [tripper.dataset]: An API for data documentation.
* [tripper.datadoc]: An API for data documentation.
* [tripper.mappings]: Traverse mappings stored in the triplestore and find possible mapping routes.
* [tripper.convert]: Convert between RDF and other data representations.

Expand Down Expand Up @@ -106,7 +106,7 @@ We gratefully acknowledge the following projects for supporting the development


[Tutorial]: https://emmc-asbl.github.io/tripper/latest/tutorial/
[tripper.dataset]: https://emmc-asbl.github.io/tripper/latest/dataset/introduction/
[tripper.datadoc]: https://emmc-asbl.github.io/tripper/latest/datadoc/introduction/
[tripper.mappings]: https://emmc-asbl.github.io/tripper/latest/api_reference/mappings/mappings/
[tripper.convert]: https://emmc-asbl.github.io/tripper/latest/api_reference/convert/convert/
[Discovery of custom backends]: https://emmc-asbl.github.io/tripper/latest/backend_discovery/
Expand Down
1 change: 1 addition & 0 deletions docs/api_reference/datadoc/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: "datadoc"
3 changes: 3 additions & 0 deletions docs/api_reference/datadoc/clitool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# clitool

::: tripper.datadoc.clitool
3 changes: 3 additions & 0 deletions docs/api_reference/datadoc/dataaccess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# dataaccess

::: tripper.datadoc.dataaccess
3 changes: 3 additions & 0 deletions docs/api_reference/datadoc/dataset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# dataset

::: tripper.datadoc.dataset
3 changes: 3 additions & 0 deletions docs/api_reference/datadoc/tabledoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# tabledoc

::: tripper.datadoc.tabledoc
1 change: 0 additions & 1 deletion docs/api_reference/dataset/.pages

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api_reference/dataset/dataaccess.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api_reference/dataset/datadoc.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api_reference/dataset/dataset.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api_reference/dataset/tabledoc.md

This file was deleted.

12 changes: 6 additions & 6 deletions docs/dataset/customisation.md → docs/datadoc/customisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ You can save this context to a triplestore with
```python
>>> from tripper import Triplestore
>>> from tripper.dataset import save_datadoc
>>> from tripper.datadoc import save_datadoc
>>>
>>> ts = Triplestore("rdflib")
>>> save_datadoc( # doctest: +ELLIPSIS
Expand Down Expand Up @@ -242,9 +242,9 @@ Instead, the list of available resource types should be stored and retrieved fro
[predefined prefixes]: prefixes.md
[predefined keywords]: keywords.md
[default context]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tripper/context/0.2/context.json
[save_dict()]: ../api_reference/dataset/dataset.md#tripper.dataset.dataset.save_dict
[as_jsonld()]: ../api_reference/dataset/dataset.md#tripper.dataset.dataset.as_jsonld
[save_datadoc()]: ../api_reference/dataset/dataset.md#tripper.dataset.dataset.save_datadoc
[TableDoc]: ../api_reference/dataset/tabledoc.md/#tripper.dataset.tabledoc.TableDoc
[TableDoc.parse_csv()]: ../api_reference/dataset/tabledoc.md/#tripper.dataset.tabledoc.TableDoc.parse_csv
[save_dict()]: ../api_reference/datadoc/dataset.md#tripper.datadoc.dataset.save_dict
[as_jsonld()]: ../api_reference/datadoc/dataset.md#tripper.datadoc.dataset.as_jsonld
[save_datadoc()]: ../api_reference/datadoc/dataset.md#tripper.datadoc.dataset.save_datadoc
[TableDoc]: ../api_reference/datadoc/tabledoc.md/#tripper.datadoc.tabledoc.TableDoc
[TableDoc.parse_csv()]: ../api_reference/datadoc/tabledoc.md/#tripper.datadoc.tabledoc.TableDoc.parse_csv
[default JSON-LD context]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tripper/context/0.2/context.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Documenting a resource
======================
In the [tripper.dataset] sub-package are the documents documenting the resources internally represented as [JSON-LD] documents stored as Python dicts.
In the [tripper.datadoc] sub-package are the documents documenting the resources internally represented as [JSON-LD] documents stored as Python dicts.
However, the API tries to hide away the complexities of JSON-LD behind simple interfaces.
To support different use cases, the sub-package provide several interfaces for data documentation, including Python dicts, YAML files and tables.
These are further described below.
Expand Down Expand Up @@ -49,7 +49,7 @@ We therefore have to define them explicitly

```python
>>> import json
>>> from tripper.dataset import as_jsonld
>>> from tripper.datadoc import as_jsonld
>>> d = as_jsonld(dataset, prefixes=prefixes)
>>> print(json.dumps(d, indent=2))
{
Expand All @@ -76,7 +76,7 @@ Since the prefixes "sem" and "kb" are not included in the [Predefined prefixes],

```python
>>> from tripper import Triplestore
>>> from tripper.dataset import save_dict
>>> from tripper.datadoc import save_dict
>>> ts = Triplestore(backend="rdflib")
>>> save_dict(ts, dataset, prefixes=prefixes) # doctest: +ELLIPSIS
AttrDict(...)
Expand Down Expand Up @@ -135,7 +135,7 @@ The [save_datadoc()] function allow to save a [YAML] file in [multi-resource](#m
Saving [semdata.yaml] to a triplestore can e.g. be done with

```python
>>> from tripper.dataset import save_datadoc
>>> from tripper.datadoc import save_datadoc
>>> save_datadoc( # doctest: +ELLIPSIS
... ts,
... "https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.yaml"
Expand Down Expand Up @@ -172,7 +172,7 @@ correspond to the following turtle representation:
The below example shows how to save all datasets listed in the CSV file [semdata.csv] to a triplestore.

```python
>>> from tripper.dataset import TableDoc
>>> from tripper.datadoc import TableDoc

>>> td = TableDoc.parse_csv(
... "https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.csv",
Expand All @@ -191,7 +191,7 @@ The below example shows how to save all datasets listed in the CSV file [semdata
```


[tripper.dataset]: https://emmc-asbl.github.io/tripper/latest/api_reference/dataset/dataset
[tripper.datadoc]: https://emmc-asbl.github.io/tripper/latest/datadoc/introduction
[DCAT vocabulary]: https://www.w3.org/TR/vocab-dcat-3/
[DLite]: https://github.com/SINTEF/dlite
[YAML]: https://yaml.org/
Expand All @@ -206,10 +206,10 @@ The below example shows how to save all datasets listed in the CSV file [semdata
[emmo:DataSet]: https://w3id.org/emmo#EMMO_194e367c_9783_4bf5_96d0_9ad597d48d9a
[oteio:Generator]: https://w3id.org/emmo/domain/oteio/Generator
[oteio:Parser]: https://w3id.org/emmo/domain/oteio/Parser
[save_dict()]: ../api_reference/dataset/dataset.md/#tripper.dataset.dataset.save_dict
[as_jsonld()]: ../api_reference/dataset/dataset.md/#tripper.dataset.dataset.as_jsonld
[save_dict()]: ../api_reference/datadoc/dataset.md/#tripper.datadoc.dataset.save_dict
[as_jsonld()]: ../api_reference/datadoc/dataset.md/#tripper.datadoc.dataset.as_jsonld
[save_datadoc()]:
../api_reference/dataset/dataset.md/#tripper.dataset.dataset.save_datadoc
../api_reference/datadoc/dataset.md/#tripper.datadoc.dataset.save_datadoc
[TableDoc]: ../api_reference/datadoc/tabledoc.md/#tripper.datadoc.tabledoc.TableDoc
[semdata.yaml]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.yaml
[semdata.csv]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.csv
[TableDoc]: https://emmc-asbl.github.io/tripper/latest/api_reference/dataset/dataset/#tripper.dataset.tabledoc.TableDoc
18 changes: 9 additions & 9 deletions docs/dataset/introduction.md → docs/datadoc/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ The data documentation is based on small [JSON-LD documents], each documenting a
Examples of resources can be a dataset, an instrument, a sample, etc.
All resources are uniquely identified by their IRI.

The primary focus of the [tripper.dataset] module is to document datasets such that they are consistent with the [DCAT vocabulary], but at the same time easily extended additional semantic meaning provided by other ontologies.
The primary focus of the [tripper.datadoc] module is to document datasets such that they are consistent with the [DCAT vocabulary], but at the same time easily extended additional semantic meaning provided by other ontologies.
It is also easy to add and relate the datasets to other types of documents, like people, instruments and samples.

The [tripper.dataset] module provides a Python API for documenting resources at all four levels of data documentation, including:
The [tripper.datadoc] module provides a Python API for documenting resources at all four levels of data documentation, including:

- **Cataloguing**: Storing and accessing *documents* based on their IRI and data properties.
(Addressed FAIR aspects: *findability* and *accessibility*).
Expand All @@ -30,7 +30,7 @@ The figure below shows illustrates how a dataset is documented in a triplestore.

Resource types
--------------
The [tripper.dataset] module include the following set of predefined resource types:
The [tripper.datadoc] module include the following set of predefined resource types:

- **dataset**: Individual of [dcat:Dataset] and [emmo:DataSet].
- **distribution**: Individual of [dcat:Distribution].
Expand All @@ -43,7 +43,7 @@ Future releases will support adding custom resource types.



[tripper.dataset]: https://emmc-asbl.github.io/tripper/latest/api_reference/dataset/dataset
[tripper.datadoc]: https://emmc-asbl.github.io/tripper/latest/datadoc/introduction
[DCAT vocabulary]: https://www.w3.org/TR/vocab-dcat-3/
[DLite]: https://github.com/SINTEF/dlite
[YAML]: https://yaml.org/
Expand All @@ -58,10 +58,10 @@ Future releases will support adding custom resource types.
[emmo:DataSet]: https://w3id.org/emmo#EMMO_194e367c_9783_4bf5_96d0_9ad597d48d9a
[oteio:Generator]: https://w3id.org/emmo/domain/oteio/Generator
[oteio:Parser]: https://w3id.org/emmo/domain/oteio/Parser
[save_dict()]: ../../api_reference/dataset/dataset/#tripper.dataset.dataset.save_dict
[as_jsonld()]: ../../api_reference/dataset/dataset/#tripper.dataset.dataset.as_jsonld
[save_dict()]: ../../api_reference/datadoc/dataset/#tripper.datadoc.dataset.save_dict
[as_jsonld()]: ../../api_reference/datadoc/dataset/#tripper.datadoc.dataset.as_jsonld
[save_datadoc()]:
../../api_reference/dataset/dataset/#tripper.dataset.dataset.save_datadoc
../../api_reference/datadoc/dataset/#tripper.datadoc.dataset.save_datadoc
[semdata.yaml]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.yaml
[semdata.csv]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/tabledoc-csv/tests/input/semdata.csv
[TableDoc]: https://emmc-asbl.github.io/tripper/latest/api_reference/dataset/dataset/#tripper.dataset.tabledoc.TableDoc
[semdata.csv]: https://raw.githubusercontent.com/EMMC-ASBL/tripper/refs/heads/master/tests/input/semdata.csv
[TableDoc]: https://emmc-asbl.github.io/tripper/latest/api_reference/datadoc/tabledoc/#tripper.datadoc.tabledoc.TableDoc
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Sub-packages
------------
Additional functionality beyond interfacing triplestore backends is provided by specialised sub-package:

* [tripper.dataset]: An API for data documentation.
* [tripper.datadoc]: An API for data documentation.
* [tripper.mappings]: Traverse mappings stored in the triplestore and find possible mapping routes.
* [tripper.convert]: Convert between RDF and other data representations.

Expand Down Expand Up @@ -106,7 +106,7 @@ We gratefully acknowledge the following projects for supporting the development


[Tutorial]: https://emmc-asbl.github.io/tripper/latest/tutorial/
[tripper.dataset]: https://emmc-asbl.github.io/tripper/latest/dataset/introduction/
[tripper.datadoc]: https://emmc-asbl.github.io/tripper/latest/datadoc/introduction/
[tripper.mappings]: https://emmc-asbl.github.io/tripper/latest/api_reference/mappings/mappings/
[tripper.convert]: https://emmc-asbl.github.io/tripper/latest/api_reference/convert/convert/
[Discovery of custom backends]: https://emmc-asbl.github.io/tripper/latest/backend_discovery/
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/datadoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,4 @@ The `--output` option allows to write the dataset to a local file.



[resource types]: ../dataset/introduction.md/#resource-types
[resource types]: ../datadoc/introduction.md/#resource-types
12 changes: 6 additions & 6 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ markdown_extensions:
permalink: true

exclude_docs: |
../dataset/datadoc.py
../datadoc/datadoc.py
plugins:
Expand Down Expand Up @@ -89,11 +89,11 @@ nav:
- Tools:
- datadoc: tools/datadoc.md
- Data documentation:
- Introduction: dataset/introduction.md
- Documenting a resource: dataset/documenting-a-resource.md
- Customisation: dataset/customisation.md
- Predefined prefixes: dataset/prefixes.md
- Predefined keywords: dataset/keywords.md
- Introduction: datadoc/introduction.md
- Documenting a resource: datadoc/documenting-a-resource.md
- Customisation: datadoc/customisation.md
- Predefined prefixes: datadoc/prefixes.md
- Predefined keywords: datadoc/keywords.md
- ... | api_reference/**
- Known issues: known-issues.md
- For developers: developers.md
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mappings = [
"pint>=0.16.1,<0.25",
"rdflib>=6.3.0,<7.0.0",
]
dataset = [
datadoc = [
"tripper[mappings]",
"PyYaml>=3.0.0,<6.0.3", # todo: check lower version
"requests>=2.0.0,<3.4.1", # todo: check lower version
Expand All @@ -52,7 +52,7 @@ testing-core = [
"pytest-cov==4.1.0",
]
testing = [
"tripper[testing-core,mappings,dataset]",
"tripper[testing-core,mappings,datadoc]",
"dlite-python>=0.5.23,<0.5.27; python_version>='3.8' and python_version<'3.13'",
"dlite-python>=0.5.25,<0.5.27; python_version>='3.13'",
"emmontopy>=0.5.0,<0.7.1; python_version<'3.13'",
Expand Down Expand Up @@ -84,7 +84,7 @@ Changelog = "https://github.com/EMMC-ASBL/tripper/blob/master/CHANGELOG.md"
Package = "https://pypi.org/project/tripper"

[project.scripts]
datadoc = "tripper.dataset.datadoc:main"
datadoc = "tripper.datadoc.clitool:main"

[tool.isort]
line_length = 79 # PEP8
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_save_and_load():
from dataset_paths import outdir # pylint: disable=import-error

from tripper import DCAT, DCTERMS, EMMO, Triplestore
from tripper.dataset import load, load_dict, save, save_dict
from tripper.datadoc import load, load_dict, save, save_dict

pytest.importorskip("dlite")
pytest.importorskip("rdflib")
Expand Down
26 changes: 13 additions & 13 deletions tests/dataset/test_dataset.py → tests/datadoc/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

def test_get_jsonld_context():
"""Test get_jsonld_context()."""
from tripper.dataset import get_jsonld_context
from tripper.dataset.dataset import CONTEXT_URL
from tripper.datadoc import get_jsonld_context
from tripper.datadoc.dataset import CONTEXT_URL

context = get_jsonld_context()
assert isinstance(context, dict)
Expand Down Expand Up @@ -42,7 +42,7 @@ def test_get_jsonld_context():

def test_get_prefixes():
"""Test get_prefixes()."""
from tripper.dataset import get_prefixes
from tripper.datadoc import get_prefixes

prefixes = get_prefixes()
assert prefixes["dcat"] == "http://www.w3.org/ns/dcat#"
Expand All @@ -56,7 +56,7 @@ def test_get_prefixes():
def test_get_shortnames():
"""Test get_shortnames()."""
from tripper import DCTERMS
from tripper.dataset.dataset import get_shortnames
from tripper.datadoc.dataset import get_shortnames

# Short names that are not equal to the last component of the IRI
exceptions = (
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_get_shortnames():

def test_add():
"""Test help-function add()."""
from tripper.dataset.dataset import add
from tripper.datadoc.dataset import add

d = {}
add(d, "a", "1")
Expand All @@ -99,7 +99,7 @@ def test_add():

def test_addnested():
"""Test help-function addnested()."""
from tripper.dataset.dataset import addnested
from tripper.datadoc.dataset import addnested
from tripper.utils import AttrDict

d = AttrDict()
Expand All @@ -117,7 +117,7 @@ def test_addnested():

def test_get():
"""Test help-function get()."""
from tripper.dataset.dataset import get
from tripper.datadoc.dataset import get

d = {"a": [1, 2], "b": 1}
assert get(d, "a") == [1, 2]
Expand All @@ -132,7 +132,7 @@ def test_get():
def test_expand_iri():
"""Test help-function expand_iri()."""
from tripper import CHAMEO, DCTERMS, OTEIO, RDF
from tripper.dataset.dataset import expand_iri, get_prefixes
from tripper.datadoc.dataset import expand_iri, get_prefixes

prefixes = get_prefixes()
assert expand_iri("chameo:Sample", prefixes) == CHAMEO.Sample
Expand All @@ -147,8 +147,8 @@ def test_expand_iri():
def test_as_jsonld():
"""Test as_jsonld()."""
from tripper import DCAT, EMMO, OWL, Namespace
from tripper.dataset import as_jsonld
from tripper.dataset.dataset import CONTEXT_URL
from tripper.datadoc import as_jsonld
from tripper.datadoc.dataset import CONTEXT_URL

with pytest.raises(ValueError):
as_jsonld({})
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_datadoc():
from dataset_paths import indir # pylint: disable=import-error

from tripper import CHAMEO, DCAT, EMMO, OTEIO, Triplestore
from tripper.dataset import load_dict, save_datadoc, save_dict, search_iris
from tripper.datadoc import load_dict, save_datadoc, save_dict, search_iris

pytest.importorskip("dlite")
pytest.importorskip("rdflib")
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_custom_context():
from dataset_paths import indir # pylint: disable=import-error

from tripper import Triplestore
from tripper.dataset import save_datadoc
from tripper.datadoc import save_datadoc

ts = Triplestore("rdflib")
d = save_datadoc(ts, indir / "custom_context.yaml")
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_pipeline():
otelib = pytest.importorskip("otelib")
from dataset_paths import indir # pylint: disable=import-error

from tripper.dataset import get_partial_pipeline, save_datadoc
from tripper.datadoc import get_partial_pipeline, save_datadoc

# Prepare triplestore
ts = Triplestore("rdflib")
Expand Down
Loading

0 comments on commit fd937aa

Please sign in to comment.