-
Notifications
You must be signed in to change notification settings - Fork 194
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
Fix checkpoint with runtime components through the Python interface. #2332
Conversation
The script in the original issue now verifies that the runtime attributes were added correctly, so it looks like this fixes it! |
@atmyers ready for rebase :) |
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
@@ -159,8 +159,35 @@ FlushFormatCheckpoint::CheckpointParticles ( | |||
const amrex::Vector<ParticleDiag>& particle_diags) const | |||
{ | |||
for (unsigned i = 0, n = particle_diags.size(); i < n; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this function and potentially after this look, we probably also need to treat the laser particles to write our their positions
cc @RemiLehe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support for this is added in PR #2360 - I recommend we merge that PR first, then rebase this one.
The current implementation looks good to me. Can we design or repurpose an existing test to cover this permanently? :) |
I'm not sure about an existing test, although the script in #2295 is a nice and clean way of demonstrating that this works correctly. |
LGTM, it's short and small. let's add this one? :) |
I have now added a CI test for this, based on the original script from modern electron. |
@@ -1085,6 +1086,10 @@ def initialize_inputs(self): | |||
self.diagnostic.diag_type = 'Full' | |||
self.diagnostic.format = 'checkpoint' | |||
|
|||
if self.write_dir is not None or self.file_prefix is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to modify the Python interface a bit here so that Checkpoint files could be configured to use a custom file prefix, as needed by the regression testing suite. Maybe @dpgrote could weigh in on whether this is the right way to fix this?
I could also split this into a separate PR, if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think you can even remove the if
line here with the logic in the next two lines
Let's also add an inline comment to document the need for this modification, otherwise this convention looks a bit magical to future readers
This pull request introduces 1 alert when merging 2a1bfff into fb2ef4c - view on LGTM.com new alerts:
|
if self.write_dir is not None or self.file_prefix is not None: | ||
write_dir = (self.write_dir or 'diags') | ||
file_prefix = (self.file_prefix or self.name) | ||
self.diagnostic.file_prefix = write_dir + '/' + file_prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.write_dir is not None or self.file_prefix is not None: | |
write_dir = (self.write_dir or 'diags') | |
file_prefix = (self.file_prefix or self.name) | |
self.diagnostic.file_prefix = write_dir + '/' + file_prefix | |
# use checkpoint naming scheme expected by WarpX regression test suite | |
write_dir = (self.write_dir or 'diags') | |
file_prefix = (self.file_prefix or self.name) | |
self.diagnostic.file_prefix = write_dir + '/' + file_prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really specific to the test suite - the other diagnostic types FieldDiagnostic and ParticleDiagnostic already let you pass in a custom file prefix for whatever reason you want, as you can in the C++ interface. This just makes the Checkpoints behave the same way. This if
block is basically just copied from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks good. My preference is to keep the if
check - this is a subtle difference but with the if
, diagnostic.file_prefix
won't be set if write_dir
and file_prefix
are not set and so it will rely on its default value in the C++ (this avoids having a default value defined in two different places).
I just noticed this - it should be self.diagnostic.file_prefix = os.path.join(write_dir, file_prefix)
to be proper Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - I'll issue a follow-up PR to change the + '/' +
, I think the modern electron folks are waiting on this one to be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this, that's great!
The patch & test looks generally good to me.
Comment on the Python side and just double-checking the extra SoA attributes for ionization/QED are there.
Fix #2295.
Specifically, this makes three changes: