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

Integration nexus file #147

Closed
wants to merge 111 commits into from
Closed

Conversation

RubelMozumder
Copy link
Contributor

@RubelMozumder RubelMozumder commented Dec 19, 2024

Summary by Sourcery

Implement Nexus file generation for XRD measurements.

PR #116 handled in #118 and #147.

aalbino2 and others added 30 commits November 25, 2024 11:42
Co-authored-by: Sarthak Kapoor <[email protected]>
Co-authored-by: Hampus Näsström <[email protected]>
* Implement write nexus section based on the populated nomad archive

* app def missing.

* mapping nomad_measurement.

* All concept are connected, creates nexus file and subsection.

* adding links in hdf5 file.

* Remove the nxs file.

* back to the previous design.

* Include pynxtools plugins in nomad.yaml and extend dependencies including pynxtools ans pnxtools-xrd.

* PR review correction.

* Remove the entry_type overwtitten.

* Remove comments.

* Replace __str__ function.

* RUFF

* Update pyproject.toml

Co-authored-by: Sarthak Kapoor <[email protected]>

* Update src/nomad_measurements/xrd/schema.py

Co-authored-by: Sarthak Kapoor <[email protected]>

* Update src/nomad_measurements/xrd/nx.py

* Replace Try-block.

---------

Co-authored-by: Sarthak Kapoor <[email protected]>
Co-authored-by: Sarthak Kapoor <[email protected]>
Co-authored-by: Sarthak Kapoor <[email protected]>
Co-authored-by: Hampus Näsström <[email protected]>
Copy link

sourcery-ai bot commented Dec 19, 2024

Reviewer's Guide by Sourcery

This pull request integrates the nexus file generation into the XRD processing pipeline. It introduces functions to map NOMAD concepts to NeXus paths, populate datasets and attributes, and handle unit conversions. It also updates the _write_nx_file method to generate the nexus file using the populated data and a template based on the NXxrd_pan application definition.

Sequence diagram for NeXus file generation process

sequenceDiagram
    participant Archive as NOMAD Archive
    participant Writer as NX Writer
    participant Template as NeXus Template
    participant File as NeXus File

    Writer->>Template: generate_template_from_nxdl()
    Writer->>Archive: populate_nx_dataset_and_attribute()
    Archive-->>Writer: Return datasets and attributes
    Writer->>Template: Add datasets to template
    Writer->>Template: Add attributes to template
    Writer->>File: Write NeXus file using template
    Writer->>Archive: Update file references
Loading

Class diagram for NeXus integration components

classDiagram
    class DatasetModel {
        +data: Any
        +internal_reference: Optional[bool]
        +archive_path: Optional[str]
    }

    class Writer {
        -_hdf5_datasets: dict
        -_hdf5_attributes: dict
        +_write_nx_file()
        +_write_hdf5_file()
        -_remove_nexus_annotations()
        -_set_hdf5_reference()
    }

    class Template {
        +dict data
        +dict optional
    }

    Writer --> DatasetModel : uses
    Writer --> Template : uses
    note for Writer "Handles NeXus file generation"
    note for DatasetModel "Stores dataset information"
Loading

File-Level Changes

Change Details Files
Implementation of nexus file generation.
  • Added functions to map NOMAD archive data to NeXus datasets and attributes.
  • Added functions to handle unit conversions for NeXus attributes.
  • Added functions to create nexus groups and handle optional data.
  • Implemented nexus file writing using pynxtools.
  • Updated _write_nx_file to generate nexus file with archive data.
src/nomad_measurements/xrd/nx.py
src/nomad_measurements/utils.py
Introduction of new dependencies and type annotations.
  • Added type annotations for improved code clarity.
  • Introduced new dependencies like pint for unit handling and pydantic for data validation.
src/nomad_measurements/xrd/nx.py
Updated nexus dataset paths.
  • Added new paths to NEXUS_DATASET_PATHS to accommodate the new data being written to the nexus file.
src/nomad_measurements/xrd/nx.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @RubelMozumder - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Remove the outdated TODO comments in _write_nx_file() since they have been implemented
  • Consider adding more specific error messages when NeXus file generation fails to help with debugging
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src/nomad_measurements/xrd/nx.py Show resolved Hide resolved
src/nomad_measurements/utils.py Outdated Show resolved Hide resolved
src/nomad_measurements/xrd/nx.py Outdated Show resolved Hide resolved
src/nomad_measurements/utils.py Outdated Show resolved Hide resolved
src/nomad_measurements/xrd/nx.py Outdated Show resolved Hide resolved
src/nomad_measurements/xrd/nx.py Outdated Show resolved Hide resolved
src/nomad_measurements/xrd/nx.py Outdated Show resolved Hide resolved
Base automatically changed from use-hdf5-references-for-arrays to write-nexus-section December 19, 2024 14:55
@ka-sarthak ka-sarthak mentioned this pull request Dec 19, 2024
6 tasks
@ka-sarthak ka-sarthak marked this pull request as draft December 19, 2024 15:56
@RubelMozumder
Copy link
Contributor Author

This PR replaced by #150 .

@RubelMozumder RubelMozumder deleted the Integration_nexus_file branch December 20, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants