Skip to content

Commit 91f46a0

Browse files
committed
Update docs
1 parent 868698a commit 91f46a0

File tree

10 files changed

+51
-27
lines changed

10 files changed

+51
-27
lines changed

.cspell/custom-dictionary.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Downsampled
1414
Draxl
1515
ELECTRONANALYZER
1616
ESRFET
17+
ESRF
1718
Emminger
1819
Florian
1920
Forschungsgemeinschaft
@@ -60,7 +61,9 @@ Sandor
6061
Scheidgen
6162
Shabih
6263
Sherjeel
64+
submoduling
6365
Tommaso
66+
testdata
6467
UNALLOWED
6568
Uniquified
6669
Uniquifies
130 KB
Loading
63.2 KB
Loading
186 KB
Loading
Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
# How to use the ontology service in pynxtools
1+
# Using ontology service in pynxtools
22

3-
## Overview
4-
5-
The ontology service in `pynxtools` provides a FastAPI-based app for querying NeXus ontology integrated with ESRFET and PaNET. It enables users to retrieve ontological information, such as superclasses for NeXus Application definitions and makes datasets of different experimental techniques based on PaNET ontology findable in NOMAD.
3+
!!! info "This is a how-to guide for using the ontology service. If you want to learn more about how `ontology service` works in `pynxtools`, please visit the [explanation](../../learn/pynxtools/ontology-service.md) "
64

75
## Prerequisites
86

9-
- Python 3.8+
7+
- Python 3.10+
108
- Install required packages:
11-
- `pynxtools` and its dependencies (see [`pyproject.toml`](../../../pyproject.toml))
9+
- `pynxtools` and its dependencies (see [`pyproject.toml`](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/pyproject.toml))
1210
- `owlready2`, `pygit2`, `fastapi`, `uvicorn`
13-
- Ensure the NeXusOntology and definitions submodule are present in the repository, typically at [`src/pynxtools/NeXusOntology`](../../../src/pynxtools/NeXusOntology/) and [`src/pynxtools/definitions`](../../../src/pynxtools/definitions/) respectively.
11+
- Ensure the NeXusOntology and definitions submodules are initialized (see [Development guide](../../tutorial/contributing.md#development-installation)).
1412

1513
## Getting Started
1614

1715
### Importing and Using the Service
1816

19-
The main entry point is the FastAPI app defined in [`pynxtools.nomad.apis.ontology_service`](../../../src/pynxtools//nomad/apis/ontology_service.py). You can import and use the service as follows:
17+
The main entry point is the FastAPI app defined in [`pynxtools.nomad.apis.ontology_service`](https://github.com/FAIRmat-NFDI/pynxtools/blob/ontology-service/src/pynxtools/nomad/apis/ontology_service.py). You can import and use the service as follows:
2018

2119
```python
2220
from pynxtools.nomad.apis.ontology_service import app, load_ontology, fetch_superclasses
2321
```
2422

2523
### Minimal Working Example
2624

27-
You can extract superclasses for a NeXus class using the ontology service's HTTP API endpoint. For example, using Python's `requests` library:
25+
You can extract superclasses for a NeXus class using the ontology service's HTTP API endpoint. Here's an example using Python's `requests` library:
2826

2927
```python
3028
import requests
3129

3230
# Replace with the actual running service URL
3331
base_url = "http://localhost:8000/nomad-oasis/"
34-
class_name = "NXiv_temp"
32+
class_name = "NXmpes_arpes"
3533
response = requests.get(f"{base_url}/superclasses/{class_name}")
3634
if response.status_code == 200:
3735
superclasses = response.json().get("superclasses", [])
@@ -40,8 +38,22 @@ else:
4038
print(f"Error: {response.status_code} - {response.text}")
4139
```
4240

43-
This endpoint returns a JSON object with the list of superclasses for the given NeXus class name, as used internally in [pynxtools](../../../src/pynxtools/nomad/schema.py)
41+
This endpoint returns a JSON object with the list of superclasses for the given NeXus class name, as used internally in [pynxtools](https://github.com/FAIRmat-NFDI/pynxtools/blob/ontology-service/src/pynxtools/nomad/schema.py)
42+
43+
## How it works in NOMAD
44+
45+
When you upload a NeXus file to NOMAD, the ontology service is automatically triggered during data processing. Here's what happens:
46+
47+
1. **Triggering**: During normalization, NOMAD reads the `definition__field` from NeXus entry (e.g., `NXmpes_arpes`).
48+
49+
![Processing NeXus files in NOMAD](../../assets/ontology-service-trigger.png){ width="800" }
50+
![Reading definition field](../../assets/entry_definition__field.png){ width="800" }
51+
52+
2. **Querying**: The service loads the ontology (or generates it if not already present) and retrieves all superclasses for that application definition.
53+
54+
3. **Storing results**: The retrieved superclasses are stored in `results.eln.methods` in the NOMAD archive.
4455

45-
### Further Reading
56+
![Ontology results in NOMAD](../../assets/superclasses_results.png){ width="800" }
4657

47-
- [Learn: Understanding the ontology service in pynxtools](../../learn/pynxtools/ontology-service.md)
58+
!!! info "Further Reading"
59+
- [Learn: Understanding the ontology service in pynxtools](../../learn/pynxtools/ontology-service.md)

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ We are offering a small guide to getting started with NeXus, `pynxtools`, and NO
5050
- [Running `pynxtools` tests in parallel](how-tos/pynxtools/run-tests-in-parallel.md)
5151
- [Using Python to create NeXus files](how-tos/pynxtools/create-nexus-files-by-python.md)
5252
- [Validation of NeXus files](how-tos/pynxtools/validate-nexus-files.md)
53+
- [Use ontology service](how-tos/pynxtools/ontology-service.md)
5354

5455
</div>
5556

@@ -68,6 +69,7 @@ We are offering a small guide to getting started with NeXus, `pynxtools`, and NO
6869
- [Data conversion in `pynxtools`](learn/pynxtools/dataconverter-and-readers.md)
6970
- [Validation of NeXus files](learn/pynxtools/nexus-validation.md)
7071
- [The `MultiFormatReader` as a reader superclass](learn/pynxtools/multi-format-reader.md)
72+
- [Introduction to ontology service](learn/pynxtools/ontology-service.md)
7173

7274
</div>
7375
<div markdown="block">

docs/learn/pynxtools/ontology-service.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
# Understanding the ontology service in pynxtools
22

3+
!!! info "This is a learn guide for using the ontology service. If you want to learn more about how to use `ontology service` in `pynxtools`, please visit the [explanation](../../how-tos/pynxtools/ontology-service.md) "
4+
35
## Introduction
46

5-
The ontology service in `pynxtools` addresses the need for structured, semantic search of NeXus Application definitions and their relationships to ESRFET and PaNET, within NOMAD. It enables querying, reasoning of ontologies, supporting FAIR data principles in scientific workflows.
7+
The ontology service in `pynxtools` provides a FastAPI-based app for querying the [NeXus ontology](https://github.com/nexusformat/NeXusOntology). This service enables users to retrieve ontological information—such as superclasses for NeXus application definitions—and makes datasets of different experimental techniques findable in NOMAD.
8+
9+
The NeXus ontology integrates two key experimental technique ontologies:
10+
11+
- **[PaN Experimental Technique Ontology (PaNET)](https://bioportal.bioontology.org/ontologies/PANET)**: Photon and Neutron Experimental Techniques ontology (PaNET) provides a standardized vocabulary for describing experimental techniques used at photon and neutron research facilities, enabling consistent categorization and discovery of scientific data across different institutions.
12+
13+
- **ESRF Experimental Technique Ontology (ESRFET)**: An ontology developed by the European Synchrotron Radiation Facility (ESRF) to classify and describe experimental techniques specific to synchrotron radiation science. It complements PaNET by providing more granular terms for synchrotron-based methods.
14+
15+
By using these ontologies, the service maps NeXus application definitions to standardized experimental technique terms, improving data interoperability and enabling semantic search capabilities within NOMAD.
616

7-
## How It Fits in pynxtools
17+
## How it fits in pynxtools
818

9-
This service operates within the `nomad` integration layer, exposing ontological data for NeXus Application definitions through a FastAPI interface. It works by accessing ontology files, leveraging NOMAD configuration, and processing NeXus definitions to provide semantic tools and data to users and connected systems.
19+
This service only operates when `pynxtools` is run within `NOMAD`, exposing ontological data for NeXus Application definitions through a FastAPI interface. It uses NOMAD's configuration to set up the API base path and plugin entry points, then processes NeXus definitions to provide semantic data to users and connected systems.
1020

1121
## Core Concepts
1222

13-
- **Ontology**: A formal representation of concepts (classes), relationships, and properties, typically serialized as OWL files.
14-
- **Application definition**: A class or term describing an experimental technique in the NeXus (e.g., `NXiv_temp`).
23+
- **Ontology**: A formal representation of concepts (classes), relationships, and properties, typically serialized as [OWL](https://www.w3.org/OWL/) files.
24+
- **Application definition**: A class or term describing an experimental technique in the NeXus (e.g., `NXmpes_arpes`).
1525
- **Relation**: Connections between entities, such as superclass/subclass relationships.
1626
- **Inferred ontology**: An ontology file that has been processed by a reasoner to infer additional relationships and properties between classes, beyond those explicitly defined.
1727

@@ -43,7 +53,7 @@ import requests
4353

4454
# Replace with the actual running service URL
4555
base_url = "http://localhost:8000/nomad-oasis/"
46-
class_name = "NXiv_temp"
56+
class_name = "NXmpes_arpes"
4757
response = requests.get(f"{base_url}/superclasses/{class_name}")
4858
if response.status_code == 200:
4959
superclasses = response.json().get("superclasses", [])

docs/tutorial/contributing.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ git submodule update --init --recursive --jobs=4
6060

6161
Note that we are using the NeXus definitions as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). The last two lines initiate the submodule and upgrade it to match the first used in pynxtools.
6262

63-
For NeXusOntology submodule [NeXusOntology](../../src/pynxtools/NeXusOntology/) we use the sparse checkout
63+
In addition, for the [ontology service](../learn/pynxtools/ontology-service.md), we are submoduling the [NeXusOntology](https://github.com/FAIRmat-NFDI/NeXusOntology/tree/oscars-project). Here, it is recommended to use the sparse checkout:
64+
6465
```bash
6566
git sparse-checkout init --no-cone
66-
git sparse-checkout set "/*" '!ontology/NeXusOntology.owl' '!ontology/NeXusOntology_full.owl'
67+
git sparse-checkout set "/*" '!ontology/NeXusOntology.owl' '!ontology/NeXusOntology_full.owl' '!ontology/NeXusOntology_full_testdata.owl'
6768
```
6869

6970
Next, we install the package in editable mode (together with its dependencies):

mkdocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ nav:
2525
- how-tos/pynxtools/run-tests-in-parallel.md
2626
- how-tos/pynxtools/create-nexus-files-by-python.md
2727
- how-tos/pynxtools/validate-nexus-files.md
28+
- how-tos/pynxtools/ontology-service.md
2829
- Learn:
2930
- NeXus:
3031
- learn/nexus/nexus-primer.md
@@ -34,6 +35,7 @@ nav:
3435
- learn/pynxtools/dataconverter-and-readers.md
3536
- learn/pynxtools/nexus-validation.md
3637
- learn/pynxtools/multi-format-reader.md
38+
- learn/pynxtools/ontology-service.md
3739
- Reference:
3840
- reference/definitions.md
3941
- reference/cli-api.md

package-lock.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)