diff --git a/pyiron_ontology/parser.py b/pyiron_ontology/parser.py index b100272..66472bc 100644 --- a/pyiron_ontology/parser.py +++ b/pyiron_ontology/parser.py @@ -47,10 +47,12 @@ def get_inputs_and_outputs(node: Node) -> dict: for key, value in node.inputs.items(): if inputs[key] is None: inputs[key] = {} - inputs[key]["value"] = value.value + if value.value is not NOT_DATA: + inputs[key]["value"] = value.value inputs[key]["connection"] = get_source_output(value) for key, value in node.outputs.to_value_dict().items(): - outputs[key]["value"] = value + if value is not NOT_DATA: + outputs[key]["value"] = value return { "inputs": inputs, "outputs": outputs, @@ -129,7 +131,7 @@ def get_triples( graph.add((label, RDF.type, PROV.Entity)) if d.get("uri", None) is not None: graph.add((label, RDF.type, URIRef(d["uri"]))) - if d.get("value", NOT_DATA) is not NOT_DATA: + if "value" in d: graph.add((label, RDF.value, Literal(d["value"]))) if io_ == "inputs": graph.add((label, PNS.inputOf, URIRef(full_label))) diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py index 530f381..d6bb36d 100644 --- a/tests/unit/test_parser.py +++ b/tests/unit/test_parser.py @@ -178,6 +178,26 @@ def test_namespace(self): with self.assertRaises(AttributeError): _ = PNS.ahoy + def test_parsing_without_running(self): + wf = Workflow("correct_analysis") + wf.addition = add(a=1.0, b=2.0) + data = get_inputs_and_outputs(wf.addition) + self.assertFalse("value" in data["outputs"]) + graph = get_triples(data) + self.assertEqual( + len(list(graph.triples((None, RDF.value, None)))), + 2, + msg="There should be only values for a and b, but not for the output", + ) + wf.run() + data = get_inputs_and_outputs(wf.addition) + graph = get_triples(data) + self.assertEqual( + len(list(graph.triples((None, RDF.value, None)))), + 3, + msg="There should be values for a, b and the output", + ) + if __name__ == "__main__": unittest.main()