Skip to content

Commit

Permalink
Translate all of this to TOML
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Apr 18, 2023
1 parent 576ac4d commit 23366e0
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 6 deletions.
2 changes: 1 addition & 1 deletion share/openPMD/json_schema/mesh.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
},
{
"title": "Contains components",
"description": "Additionally to the attributes, at least one component must be contained",
"oneOf": [
{
"title": "Scalar mesh component",
"$ref": "mesh_record_component.json"
},
{
"title": "Vector component",
"description": "Additionally to the attributes, at least one component must be contained",
"patternProperties":
{
"^(?!attributes).*": {
Expand Down
6 changes: 3 additions & 3 deletions share/openPMD/json_schema/mesh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dataOrder."$ref" = "attribute_defs.json#/$defs/string_attribute"
axisLabels."$ref" = "attribute_defs.json#/$defs/vec_string_attribute"

################################################
# Requirement 1.1: Generic attribute structure #
# Requirement 1.2: Generic attribute structure #
################################################

[[allOf.properties.attributes.allOf]]
Expand All @@ -57,7 +57,6 @@ title = "Attribute layout"
[[allOf]]

title = "Contains components"
description = "Additionally to the attributes, at least one component must be contained"

####################################################
# Requirement 2.1: Either this is a scalar mesh... #
Expand All @@ -68,13 +67,14 @@ title = "Scalar mesh component"
"$ref" = "mesh_record_component.json"

#################################################
# Requirement 2.1: ... or it's a vector mesh. #
# Requirement 2.2: ... or it's a vector mesh. #
# Note that exactly one of these two conditions #
# must be true, not both at once (oneOf). #
#################################################

[[allOf.oneOf]]
title = "Vector component"
description = "Additionally to the attributes, at least one component must be contained"
# The attributes are contained in this dict, and at least one further
# non-scalar component. Hence, we require at least two entries.
minProperties = 2
Expand Down
27 changes: 27 additions & 0 deletions share/openPMD/json_schema/mesh_record_component.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
title = "Mesh Record Component"

#############################################
# Requirement 1: This is a record component #
#############################################

[[allOf]]
title = "Record Component"
"$ref" = "record_component.json"

##################################################
# Requirement 2: Mesh Record Component Specifics #
##################################################

[[allOf]]
title = "Mesh Record Component"
description = "Single component in a mesh record."
type = "object"
required = ["attributes"]

[allOf.properties.attributes]
required = ["position"]
title = "Record Component attributes"
description = "Standard-defined attributes at the Record Component level."

[allOf.properties.attributes.properties]
position."$ref" = "attribute_defs.json#/$defs/vec_float_attribute"
33 changes: 33 additions & 0 deletions share/openPMD/json_schema/particle_species.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
type = "object"
title = "Particle Species"
description = "Dict of particle quantities."
propertyNames.pattern = "^\\w*$"

[properties.attributes]

##################################################
# First requirement: standard-defined attributes #
##################################################

[[properties.attributes.allOf]]
title = "Particle Species attributes"
description = "Standard-defined attributes at the Particle Species level."
# No required attributes
required = []

[properties.attributes.allOf.properties]
id."$ref" = "attribute_defs.json#/$defs/int_attribute"

####################################################
# Second requirement: General layout of attributes #
####################################################

[[properties.attributes.allOf]]
title = "Attribute layout"
description = "Custom attributes allowed, no required attributes defined."
"$ref" = "attributes.json"


[patternProperties."^(?!(attributes|particlePatches)).*"]
title = "Record"
"$ref" = "record.json"
72 changes: 72 additions & 0 deletions share/openPMD/json_schema/record.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#########################################################
# Requirement 1: Mesh-specific structure and attributes #
#########################################################

[[allOf]]

type = "object"
required = ["attributes"]
title = "Record"
description = "A list of particle quantities."

[allOf.properties.attributes]
title = "Attributes"

####################################
# Requirement 1.1: Mesh attributes #
####################################

[[allOf.properties.attributes.allOf]]

title = "Particle Record attributes"
description = "Standard-defined attributes at the Particle Record level."
required = ["timeOffset", "unitDimension"]

[allOf.properties.attributes.allOf.properties]

timeOffset."$ref" = "attribute_defs.json#/$defs/float_attribute"
unitDimension."$ref" = "attribute_defs.json#/$defs/unitDimension"
dataOrder."$ref" = "attribute_defs.json#/$defs/string_attribute"

################################################
# Requirement 1.2: Generic attribute structure #
################################################

[[allOf.properties.attributes.allOf]]
title = "Attribute layout"
"$ref" = "attributes.json"

######################################
# Requirement 2: Contains components #
######################################

[[allOf]]
title = "Contains components"

####################################################
# Requirement 2.1: Either this is a scalar mesh... #
####################################################

[[allOf.oneOf]]
title = "Scalar component"
"$ref" = "record_component.json"

#################################################
# Requirement 2.2: ... or it's a vector mesh. #
# Note that exactly one of these two conditions #
# must be true, not both at once (oneOf). #
#################################################

[[allOf.oneOf]]
title = "Vector component"
description = "Additionally to the attributes, at least one component must be contained"
# The attributes are contained in this dict, and at least one further
# non-scalar component. Hence, we require at least two entries.
minProperties = 2
propertyNames.pattern = "^\\w*$"

[allOf.oneOf.patternProperties]

[allOf.oneOf.patternProperties."^(?!attributes).*"]
title = "Scalar component"
"$ref" = "record_component.json"
89 changes: 89 additions & 0 deletions share/openPMD/json_schema/record_component.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
##############################################
# Requirement 1: Record Component attributes #
##############################################

[[allOf]]
title = "Record Component"
description = "Single component in a record."
type = "object"
required = ["attributes"]

[allOf.properties.attributes]
title = "Attributes"

################################################
# Requirement 1.1: Standard-defined attributes #
################################################

[[allOf.properties.attributes.allOf]]
title = "Record Component attributes"
description = "Standard-defined attributes at the Record Component level."
required = ["unitSI"]

[allOf.properties.attributes.allOf.properties]
unitSI."$ref" = "attribute_defs.json#/$defs/float_attribute"

#############################################
# Requirement 1.2: Generic attribute layout #
#############################################

[[allOf.properties.attributes.allOf]]
title = "Attribute layout"
"$ref" = "attributes.json"

###########################################
# Requirement 2: Either array or constant #
###########################################

[[allOf]]
title = "Either array or constant"

#####################
# Option 2.1: Array #
#####################

[[allOf.oneOf]]
required = ["data", "datatype"]
description = "An n-dimensional dataset containing the payload."
title = "Array dataset"

[allOf.oneOf.properties]

datatype.enum = [
"CHAR",
"UCHAR",
"SCHAR",
"SHORT",
"INT",
"LONG",
"LONGLONG",
"USHORT",
"UINT",
"ULONG",
"ULONGLONG",
"FLOAT",
"DOUBLE",
"LONG_DOUBLE",
"CFLOAT",
"CDOUBLE",
"CLONG_DOUBLE",
"BOOL",
]
# TODO: properly define this
data.type = "array"

########################
# Option 2.2: Constant #
########################

[[allOf.oneOf]]
title = "Constant dataset"
description = "A dataset represented by two attributes: The constant value and its shape."
required = ["attributes"]

[allOf.oneOf.properties.attributes]
required = ["shape", "value"]

[allOf.oneOf.properties.attributes.properties]
value."$ref" = "attribute_defs.json#/$defs/float_attribute"
shape."$ref" = "attribute_defs.json#/$defs/vec_int_attribute"
8 changes: 6 additions & 2 deletions share/openPMD/json_schema/series.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ title = "Iteration"
[properties.attributes]
title = "Attributes"

# First requirement: standard-defined attributes
##############################################
# Requirement 1: standard-defined attributes #
##############################################

[[properties.attributes.allOf]]
required = ["openPMD", "openPMDextension", "basePath"]
Expand Down Expand Up @@ -70,7 +72,9 @@ particlesPath.description = "Note that the particlesPath is hardcoded as its sem
particlesPath.const.value = "particles/"
particlesPath.const.datatype = "STRING"

# Second condition: General layout of attributes
###############################################
# Requirement 2: General layout of attributes #
###############################################

[[properties.attributes.allOf]]
title = "Attribute layout"
Expand Down

0 comments on commit 23366e0

Please sign in to comment.