Skip to content

Feature/sina/append functionality#1542

Merged
kennyweiss merged 139 commits into
developfrom
feature/sina/append_functionality
Sep 11, 2025
Merged

Feature/sina/append functionality#1542
kennyweiss merged 139 commits into
developfrom
feature/sina/append_functionality

Conversation

@gwaegner

@gwaegner gwaegner commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

Summary

  • This PR is a feature
  • It does the following (modify list as needed):
    • Adds the ability for Sina to append to existing JSON and HDF5 files using file manipulation (JSON) and data streaming (HDF5)

@doutriaux1

Copy link
Copy Markdown
Contributor

@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

@rhornung67

Copy link
Copy Markdown
Member

@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.

@rhornung67

Copy link
Copy Markdown
Member

This PR needs to be squash merged when done!!!

@doutriaux1 doutriaux1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@HaluskaR if the pngs I commented on are good and if you adressed @kennyweiss requested change then I'm good with this Pr.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@HaluskaR is that the original file from @gwaegner ? If so can we update it with results from your current implementation?

@HaluskaR HaluskaR Aug 12, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@doutriaux1

Copy link
Copy Markdown
Contributor

@kennyweiss @white238 @rhornung67 I think this is ready to go. @HaluskaR we're good right?

@doutriaux1

Copy link
Copy Markdown
Contributor

@LLNL/axom please review/merge

@kennyweiss kennyweiss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Comment thread src/axom/sina/tests/sina_Document.cpp Outdated
Comment on lines +157 to +204
// 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]}"
" }"
" }"
" }"
" }"
"]}";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one is still not updated.

Comment thread src/axom/sina/core/Document.hpp Outdated
std::to_string(SINA_FILE_FORMAT_VERSION_MINOR);
}

// just need to get something working...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment should be revised or removed.

Is this still considered a quick fix or has it been improved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/axom/sina/core/Document.hpp Outdated
const std::string &endpoint,
const int mergeProtocol,
int record_num,
const std::string &original_file_path=""); // default'd because it might go away

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const std::string &original_file_path=""); // default'd because it might go away

Should this question be resolved before merging?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unclear comment from me--this referencing a possible addition to Conduit, not a PR change. Will clean that up.

Comment thread src/axom/sina/core/Document.cpp Outdated
Comment thread src/axom/sina/core/Document.cpp Outdated
Comment on lines +409 to +417
// 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();
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it make sense to add (debug) checks that both concatTo and concatFrom are conduit lists?

Comment thread src/axom/sina/core/Document.cpp Outdated
Comment on lines +419 to +427
///////////////////// 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];
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice comment!

I'm confused about the word "template" in "TEMPLATE HELPER BLOCK" -- these functions do not appear to be templated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good point, it's a reference to RelayLike further down but that's certainly not clear.

Comment thread src/axom/sina/core/Document.cpp Outdated
Comment on lines +439 to +443
// 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];
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

// We need to read exactly one thing outside the records set. Terrible.

Please update this comment before merging.

Comment thread src/axom/sina/core/Document.cpp Outdated
Comment on lines +1023 to +1024
#endif
#ifndef AXOM_USE_HDF5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please change this to #else

Suggested change
#endif
#ifndef AXOM_USE_HDF5
#else

@kennyweiss kennyweiss added the Sina Issues related to Axom's 'sina' component label Aug 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I should delete these entirely.

@kennyweiss kennyweiss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread RELEASE-NOTES.md
Comment on lines +58 to +61
- 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for updating the RELEASE-NOTES!

Comment thread src/axom/sina/core/Document.hpp Outdated
/**
* \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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: Should this be appendDocumentToHDF5 instead of append_to_hdf5?

Suggested change
* 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;

Comment on lines +354 to +371
/**
* \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 = "");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few of the parameters are not documented: endpoint, record_num, original_file_path

Comment thread src/axom/sina/core/Document.cpp Outdated
Comment on lines +85 to +86
#define UNUSED(x) \
(void)(x) // TODO: axom likely has a better preference on how to suppress the warning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this UNUSED macro, and replace all uses with AXOM_UNUSED_VAR (already included via axom/core.hpp)

@kennyweiss kennyweiss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @HaluskaR !

format-robot and others added 2 commits September 11, 2025 13:04

@Arlie-Capps Arlie-Capps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @HaluskaR . Lots of work went into this one.

@kennyweiss
kennyweiss merged commit c87e743 into develop Sep 11, 2025
15 checks passed
@kennyweiss
kennyweiss deleted the feature/sina/append_functionality branch September 11, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Sina Issues related to Axom's 'sina' component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants