Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New attempt: map to NOMAD basesections #419

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d7b7bf2
import basesections
lukaspie Sep 2, 2024
017ea57
initiate base section map
lukaspie Sep 2, 2024
f15f3d3
implement mapping in __to_section
lukaspie Sep 2, 2024
609c688
type hinting
lukaspie Sep 2, 2024
8ac181f
name testing
lukaspie Sep 2, 2024
55a4949
create own basesections with mapping
lukaspie Sep 2, 2024
f456c44
dynamically create class that inherits from base section
lukaspie Sep 2, 2024
7fcabc5
use base section mapping function
lukaspie Sep 2, 2024
83c90f8
add base section directly
lukaspie Sep 3, 2024
c3f9308
rename nexus to nomad.
RubelMozumder Sep 3, 2024
4e4057f
rename nexus to nomad.
RubelMozumder Sep 3, 2024
98e15a0
harmonize collaborative work, functionality to get the correct defini…
lukaspie Sep 3, 2024
ed958dd
rename file with remote definitions url
lukaspie Sep 3, 2024
cec3753
add .txt to MANIFEST
lukaspie Sep 3, 2024
32d2ddc
test for definitions url retrieval
lukaspie Sep 3, 2024
b3d978f
remove unneeded function
lukaspie Sep 3, 2024
6ab0ce4
Fix error Parsing NeXus file: Error from resolve_variadic_name function.
RubelMozumder Sep 3, 2024
edace9c
Test effort to fix error in parsing nexus file.
RubelMozumder Sep 4, 2024
906f593
revert changes to parser
lukaspie Sep 4, 2024
d71fdc4
revert changes to parser
lukaspie Sep 4, 2024
6bbcfdf
Nomad BaseSeection implemented properly.
RubelMozumder Sep 5, 2024
f5de6c9
Attempt: Add normalize function.
RubelMozumder Sep 5, 2024
ce39260
linting fix
lukaspie Sep 6, 2024
e88f39a
reorganize, dont use new classes
lukaspie Sep 6, 2024
23f3a1c
implement both options
lukaspie Sep 6, 2024
cc7b419
tests in schema.py
GinzburgLev Sep 6, 2024
6b7a661
reasonable test for normalizing NXfabrication
sanbrock Sep 7, 2024
1cb5195
ruff formatting
lukaspie Sep 9, 2024
8019a73
initial work on NXsample normalization
lukaspie Sep 9, 2024
936c5c8
Attempt to reference NXsample.
RubelMozumder Sep 9, 2024
c73d58b
lab_id can be populated properly, nut not sure CompositeSystemReferen…
RubelMozumder Sep 9, 2024
b28c1d8
reference to compositeSystem.
RubelMozumder Sep 10, 2024
67610dd
multiple inheritance.
RubelMozumder Sep 10, 2024
acb4591
Just save.
RubelMozumder Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cython_debug/
!dev-requirements.txt
!mkdocs-requirements.txt
!src/pynxtools/nexus-version.txt
!src/pynxtools/remote_definitions_url.txt
build/
nexusparser.egg-info/PKG-INFO
.python-version
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ recursive-include src/pynxtools/definitions/applications/ *.xml
recursive-include src/pynxtools/definitions/contributed_definitions/ *.xml
include src/pynxtools/definitions/*.xsd
include src/pynxtools/nexus-version.txt
include src/pynxtools/definitions/NXDL_VERSION

include src/pynxtools/remote_definitions_url.txt
include src/pynxtools/definitions/NXDL_VERSION
7 changes: 7 additions & 0 deletions src/pynxtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ def get_nexus_version_hash() -> str:
return MAIN_BRANCH_NAME

return version.group(1)


def get_definitions_url() -> str:
"""Get the URL of the NeXus definitions that are submoduled in pynxtools."""
url_file = os.path.join(os.path.dirname(__file__), "remote_definitions_url.txt")
with open(url_file, encoding="utf-8") as file:
return file.read().strip()
54 changes: 52 additions & 2 deletions src/pynxtools/_build_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,71 @@ def _write_version_to_metadata():
file.write(version)


def get_definitions_submodule_url():
"""
The URL of the definitions submodule in pynxtools.
"""
submodule_path = "src/pynxtools/definitions"

try:
# Define the command to run
url_line = run(
[
"git",
"config",
"--file",
".git/config",
"--get-regexp",
f"^submodule\\.{submodule_path}\\.url",
],
text=True,
capture_output=True,
check=True,
).stdout.strip()

if url_line:
url = url_line.split(" ")[1]
return url
else:
return None

except (FileNotFoundError, CalledProcessError):
return None


def _write_definitions_remote_url():
"""Write the URL of the definitions remote to file."""
remote_repo_url = get_definitions_submodule_url()
if remote_repo_url is None or not remote_repo_url:
return

with open(
os.path.join(os.path.dirname(__file__), "remote_definitions_url.txt"),
"w+",
encoding="utf-8",
) as file:
file.write(remote_repo_url)


# pylint: disable=function-redefined
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
"""
PEP 517 compliant build wheel hook.
This is a wrapper for setuptools and adds a nexus version file.
This is a wrapper for setuptools and adds a nexus version file and a
file with the remote of the definitions submodule.
"""
_write_version_to_metadata()
_write_definitions_remote_url()
return _orig.build_wheel(wheel_directory, config_settings, metadata_directory)


# pylint: disable=function-redefined
def build_sdist(sdist_directory, config_settings=None):
"""
PEP 517 compliant build sdist hook.
This is a wrapper for setuptools and adds a nexus version file.
This is a wrapper for setuptools and adds a nexus version file and a
file with the remote of the definitions submodule.
"""
_write_version_to_metadata()
_write_definitions_remote_url()
return _orig.build_sdist(sdist_directory, config_settings)
1 change: 0 additions & 1 deletion src/pynxtools/nomad/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def _populate_data(
target_name=attr_name,
exc_info=exc,
)

if parent_field_name in current.__dict__:
quantity = current.__dict__[parent_field_name]
if isinstance(quantity, dict):
Expand Down
Loading
Loading