Skip to content

Commit 274d86d

Browse files
authored
Merge branch 'develop' into task/2026_raja_and_friends
2 parents 9522a57 + 61c7ff5 commit 274d86d

6 files changed

Lines changed: 684 additions & 150 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
1313
- Added a macro to make an integer a version number from major, minor, patch version numbers. Example: `CONDUIT_MAKE_VERSION_VALUE(0, 9, 6)`. This macro can be used to conditionally compile code that is valid for specific versions of Conduit.
1414
- Added `set` methods to `DataAccessor` that take `DataArray`s and `DataAccessor`s.
1515
- Added optional device execution support via RAJA and Umpire.
16+
- Added `conduit_bin_yaml` protocol case to `Node::load()` and `Node::save()`. Also added `conduit_bin_json`, which does the same thing as `conduit_bin` (creates a json schema file to go with the `conduit_bin` file).
1617

1718
#### Blueprint
1819
- Finished `bent_multi_grid_amr` mesh by adding adjacency sets between spatially adjacent domains at the same level of refinement.
@@ -32,6 +33,12 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
3233
- Updates to use Silo 4.12 and HDF5 2.0.0.
3334
- Reworked HDF5 handle managment to avoid resource leaks with exceptions.
3435

36+
### Fixed
37+
38+
#### Conduit
39+
- Fixed a bug preventing explicit length 0 in `yaml` schema.
40+
- Fixed a bug where empty objects or lists were not written correctly to `yaml` schema.
41+
3542
## [0.9.5] - Released 2025-09-10
3643

3744
### Added

src/libs/conduit/conduit_generator.cpp

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,6 @@ Generator::Parser::JSON::walk_json_schema_external(Node *node,
16381638
{
16391639
// node is already linked to the schema pointer
16401640
schema->set(dtype);
1641-
schema->print();
16421641
node->set_data_ptr(data);
16431642
}
16441643
else
@@ -2574,7 +2573,7 @@ Generator::Parser::YAML::parse_leaf_dtype(yaml_document_t *yaml_doc,
25742573
length = get_yaml_sequence_length(value_node);
25752574
}
25762575
// support explicit length 0 in a schema
2577-
else if (fetch_yaml_node_from_object_by_name(yaml_doc, yaml_node, "number_of_elements"))
2576+
else if (! fetch_yaml_node_from_object_by_name(yaml_doc, yaml_node, "number_of_elements"))
25782577
{
25792578
length = 1;
25802579
}
@@ -2696,7 +2695,6 @@ Generator::Parser::YAML::walk_yaml_schema(Node *node,
26962695
{
26972696
// node is already linked to the schema pointer
26982697
schema->set(des_dtype);
2699-
schema->print();
27002698
node->set_data_ptr(data);
27012699
}
27022700
else
@@ -3294,7 +3292,7 @@ Generator::data_ptr() const
32943292

32953293

32963294
//-----------------------------------------------------------------------------
3297-
// JSON Parsing interface
3295+
// JSON & YAML Parsing interface
32983296
//-----------------------------------------------------------------------------s
32993297

33003298

@@ -3304,7 +3302,8 @@ Generator::walk(Schema &schema) const
33043302
{
33053303
schema.reset();
33063304
index_t curr_offset = 0;
3307-
if (m_protocol.find("json") != std::string::npos)
3305+
3306+
auto json_case = [&]()
33083307
{
33093308
conduit_json::Document document;
33103309
std::string res = utils::json_sanitize(m_schema);
@@ -3315,8 +3314,8 @@ Generator::walk(Schema &schema) const
33153314
}
33163315

33173316
Parser::JSON::walk_json_schema(&schema,document,curr_offset);
3318-
}
3319-
else if (m_protocol.find("yaml") != std::string::npos)
3317+
};
3318+
auto yaml_case = [&]()
33203319
{
33213320
Parser::YAML::YAMLParserWrapper parser;
33223321
parser.parse(m_schema.c_str());
@@ -3332,6 +3331,64 @@ Generator::walk(Schema &schema) const
33323331
curr_offset);
33333332

33343333
// YAMLParserWrapper cleans up for us
3334+
};
3335+
3336+
std::string error_message;
3337+
bool schema_walked = false;
3338+
3339+
// The protocol is default initialized to json. We choose to prefer
3340+
// walking based on the protocol but we can fall back if possible.
3341+
if (m_protocol.find("json") != std::string::npos)
3342+
{
3343+
try
3344+
{
3345+
json_case();
3346+
schema_walked = true;
3347+
}
3348+
catch (conduit::Error &e_json)
3349+
{
3350+
error_message = "JSON schema walk failed: " + e_json.message();
3351+
try
3352+
{
3353+
yaml_case();
3354+
schema_walked = true;
3355+
}
3356+
catch(conduit::Error &e_yaml)
3357+
{
3358+
error_message += "\nYAML schema walk failed: " + e_yaml.message();
3359+
}
3360+
}
3361+
3362+
if (! schema_walked)
3363+
{
3364+
CONDUIT_ERROR(error_message);
3365+
}
3366+
}
3367+
else if (m_protocol.find("yaml") != std::string::npos)
3368+
{
3369+
try
3370+
{
3371+
yaml_case();
3372+
schema_walked = true;
3373+
}
3374+
catch (conduit::Error &e_yaml)
3375+
{
3376+
error_message = "YAML schema walk failed: " + e_yaml.message();
3377+
try
3378+
{
3379+
json_case();
3380+
schema_walked = true;
3381+
}
3382+
catch(conduit::Error &e_json)
3383+
{
3384+
error_message += "\nJSON schema walk failed: " + e_json.message();
3385+
}
3386+
}
3387+
3388+
if (! schema_walked)
3389+
{
3390+
CONDUIT_ERROR(error_message);
3391+
}
33353392
}
33363393
else
33373394
{

src/libs/conduit/conduit_generator.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace conduit
3030
/// class: conduit::Generator
3131
///
3232
/// description:
33-
/// The Generator class implements parsing logic for json schemas.
33+
/// The Generator class implements parsing logic for yaml and json schemas.
3434
///
3535
//-----------------------------------------------------------------------------
3636
class CONDUIT_API Generator
@@ -60,8 +60,12 @@ class CONDUIT_API Generator
6060
/// protocols:
6161
/// "json"
6262
/// "conduit_json"
63+
/// "conduit_json_external"
6364
/// "conduit_base64_json"
6465
/// "yaml"
66+
/// "conduit_yaml"
67+
/// "conduit_yaml_external"
68+
/// "conduit_base64_yaml"
6569
///
6670
Generator(const std::string &schema,
6771
const std::string &protocol = std::string("conduit_json"),

0 commit comments

Comments
 (0)