Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Reduce dependence on pyiron workflow #105

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pyiron_ontology/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)))
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading