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

Correct typing of TaskDoc.run_stats, add number of electronic steps per ionic step to TaskDoc #1167

Merged
merged 15 commits into from
Jan 9, 2025

Conversation

esoteric-ephemera
Copy link
Collaborator

@esoteric-ephemera esoteric-ephemera commented Jan 3, 2025

Closes two issues:

  • 1165 by correcting the pydantic field typing of TaskDoc.run_stats
  • 1065 by adding a num_electronic_steps to emmet.core.vasp.calculation.{IonicStep, CalculationOutput}. The number of electronic steps in each ionic step is accessible via TaskDoc.calcs_reversed[...].output.num_electronic_steps.
  • Bad force unit in VASP OutputDoc #1035 by correcting the unit of force in emmet.core.tasks.OutputDoc to eV/Å (this was just a typo, the output in VASP defaults to eV/Å for force units)

Should also fix some pydantic-related issues

@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 88.63636% with 5 lines in your changes missing coverage. Please review.

Project coverage is 90.32%. Comparing base (b8d8222) to head (84d4b22).
Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
emmet-core/emmet/core/feff/task.py 0.00% 2 Missing ⚠️
emmet-core/emmet/core/defect.py 75.00% 1 Missing ⚠️
emmet-core/emmet/core/tasks.py 85.71% 1 Missing ⚠️
emmet-core/emmet/core/xas.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1167       +/-   ##
===========================================
+ Coverage   72.25%   90.32%   +18.06%     
===========================================
  Files          77      147       +70     
  Lines        5136    14509     +9373     
===========================================
+ Hits         3711    13105     +9394     
+ Misses       1425     1404       -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@esoteric-ephemera esoteric-ephemera changed the title Correct typing of TaskDoc.run_stats Correct typing of TaskDoc.run_stats, add number of electronic steps per ionic step to TaskDoc Jan 3, 2025
@esoteric-ephemera
Copy link
Collaborator Author

@tschaume @tsm should be ready for review whenever you get a chance

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

looks great, thanks @esoteric-ephemera! 👍

only some minor suggestions and maybe a unit test for the new num_electronic_steps

@@ -434,7 +434,7 @@ class TaskDoc(StructureMetadata, extra="allow"):
description="Identifier for this calculation; should provide rough information about the calculation origin and purpose.",
)

run_stats: Optional[RunStatistics] = Field(
run_stats: Optional[dict[str, RunStatistics]] = Field(
Copy link
Member

Choose a reason for hiding this comment

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

type annotation uses dict instead of Mapping which is used elsewhere in the codebase for similar cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to mapping, also added some basic tests to the TaskDoc tests - we don't have specific unit tests for IonicStep, would make sense to add these in a later PR if needed

Comment on lines 353 to 357
@model_validator(mode="after")
def set_elec_step_count(self):
if self.electronic_steps is not None and self.num_electronic_steps is None:
self.num_electronic_steps = len(self.electronic_steps)
return self
Copy link
Member

Choose a reason for hiding this comment

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

maybe handle the case where num_electronic_steps is set but doesn't match len(electronic_steps). probably len(electronic_steps) should take precedence or an error be raised if there's such a thing as a strict mode

Copy link
Member

Choose a reason for hiding this comment

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

could also validate that num_electronic_steps is non-negative

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @janosh - think I would lean towards always overwriting the value of num_electronic_steps. We do the same now with run / task / calc type to ensure that they're always up to date with parsing changes

That should also take care of the negative number of steps

Copy link
Member

@tschaume tschaume left a comment

Choose a reason for hiding this comment

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

Looks good! Just have a few minor questions for some of the if conditions.

emmet-core/emmet/core/feff/task.py Show resolved Hide resolved
emmet-core/emmet/core/tasks.py Outdated Show resolved Hide resolved
emmet-core/emmet/core/vasp/calculation.py Show resolved Hide resolved
emmet-core/emmet/core/vasp/calculation.py Show resolved Hide resolved
@esoteric-ephemera
Copy link
Collaborator Author

@tschaume OK if I merge?

@tschaume
Copy link
Member

tschaume commented Jan 9, 2025

Yes, looks good, go ahead. We can do a release candidate to test the changes in the builders before a full release.

@esoteric-ephemera esoteric-ephemera merged commit 943574d into materialsproject:main Jan 9, 2025
8 checks passed
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.

4 participants