Feature/sina/append functionality#1542
Conversation
…eave/axom into append_functionality
|
@kennyweiss @cyrush @rhornung67 I think @HaluskaR is done. The PR looks good and I think is ready for you to give it a final review. Thanks @HaluskaR |
@doutriaux1 please approve if you think it is ready to merge. When you approve, we will do our final reviews. Thank you. |
|
This PR needs to be squash merged when done!!! |
doutriaux1
left a comment
There was a problem hiding this comment.
@HaluskaR if the pngs I commented on are good and if you adressed @kennyweiss requested change then I'm good with this Pr.
There was a problem hiding this comment.
Good catch. Yes, those are the original results, but the pngs don't seem to be referenced from anywhere, might be how I overlooked them...remove for now and add a few pics from the presentation once that's up and ready to share around? It'd be nice to draw them from "real" data/use cases
|
@kennyweiss @white238 @rhornung67 I think this is ready to go. @HaluskaR we're good right? |
|
@LLNL/axom please review/merge |
kennyweiss
left a comment
There was a problem hiding this comment.
Looks like this is almost ready.
Please address the review, and also update the RELEASE_NOTES with the changes in this PR.
Please also update the RELEASE_NOTES for the changes in #1559 (we forgot to do that).
| // String of a new Doc to use for appending | ||
| std::string new_data = | ||
| "{\"records\": [" | ||
| " {" | ||
| " \"type\": \"foo1\"," | ||
| " \"id\": \"bar1\"," | ||
| " \"data\": {\"scal1\": {\"value\": \"goodbye!\"}, \"scal2\": {\"value\": \"goodbye!\"}}," | ||
| " \"user_defined\":{\"hello\": \"goodbye\"}," | ||
| " \"curve_sets\": {" | ||
| " \"1\": {" | ||
| " \"dependent\": {" | ||
| " \"0\": {\"value\": [1, 1]}," | ||
| " \"1\": {\"value\": [8, 9]}" | ||
| " }," | ||
| " \"independent\": {" | ||
| " \"0\": {\"value\": [4, 5]}," | ||
| " \"1\": {\"value\": [7, 9]}" | ||
| " }" | ||
| " }," | ||
| " \"2\": {" | ||
| " \"dependent\": {" | ||
| " \"0\": {\"value\": [1, 1]}," | ||
| " \"1\": {\"value\": [10, 10]}" | ||
| " }," | ||
| " \"independent\": {" | ||
| " \"0\": {\"value\": [4, 4]}," | ||
| " \"1\": {\"value\": [7, 7]}" | ||
| " }" | ||
| " }" | ||
| " }" | ||
| " }," | ||
| " {" | ||
| " \"type\": \"foo2\"," | ||
| " \"id\": \"bar3\"," | ||
| " \"curve_sets\": {" | ||
| " \"1\": {" | ||
| " \"dependent\": {" | ||
| " \"0\": {\"value\": [1, 1]}," | ||
| " \"1\": {\"value\": [10, 10]}" | ||
| " }," | ||
| " \"independent\": {" | ||
| " \"0\": {\"value\": [4, 4]}," | ||
| " \"1\": {\"value\": [7, 7]}" | ||
| " }" | ||
| " }" | ||
| " }" | ||
| " }" | ||
| "]}"; |
There was a problem hiding this comment.
This one is still not updated.
| std::to_string(SINA_FILE_FORMAT_VERSION_MINOR); | ||
| } | ||
|
|
||
| // just need to get something working... |
There was a problem hiding this comment.
This comment should be revised or removed.
Is this still considered a quick fix or has it been improved.
There was a problem hiding this comment.
I'm not even sure what it's referencing. Between this and the raw json-like test document, I'm wondering if a cleanup commit was dropped. Easy enough fix. Thanks for catching these, Kenny.
| const std::string &endpoint, | ||
| const int mergeProtocol, | ||
| int record_num, | ||
| const std::string &original_file_path=""); // default'd because it might go away |
There was a problem hiding this comment.
const std::string &original_file_path=""); // default'd because it might go away
Should this question be resolved before merging?
There was a problem hiding this comment.
Unclear comment from me--this referencing a possible addition to Conduit, not a PR change. Will clean that up.
| // Helper function--if a node has children, add them to the provided. Assumes both nodes are conduit lists | ||
| void concat_list_node(conduit::Node &concatTo, const conduit::Node &concatFrom) | ||
| { | ||
| auto itr = concatFrom.children(); | ||
| while(itr.has_next()) | ||
| { | ||
| concatTo.append() = itr.next(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Would it make sense to add (debug) checks that both concatTo and concatFrom are conduit lists?
| ///////////////////// TEMPLATE HELPER BLOCK -- smooth differences between JSON and HDF5 ///////////////////// | ||
| // This section exits because the hdf5 uses a dictionary to store records, ex: records/<some_num>/{actual_record} | ||
| // whereas the JSON uses a list. The pathlike relay interface doesn't have access for list entries. This all should | ||
| // be able to go away fairly cleanly if we swap over to dicts in JSON. | ||
| conduit::Node &relayLikeRead(conduit::Node &appendTo, const std::string &endpoint, conduit::Node &readInto, int record_num) | ||
| { | ||
| UNUSED(readInto); | ||
| return appendTo["records"].child(record_num)[endpoint]; | ||
| } |
There was a problem hiding this comment.
Nice comment!
I'm confused about the word "template" in "TEMPLATE HELPER BLOCK" -- these functions do not appear to be templated.
There was a problem hiding this comment.
Good point, it's a reference to RelayLike further down but that's certainly not clear.
| // We need to read exactly one thing outside the records set. Terrible. | ||
| conduit::Node &relayLikeReadEtc(conduit::Node &appendTo, const std::string &endpoint, conduit::Node &readInto){ | ||
| UNUSED(readInto); | ||
| return appendTo[endpoint]; | ||
| } |
There was a problem hiding this comment.
// We need to read exactly one thing outside the records set. Terrible.
Please update this comment before merging.
| #endif | ||
| #ifndef AXOM_USE_HDF5 |
There was a problem hiding this comment.
Please change this to #else
| #endif | |
| #ifndef AXOM_USE_HDF5 | |
| #else |
There was a problem hiding this comment.
I should delete these entirely.
…xom into feature/sina/append_functionality
kennyweiss
left a comment
There was a problem hiding this comment.
Thanks @HaluskaR -- I had a few small suggestions and one important but easy one about the UNUSED macro, which could potentially conflict with upstream dependencies, so we should fix it before merging.
| - Sina: Records can now be provided with a curve ordering to use when writing to file. By default, all records will now use | ||
| oldest-first ordering (ULTRA-like) | ||
| - Sina: Documents can optionally be written as HDF5 instead of JSON. HDF5 should provide better performance for large, curve-rich sets | ||
| - Sina: Written documents can now be appended to. This is a flexible system with a few different uses, ex: continuous writing of timeseries, overwriting values that change over the course of a simulation, and snapshot handling. See documentation for details. |
There was a problem hiding this comment.
Thanks for updating the RELEASE-NOTES!
| /** | ||
| * \brief Append the new records or, per-record, new data, user defined content, curves/curve sets, | ||
| * and library data of a Sina Document to an existing JSON file. For a full explanation of behavior, | ||
| * see append_to_hdf5. Note that a JSON file must be entirely re-written for an append to function; |
There was a problem hiding this comment.
Minor: Should this be appendDocumentToHDF5 instead of append_to_hdf5?
| * see append_to_hdf5. Note that a JSON file must be entirely re-written for an append to function; | |
| * see appendDocumentToHDF5. Note that a JSON file must be entirely re-written for an append to function; |
| /** | ||
| * \brief Check a node against some file handle and return a Conduit node populated with any errors that | ||
| * would prevent appending. Primarily useful for testing out what may be going wrong with an append. | ||
| * | ||
| * \param appendTo Either a conduit node or a conduit relay filehandle (prefer the latter for HDF5) representing | ||
| * the data on disk | ||
| * \param appendFrom A conduit node representing the document being appended to the file on disk | ||
| * \param mergeProtocol protocol for handling duplicate data/files/user_defined/etc. See append methods above. | ||
| * \return a conduit Node containing a list of any errors encountered in appending. If empty, success. | ||
| */ | ||
| template <typename ConduitRelayLike> | ||
| conduit::Node validateAppendDocument(ConduitRelayLike &appendTo, | ||
| const conduit::Node &appendFrom, | ||
| const std::string &endpoint, | ||
| const int mergeProtocol, | ||
| int record_num, | ||
| // default'd because it might go away with a conduit update | ||
| const std::string &original_file_path = ""); |
There was a problem hiding this comment.
A few of the parameters are not documented: endpoint, record_num, original_file_path
| #define UNUSED(x) \ | ||
| (void)(x) // TODO: axom likely has a better preference on how to suppress the warning |
There was a problem hiding this comment.
Please remove this UNUSED macro, and replace all uses with AXOM_UNUSED_VAR (already included via axom/core.hpp)
…xom into feature/sina/append_functionality
Arlie-Capps
left a comment
There was a problem hiding this comment.
Thanks, @HaluskaR . Lots of work went into this one.
Summary