Skip to content

Commit

Permalink
Merge branch 'bring-in-examples' of github.com:FAIRmat-NFDI/pynxtools…
Browse files Browse the repository at this point in the history
…-mpes into bring-in-examples
  • Loading branch information
lukaspie committed Oct 11, 2024
2 parents f5fdcce + 7e9558f commit 960d3ca
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uv pip install -r dev-requirements.txt
- name: ruff check
run: |
ruff check pynxtools_mpes tests
ruff check src/pynxtools_mpes tests
- name: ruff format
run: |
ruff format --check pynxtools_mpes tests
ruff format --check src/pynxtools_mpes tests
- name: mypy
run: |
mypy pynxtools_mpes tests
mypy src/pynxtools_mpes tests
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
prune *
exclude *
recursive-include pynxtools_mpes *.py
include pyproject.toml README.md dev-requirements.txt
recursive-include src/pynxtools_mpes *.py
include pyproject.toml README.md dev-requirements.txt
recursive-include src/pynxtools_mpes/nomad/examples
2 changes: 1 addition & 1 deletion docs/reference/mpes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The reader supports [HDF5](https://www.hdfgroup.org/solutions/hdf5/) files created using the MPES instruments at the Department of Physical Chemistry of the [Fritz Haber Institute of the Max Planck Society (FHI)](https://pc.fhi-berlin.mpg.de).

The reader for can be found [here](https://github.com/FAIRmat-NFDI/pynxtools-mpes/blob/main/pynxtools_mpes/reader.py).
The reader for can be found [here](https://github.com/FAIRmat-NFDI/pynxtools-mpes/blob/main/src/pynxtools_mpes/reader.py).

Example data for the MPES reader is available [here](https://github.com/FAIRmat-NFDI/pynxtools-mpes/tree/main/tests/data).

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nav:
plugins:
- search
- macros:
module_name: pynxtools_mpes/mkdocs
module_name: src/pynxtools_mpes/mkdocs

theme:
name: material
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ docs = [
[project.entry-points."pynxtools.reader"]
mpes = "pynxtools_mpes.reader:MPESReader"

[tool.setuptools]
packages = ["pynxtools_mpes"]
[project.entry-points.'nomad.plugin']
mpes_example = "pynxtools_mpes.nomad.entrypoints:mpes_example"

[tool.setuptools.packages.find]
where = [
"src",
]

[tool.setuptools_scm]

[tool.ruff]
include = ["pynxtools_mpes/*.py", "tests/*.py"]
include = ["src/*.py", "tests/*.py"]
line-length = 88
indent-width = 4

Expand Down
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions src/pynxtools_mpes/nomad/entrypoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Entry points for mpes examples."""

try:
from nomad.config.models.plugins import ExampleUploadEntryPoint
except ImportError as exc:
raise ImportError(
"Could not import nomad package. Please install the package 'nomad-lab'."
) from exc

mpes_example = ExampleUploadEntryPoint(
title="Multidimensional photoemission spectroscopy (MPES)",
category="FAIRmat examples",
description="""
This example presents the capabilities of the NOMAD platform to store and standardize multidimensional photoemission spectroscopy (MPES) experimental data. It contains three major examples:
- Taking a pre-binned file, here stored in a h5 file, and converting it into the standardized MPES NeXus format.
There exists a [NeXus application definition for MPES](https://manual.nexusformat.org/classes/contributed_definitions/NXmpes.html#nxmpes) which details the internal structure of such a file.
- Binning of raw data (see [here](https://www.nature.com/articles/s41597-020-00769-8) for additional resources) into a h5 file and consecutively generating a NeXus file from it.
- An analysis example using data in the NeXus format and employing the [pyARPES](https://github.com/chstan/arpes) analysis tool to reproduce the main findings of [this paper](https://arxiv.org/pdf/2107.07158.pdf).
""",
path="nomad/examples",
local_path="examples/data/uploads/mpes.zip",
)
File renamed without changes.
62 changes: 62 additions & 0 deletions tests/test_nomad_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Test for NOMAD examples in reader plugins."""

import pytest

try:
from nomad.parsing.parser import ArchiveParser
from nomad.datamodel import EntryArchive, Context
except ImportError:
pytest.skip(
"Skipping NOMAD example tests because nomad is not installed",
allow_module_level=True,
)

from pynxtools.testing.nomad_example import get_file_parameter, test_nomad_example


@pytest.mark.parametrize(
"mainfile", get_file_parameter("../src/pynxtools_mpes/nomad/examples")
)
def test_nomad_examples(mainfile, no_warn):
"""Test if NOMAD examples work."""
test_nomad_example(mainfile)


@pytest.mark.parametrize(
"config, expected_local_path",
[
pytest.param(
{
"title": "mpes_example",
"description": "mpes_example",
"category": "test",
"path": "nomad/examples",
},
f"examples/data/uploads/mpes.zip",
id="mpes_example",
),
],
)
def test_nomad_example_upload_entry_point_valid(config, expected_local_path):
test_example_upload_entry_point_valid(
plugin_package="pynxtools-mpes",
config=config,
expected_local_path=expected_local_path,
)
19 changes: 18 additions & 1 deletion tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Basic example based test for the stm reader
Basic example based test for the MPES reader
"""

from pathlib import Path
Expand Down

0 comments on commit 960d3ca

Please sign in to comment.