Skip to content

Commit 486ce11

Browse files
authored
Add version number to JSON format (#100)
1 parent e9aba8a commit 486ce11

File tree

8 files changed

+15
-0
lines changed

8 files changed

+15
-0
lines changed

example_workflows/arithmetic/workflow.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.0.1",
23
"nodes": [
34
{"id": 0, "type": "function", "value": "workflow.get_prod_and_div"},
45
{"id": 1, "type": "function", "value": "workflow.get_sum"},

example_workflows/nfdi/workflow.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.0.1",
23
"nodes": [
34
{"id": 0, "type": "function", "value": "workflow.generate_mesh"},
45
{"id": 1, "type": "function", "value": "workflow.convert_to_xdmf"},

example_workflows/quantum_espresso/workflow.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.0.1",
23
"nodes": [
34
{"id": 0, "type": "function", "value": "workflow.get_bulk_structure"},
45
{"id": 1, "type": "function", "value": "workflow.calculate_qe"},

python_workflow_definition/src/python_workflow_definition/aiida.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
SOURCE_PORT_LABEL,
1919
TARGET_LABEL,
2020
TARGET_PORT_LABEL,
21+
VERSION_NUMBER,
22+
VERSION_LABEL,
2123
)
2224

2325

@@ -139,6 +141,7 @@ def write_workflow_json(wg: WorkGraph, file_name: str) -> dict:
139141
SOURCE_PORT_LABEL: None,
140142
}
141143
)
144+
data[VERSION_LABEL] = VERSION_NUMBER
142145
PythonWorkflowDefinitionWorkflow(
143146
**set_result_node(workflow_dict=update_node_names(workflow_dict=data))
144147
).dump_json_file(file_name=file_name, indent=2)

python_workflow_definition/src/python_workflow_definition/jobflow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
SOURCE_PORT_LABEL,
2121
TARGET_LABEL,
2222
TARGET_PORT_LABEL,
23+
VERSION_NUMBER,
24+
VERSION_LABEL,
2325
)
2426

2527

@@ -339,6 +341,7 @@ def write_workflow_json(flow: Flow, file_name: str = "workflow.json"):
339341
**set_result_node(
340342
workflow_dict=update_node_names(
341343
workflow_dict={
344+
VERSION_LABEL: VERSION_NUMBER,
342345
NODES_LABEL: nodes_store_lst,
343346
EDGES_LABEL: edges_lst,
344347
}

python_workflow_definition/src/python_workflow_definition/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def serialize_source_handle(self, v: Optional[str]) -> Optional[str]:
116116
class PythonWorkflowDefinitionWorkflow(BaseModel):
117117
"""The main workflow model."""
118118

119+
version: str
119120
nodes: List[PythonWorkflowDefinitionNode]
120121
edges: List[PythonWorkflowDefinitionEdge]
121122

python_workflow_definition/src/python_workflow_definition/pyiron_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
SOURCE_PORT_LABEL,
2121
TARGET_LABEL,
2222
TARGET_PORT_LABEL,
23+
VERSION_NUMBER,
24+
VERSION_LABEL,
2325
)
2426

2527

@@ -300,6 +302,7 @@ def write_workflow_json(
300302
**set_result_node(
301303
workflow_dict=update_node_names(
302304
workflow_dict={
305+
VERSION_LABEL: VERSION_NUMBER,
303306
NODES_LABEL: nodes_store_lst,
304307
EDGES_LABEL: edges_new_lst,
305308
}

python_workflow_definition/src/python_workflow_definition/shared.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
SOURCE_PORT_LABEL = "sourcePort"
77
TARGET_LABEL = "target"
88
TARGET_PORT_LABEL = "targetPort"
9+
VERSION_NUMBER = "0.0.1"
10+
VERSION_LABEL = "version"
911

1012

1113
def get_dict(**kwargs) -> dict:

0 commit comments

Comments
 (0)