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

Filename extensions: Allow specifying wildcards #1584

Merged
merged 26 commits into from
Feb 28, 2024

Conversation

franzpoeschel
Copy link
Contributor

@franzpoeschel franzpoeschel commented Jan 8, 2024

Close #1561

Diff: https://github.com/franzpoeschel/openPMD-api/compare/refactor-extract-bufferedactions..topic-wildcard-extension

Usage idea:

> bin/openpmd-pipe --infile ../samples/git-sample/3d-bp4/example-3d-bp4_%T.%E --outfile out.%E                                                              
Opening data source                                                                                                                                         
Opening data sink                                                                                                                                           
Traceback (most recent call last):                                                                                                                          
  File "/home/franzpoeschel/build/nbuild/bin/openpmd-pipe", line 17, in <module>                                                                            
    pipe.main()                                                                                                                                             
  File "/home/franzpoeschel/build/nbuild/lib/python3.11/site-packages/openpmd_api/pipe/__main__.py", line 366, in main                                      
    run_pipe.run()                                                                                                                                          
  File "/home/franzpoeschel/build/nbuild/lib/python3.11/site-packages/openpmd_api/pipe/__main__.py", line 211, in run                                       
    outseries = io.Series(self.outfile, io.Access.create,                                                                                                   
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                   
openpmd_api.openpmd_api_cxx.ErrorWrongAPIUsage: Wrong API usage: Unable to automatically determine filename extension. Please specify in some way.          
[~Series] An error occurred: fileBased output can not be written with no iterations.


> bin/openpmd-pipe --infile ../samples/git-sample/3d-bp4/example-3d-bp4_%T.%E --outfile out.%E --outconfig 'backend = "hdf5"'
Opening data source
Opening data sink
Opened input and output
Iteration 550 contains 9 meshes:
         B
         E
         e_all_chargeDensity
         e_all_energyDensity
         e_all_particleMomentumComponent
         i_all_chargeDensity
         i_all_energyDensity
         i_all_particleMomentumComponent
         picongpu_idProvider

Iteration 550 contains 2 particle species:
[…]


> ls 
out.h5


> bin/openpmd-ls out.%E                                  
openPMD series: out
openPMD standard: 1.1.0
openPMD extensions: 0

data author: unknown
data created: 2021-07-15 13:51:27 +0000 
data backend: HDF5
generating machine: unknown
generating software: PIConGPU (version: 0.6.0-dev)
generating software dependencies: unknown

number of iterations: 2 (groupBased)
  all iterations: 550 600 

number of meshes: 0 # this is a bug

number of particle species: 2
  all particle species:
    e
    i



> bin/openpmd-pipe --infile ../samples/git-sample/3d-bp4/example-3d-bp4_%T.%E --outfile out.%E --outconfig 'backend = "adios2"'
Opening data source
Opening data sink
Opened input and output
Iteration 550 contains 9 meshes:
         B
         E
         e_all_chargeDensity
         e_all_energyDensity
         e_all_particleMomentumComponent
         i_all_chargeDensity
         i_all_energyDensity
         i_all_particleMomentumComponent
         picongpu_idProvider

Iteration 550 contains 2 particle species:



> ls 
out.bp
out.h5



> bin/openpmd-ls out.%E            
An error occurred while opening the specified openPMD series!
Read Error in frontend 
Object type:    File
Error type:     Other
Further description:    Found ambiguous filename extensions on disk: '.h5' and '.bp'.

Todo:

  • Testing
  • Documentation
  • (Maybe) Adapt for Linear and Append access types
  • Fix (probably unrelated) bug found in openpmd-pipe

Access at,
std::string const &options,
// Either an MPI_Comm or none, the template works for both options
MPI_Communicator &&...comm)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable comm is not used.
@franzpoeschel franzpoeschel force-pushed the topic-wildcard-extension branch from 75949da to 4708900 Compare January 18, 2024 17:43

void markActive(Writable *);

// bool isActive(std::string const & path);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@@ -1180,6 +1181,98 @@
"../samples/optionsViaJsonPseudoFilebased%T.json"));
}

TEST_CASE("wildcard_extension", "[core]")

Check notice

Code scanning / CodeQL

Unused static function Note test

Static function C_A_T_C_H_T_E_S_T_44 is unreachable (
autoRegistrar45
must be removed at the same time)
@franzpoeschel franzpoeschel requested a review from ax3l January 19, 2024 16:41
@franzpoeschel franzpoeschel force-pushed the topic-wildcard-extension branch 2 times, most recently from 38edc16 to 7d3d398 Compare January 23, 2024 16:58
* @brief Construct a new Series
*
* @param filepath The backend will be determined by the filepath extension.
* @brief Construct a new Series.
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a .. tip:: in the First Read overview:
https://openpmd-api.readthedocs.io/en/latest/usage/firstread.html#open

That explains %T and %E in 1-2 sentences.

Copy link
Member

Choose a reason for hiding this comment

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

.. tip::

   Use the wildcards `%T` to match filename encoded iterations and `%E` to match supported extensions such as `.h5` and `.bp`.

Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

This is awesome. Please add the .. tip:: and then we ready.

@franzpoeschel franzpoeschel force-pushed the topic-wildcard-extension branch from adc9ed8 to d19a50b Compare February 28, 2024 14:08
@franzpoeschel franzpoeschel enabled auto-merge (squash) February 28, 2024 14:51
@franzpoeschel franzpoeschel force-pushed the topic-wildcard-extension branch from aa673d2 to 8212999 Compare February 28, 2024 14:52
@franzpoeschel franzpoeschel merged commit c2e0e83 into openPMD:dev Feb 28, 2024
31 checks passed
@PrometheusPi
Copy link
Member

Thanks for implementing that file ending wild card @franzpoeschel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series: Open with Placeholder for File-Ending/Backend
3 participants