File tree Expand file tree Collapse file tree 9 files changed +59
-21
lines changed
Expand file tree Collapse file tree 9 files changed +59
-21
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,11 @@ int main()
3434# be passed by adding an at-sign `@` in front of the path
3535# The format will then be recognized by filename extension, i.e. .json or .toml
3636
37- backend = "adios2 "
37+ backend = "hdf5 "
3838iteration_encoding = "group_based"
3939# The following is only relevant in read mode
4040defer_iteration_parsing = true
4141
42- [adios1.dataset]
43- transform = "blosc:compressor=zlib,shuffle=bit,lvl=5;nometa"
44-
4542[adios2.engine]
4643type = "bp4"
4744
@@ -60,13 +57,18 @@ parameters.clevel = 5
6057# type = "some other parameter"
6158# # ...
6259
63- [hdf5.dataset]
64- chunks = "auto"
60+ [[hdf5.dataset]]
61+ cfg.chunks = "auto"
62+
63+ [[hdf5.dataset]]
64+ select = "particles/e/.*"
65+ cfg.chunks = [10]
66+ cfg.chornks = []
6567)END" ;
6668
6769 // open file for writing
6870 Series series =
69- Series (" ../samples/dynamicConfig.bp " , Access::CREATE, defaults);
71+ Series (" ../samples/dynamicConfig.h5 " , Access::CREATE, defaults);
7072
7173 Datatype datatype = determineDatatype<position_t >();
7274 constexpr unsigned long length = 10ul ;
@@ -103,11 +105,6 @@ chunks = "auto"
103105 std::string const differentCompressionSettings = R"END(
104106{
105107 "resizable": true,
106- "adios1": {
107- "dataset": {
108- "transform": "blosc:compressor=zlib,shuffle=bit,lvl=1;nometa"
109- }
110- },
111108 "adios2": {
112109 "dataset": {
113110 "operators": [
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ namespace openPMD
4242{
4343class Attributable ;
4444class Writable ;
45+ namespace json
46+ {
47+ class JsonMatcher ;
48+ }
4549
4650Writable *getWritable (Attributable *);
4751
@@ -355,6 +359,10 @@ struct OPENPMDAPI_EXPORT Parameter<Operation::CREATE_DATASET>
355359 TracingJSON &,
356360 std::string const ¤tBackendName,
357361 std::string const &warningMessage);
362+
363+ template <typename TracingJSON>
364+ TracingJSON
365+ compileJSONConfig (Writable const *writable, json::JsonMatcher &) const ;
358366};
359367
360368template <>
Original file line number Diff line number Diff line change @@ -32,12 +32,7 @@ struct Pattern
3232 std::regex pattern;
3333 nlohmann::json config;
3434
35- Pattern (std::string const &pattern_in, nlohmann::json config_in)
36- // we construct the patterns once and use them often, so let's ask for
37- // some optimization
38- : pattern{pattern_in, std::regex_constants::egrep | std::regex_constants::optimize}
39- , config{std::move (config_in)}
40- {}
35+ Pattern (std::string const &pattern_in, nlohmann::json config_in);
4136};
4237
4338/* *
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ class Attributable
157157 friend class WriteIterations ;
158158 friend class internal ::RecordComponentData;
159159 friend void debug::printDirty (Series const &);
160+ friend class internal ::AttributableData;
160161
161162protected:
162163 // tag for internal constructor
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ class Writable final
101101 template <typename >
102102 friend class Span ;
103103 friend void debug::printDirty (Series const &);
104+ friend struct Parameter <Operation::CREATE_DATASET>;
104105
105106private:
106107 Writable (internal::AttributableData *);
Original file line number Diff line number Diff line change 3131#include " openPMD/auxiliary/Environment.hpp"
3232#include " openPMD/auxiliary/Filesystem.hpp"
3333#include " openPMD/auxiliary/JSONMatcher.hpp"
34+ #include " openPMD/auxiliary/JSON_internal.hpp"
3435#include " openPMD/auxiliary/Mpi.hpp"
3536#include " openPMD/auxiliary/StringManip.hpp"
3637#include " openPMD/auxiliary/TypeTraits.hpp"
@@ -755,7 +756,8 @@ void ADIOS2IOHandlerImpl::createDataset(
755756
756757 std::vector<ParameterizedOperator> operators;
757758 json::TracingJSON options =
758- json::parseOptions (parameters.options , /* considerFiles = */ false );
759+ parameters.compileJSONConfig <json::ParsedConfig>(
760+ writable, *m_handler->jsonMatcher );
759761 if (options.json ().contains (" adios2" ))
760762 {
761763 json::TracingJSON datasetConfig (options[" adios2" ]);
Original file line number Diff line number Diff line change @@ -496,8 +496,9 @@ void HDF5IOHandlerImpl::createDataset(
496496 nlohmann::json::parse (mask_for_global_conf));
497497 }
498498 auto const &buffered_config = *m_buffered_dataset_config;
499- auto parsed_config = json::parseOptions (
500- parameters.options , /* considerFiles = */ false );
499+ auto parsed_config =
500+ parameters.compileJSONConfig <json::ParsedConfig>(
501+ writable, *m_handler->jsonMatcher );
501502 if (auto hdf5_config_it = parsed_config.config .find (" hdf5" );
502503 hdf5_config_it != parsed_config.config .end ())
503504 {
Original file line number Diff line number Diff line change 1919 * If not, see <http://www.gnu.org/licenses/>.
2020 */
2121#include " openPMD/IO/IOTask.hpp"
22+ #include " openPMD/auxiliary/JSONMatcher.hpp"
2223#include " openPMD/auxiliary/JSON_internal.hpp"
2324#include " openPMD/backend/Attributable.hpp"
2425
@@ -73,6 +74,23 @@ void Parameter<Operation::CREATE_DATASET>::warnUnusedParameters<
7374 }
7475}
7576
77+ template <>
78+ json::ParsedConfig Parameter<Operation::CREATE_DATASET>::compileJSONConfig(
79+ Writable const *writable, json::JsonMatcher &jsonMatcher) const
80+ {
81+ auto attri = writable->attributable ->asInternalCopyOf <Attributable>();
82+ auto path = attri.myPath ().openPMDPath ();
83+ auto base_config = jsonMatcher.get (path);
84+ auto manual_config =
85+ json::parseOptions (options, /* considerFiles = */ false );
86+ json::merge (base_config.config , manual_config.config );
87+ return json::ParsedConfig{
88+ std::move (base_config.config ),
89+ (options.empty () || options == " {}" )
90+ ? manual_config.originallySpecifiedAs
91+ : base_config.originallySpecifiedAs };
92+ }
93+
7694namespace internal
7795{
7896 std::string operationAsString (Operation op)
Original file line number Diff line number Diff line change 11#include " openPMD/auxiliary/JSONMatcher.hpp"
22#include " openPMD/Error.hpp"
33#include " openPMD/auxiliary/JSON_internal.hpp"
4+
45#include < nlohmann/json.hpp>
6+ #include < sstream>
57
68namespace openPMD ::json
79{
@@ -27,6 +29,19 @@ namespace
2729 nlohmann::json object) -> void;
2830} // namespace
2931
32+ Pattern::Pattern (std::string const &pattern_in, nlohmann::json config_in)
33+ : config(std::move(config_in))
34+ {
35+ // transform the regex such that the path to the Iteration is optional
36+ std::stringstream build_pattern;
37+ build_pattern << " (/data/[0-9]+/)?(" << pattern_in << " )" ;
38+ // we construct the patterns once and use them often, so let's ask for
39+ // some optimization
40+ pattern = std::regex (
41+ build_pattern.str (),
42+ std::regex_constants::egrep | std::regex_constants::optimize);
43+ }
44+
3045void MatcherPerBackend::init (TracingJSON tracing_config)
3146{
3247 auto &config = tracing_config.json ();
You can’t perform that action at this time.
0 commit comments