Skip to content

Commit e1af5c1

Browse files
committed
Update docs with suggested changes
1 parent 91f46a0 commit e1af5c1

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

docs/how-tos/pynxtools/ontology-service.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
# Using ontology service in pynxtools
1+
# Using the ontology service in pynxtools
22

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) "
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)."
44

55
## Prerequisites
66

77
- Python 3.10+
8-
- Install required packages:
9-
- `pynxtools` and its dependencies (see [`pyproject.toml`](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/pyproject.toml))
10-
- `owlready2`, `pygit2`, `fastapi`, `uvicorn`
11-
- Ensure the NeXusOntology and definitions submodules are initialized (see [Development guide](../../tutorial/contributing.md#development-installation)).
8+
- You will first need to install pynxtools and its dependencies (see [pyproject.toml](https://github.com/FAIRmat-NFDI/pynxtools/blob/master/pyproject.toml)), including owlready2, pygit2, fastapi, uvicorn. For more information about the installation, see [installation guide](../../tutorial/installation.md)
9+
- If you plan to work on `pynxtools` and the ontology service locally, follow the [development guide](../../tutorial/contributing.md). Ensure the NeXusOntology and definitions submodules [are initialized](../../tutorial/contributing.md#development-installation).
1210

13-
## Getting Started
11+
!!! note "NeXusOntology and definitions submodules"
12+
=== "Using pynxtools (standard installation)"
13+
If you are simply using `pynxtools` as a package, the NeXusOntology and definitions submodules are included automatically during installation. Follow the [installation guide](../../tutorial/installation.md) to get started.
1414

15-
### Importing and Using the Service
15+
=== "Developing the ontology service"
16+
If you are contributing to or developing the ontology service, you need to manually initialize the submodules. See the [development guide](../../tutorial/contributing.md#development-installation) for instructions on setting up the development environment.
17+
18+
## Getting started
19+
20+
### Importing and using the service
1621

1722
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:
1823

1924
```python
2025
from pynxtools.nomad.apis.ontology_service import app, load_ontology, fetch_superclasses
2126
```
2227

23-
### Minimal Working Example
28+
### Minimal working example
2429

2530
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:
2631

@@ -46,14 +51,11 @@ When you upload a NeXus file to NOMAD, the ontology service is automatically tri
4651

4752
1. **Triggering**: During normalization, NOMAD reads the `definition__field` from NeXus entry (e.g., `NXmpes_arpes`).
4853

49-
![Processing NeXus files in NOMAD](../../assets/ontology-service-trigger.png){ width="800" }
50-
![Reading definition field](../../assets/entry_definition__field.png){ width="800" }
54+
![Processing NeXus files in NOMAD](../../assets/ontology-service-trigger.png){ width="800" }
55+
![Reading definition field](../../assets/entry_definition__field.png){ width="800" }
5156

5257
2. **Querying**: The service loads the ontology (or generates it if not already present) and retrieves all superclasses for that application definition.
5358

5459
3. **Storing results**: The retrieved superclasses are stored in `results.eln.methods` in the NOMAD archive.
5560

56-
![Ontology results in NOMAD](../../assets/superclasses_results.png){ width="800" }
57-
58-
!!! info "Further Reading"
59-
- [Learn: Understanding the ontology service in pynxtools](../../learn/pynxtools/ontology-service.md)
61+
![Ontology results in NOMAD](../../assets/superclasses_results.png){ width="800" }

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +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)
53+
- [Use the ontology service](how-tos/pynxtools/ontology-service.md)
5454

5555
</div>
5656

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

7474
</div>
7575
<div markdown="block">

docs/learn/pynxtools/ontology-service.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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) "
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)."
44

55
## Introduction
66

@@ -16,9 +16,9 @@ By using these ontologies, the service maps NeXus application definitions to sta
1616

1717
## How it fits in pynxtools
1818

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.
19+
The `ontology service` only operates when `pynxtools` is run within `NOMAD`. It is registered as an [`ApiEntryPoint`](https://nomad-lab.eu/prod/v1/docs/reference/config.html#apientrypoint), which allows NOMAD to automatically discover and mount the FastAPI routes at startup. The service exposes [NeXus ontology](https://github.com/nexusformat/NeXusOntology) to users and connected systems.
2020

21-
## Core Concepts
21+
## Core concepts
2222

2323
- **Ontology**: A formal representation of concepts (classes), relationships, and properties, typically serialized as [OWL](https://www.w3.org/OWL/) files.
2424
- **Application definition**: A class or term describing an experimental technique in the NeXus (e.g., `NXmpes_arpes`).
@@ -27,24 +27,24 @@ This service only operates when `pynxtools` is run within `NOMAD`, exposing onto
2727

2828
Ontologies are represented as OWL files (e.g., `NeXusOntology_full_<commit>_inferred.owl`) and loaded using `owlready2`.
2929

30-
## Architecture & Design
30+
## Architecture & design
3131

32-
- **Main Modules**:
33-
- `pynxtools.nomad.apis.ontology_service`: FastAPI app, core logic for loading and querying ontologies.
34-
- `pynxtools.NeXusOntology.script.generate_ontology`: Generates ontology files from NeXus definitions.
35-
- `pynxtools.nomad.schema`: Initializes metainfo and schema integration.
36-
- **Key Classes/Functions**:
37-
- `load_ontology()`: Loads the inferred ontology file.
38-
- `fetch_superclasses(ontology, class_name)`: Retrieves superclasses for a given NeXus class.
39-
- `ensure_ontology_file()`: Ensures ontology file is present and up-to-date.
40-
- **Data Flow**:
41-
1. On startup, the service verifies whether the inferred ontology file exists; if absent, it runs the reasoner and generates the inferred ontology file.
42-
2. Inferred ontology is loaded via `owlready2`.
43-
3. API endpoints query this inferred ontology for relationships and metadata.
32+
- **Main modules**:
33+
- `pynxtools.nomad.apis.ontology_service`: FastAPI app, core logic for loading and querying ontologies.
34+
- `pynxtools.NeXusOntology.script.generate_ontology`: Generates ontology files from NeXus definitions.
35+
- `pynxtools.nomad.schema`: Initializes metainfo and schema integration.
36+
- **Key classes/functions**:
37+
- `load_ontology()`: Loads the inferred ontology file.
38+
- `fetch_superclasses(ontology, class_name)`: Retrieves superclasses for a given NeXus class.
39+
- `ensure_ontology_file()`: Ensures ontology file is present and up-to-date.
40+
- **Data flow**:
41+
- On startup, the service verifies whether the inferred ontology file exists; if absent, it runs the reasoner and generates the inferred ontology file.
42+
- Inferred ontology is loaded via `owlready2`.
43+
- API endpoints query this inferred ontology for relationships and metadata.
4444

45-
## Extensibility Points
45+
## Extensibility points
4646

47-
- Extend FastAPI routes in `ontology_service.py` for new queries.
47+
- Extend FastAPI routes in [`ontology_service.py`](https://github.com/FAIRmat-NFDI/pynxtools/blob/ontology-service/src/pynxtools/nomad/apis/ontology_service.py) for new queries.
4848

4949
## Examples
5050

0 commit comments

Comments
 (0)