Skip to content

Commit f9b337b

Browse files
committed
Allow empty variable-based series
1 parent 53af6e8 commit f9b337b

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ jobs:
270270
cd build
271271
ctest --output-on-failure
272272
273-
python3 -m pip install jsonschema@4.2.3 referencing
273+
python3 -m pip install jsonschema==4.2.3 referencing
274274
cd ../share/openPMD/json_schema
275275
PATH="../../../build/bin:$PATH" make -j 2
276276
# We need to exclude the thetaMode example since that has a different

share/openPMD/json_schema/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ json_files = attribute_defs.json attributes.json dataset_defs.json iteration.jso
55
.PHONY: all
66
all: $(json_files)
77

8+
# The target file should only be created if the conversion succeeded
89
$(json_files): %.json: %.toml
9-
$(convert) @$^ > $@
10+
$(convert) @$^ > $@.tmp
11+
mv $@.tmp $@
1012

1113
.PHONY: clean
1214
clean:
13-
-rm $(json_files)
15+
for file in $(json_files); do rm -f "$$file" "$$file.tmp"; done

share/openPMD/json_schema/series.toml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,34 @@ title = "Contains iterations"
7878
# Requirement 2.1: Either a single iteration in variable-based encoding #
7979
#########################################################################
8080

81-
[[allOf.oneOf]]
81+
[allOf.if]
82+
properties.attributes.properties.iterationEncoding.oneOf = [
83+
{ const = { value = "variableBased", datatype = "STRING" } },
84+
{ const = "variableBased" },
85+
]
86+
87+
[allOf.then]
8288
title = "Variable-based encoding"
8389
properties.attributes.properties.iterationEncoding.properties.value = { const = "variableBased" }
8490

85-
[allOf.oneOf.properties.data]
91+
[allOf.then.properties.data]
8692
type = "object"
8793
title = "An iteration"
8894
description = "A single iteration."
95+
96+
# Only require iteration data if snapshot attribute is defined
97+
[allOf.then.properties.data.if]
98+
required = ["attributes"]
99+
properties.attributes.required = ["snapshot"]
100+
101+
[allOf.then.properties.data.then]
89102
"$ref" = "iteration.json"
90103

91104
############################################################################
92105
# Requirement 2.2: Or multiple iterations in group- or file-based encoding #
93106
############################################################################
94107

95-
[[allOf.oneOf]]
108+
[allOf.else]
96109
title = "Group-based (or file-based) encoding"
97110
properties.attributes.properties.iterationEncoding.properties.value = { oneOf = [
98111
{ const = "groupBased" },
@@ -101,22 +114,22 @@ properties.attributes.properties.iterationEncoding.properties.value = { oneOf =
101114

102115
# Base Path
103116

104-
[allOf.oneOf.properties.data]
117+
[allOf.else.properties.data]
105118
type = "object"
106119
title = "Base path"
107120
description = "A map of all iterations/snapshots in the Series."
108121

109122
propertyNames.pattern = "^(-?[0-9]*|attributes)$"
110123

111-
[allOf.oneOf.properties.data.properties]
124+
[allOf.else.properties.data.properties]
112125

113-
[allOf.oneOf.properties.data.properties.attributes]
126+
[allOf.else.properties.data.properties.attributes]
114127
title = "Attribute layout"
115128
description = "Custom attributes allowed, no required attributes defined."
116129
"$ref" = "attributes.json"
117130

118131
# Base Path -> Iterations
119132

120-
[allOf.oneOf.properties.data.patternProperties."^-?[0-9]*$"]
133+
[allOf.else.properties.data.patternProperties."^-?[0-9]*$"]
121134
title = "Iteration"
122135
"$ref" = "iteration.json"

src/Series.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,24 +1410,6 @@ void Series::flushGorVBased(
14101410
internal::FlushParams const &flushParams,
14111411
bool flushIOHandler)
14121412
{
1413-
if (iterationEncoding() == IterationEncoding::variableBased &&
1414-
access::writeOnly(IOHandler()->m_frontendAccess) && iterations.empty())
1415-
{
1416-
/*
1417-
* Note: Unlike flushFileBased, it's ok if `begin == end` since this
1418-
* method may be called without an explicit iteration.
1419-
* But since in variable-based encoding the base path is the same as the
1420-
* path to the (currently active) iteration, there must be at least one
1421-
* iteration present since the openPMD standard requires mandatory
1422-
* attributes.
1423-
* In group-based encoding, any number of iterations might be included
1424-
* in the base path, in variable-based encoding there must be exactly
1425-
* one iteration currently active.
1426-
*/
1427-
throw error::WrongAPIUsage(
1428-
"variableBased output can not be written with no iterations.");
1429-
}
1430-
14311413
auto &series = get();
14321414
if (access::readOnly(IOHandler()->m_frontendAccess))
14331415
{

0 commit comments

Comments
 (0)