Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- python >=3.11,<3.14
- python-graphviz =0.21
- rdflib =7.1.4
- semantikon =0.0.22
- semantikon =0.0.23
- setuptools>=68
- toposort =1.10
- typeguard =4.4.4
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- python >=3.11,<3.14
- python-graphviz =0.21
- rdflib =7.1.4
- semantikon =0.0.22
- semantikon =0.0.23
- setuptools>=68
- toposort =1.10
- typeguard =4.4.4
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/lower_bound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ dependencies:
- pyiron_snippets =0.1.4
- python-graphviz =0.20.3
- rdflib =7.1.4
- semantikon =0.0.22
- semantikon =0.0.23
- toposort =1.10
- typeguard =4.2.0
2 changes: 1 addition & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies:
- python >=3.11,<3.14
- python-graphviz =0.21
- rdflib =7.1.4
- semantikon =0.0.22
- semantikon =0.0.23
- setuptools>=68
- toposort =1.10
- typeguard =4.4.4
Expand Down
262 changes: 115 additions & 147 deletions notebooks/ontological_workflows.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies = [
"pint==0.25",
"pyiron_snippets==0.2.0",
"rdflib==7.1.4",
"semantikon==0.0.22",
"semantikon==0.0.23",
"toposort==1.10",
"typeguard==4.4.4",
]
Expand Down
69 changes: 39 additions & 30 deletions tests/integration/test_suggest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from semantikon.metadata import u

import pyiron_workflow as pwf
from pyiron_workflow.channels import ChannelConnectionError
from pyiron_workflow.nodes import static_io
from pyiron_workflow.suggest import (
ConnectedInputError,
Expand All @@ -30,7 +29,12 @@ def __init__(self, contents=None):
@pwf.as_function_node
def AddNuts(
gets_nuts: u(Storage, uri=EX.Shelf),
) -> u(Storage, derived_from="inputs.gets_nuts", triples=(EX.hasComponents, EX.nut)):
) -> u(
Storage,
uri=EX.Shelf,
derived_from="inputs.gets_nuts",
triples=(EX.hasComponents, EX.nut),
):
has_nuts = gets_nuts
return has_nuts

Expand All @@ -39,7 +43,10 @@ def AddNuts(
def AddWashers(
gets_washer: u(Storage, uri=EX.Shelf),
) -> u(
Storage, derived_from="inputs.gets_washer", triples=(EX.hasComponents, EX.washer)
Storage,
uri=EX.Shelf,
derived_from="inputs.gets_washer",
triples=(EX.hasComponents, EX.washer),
):
# Like a washer, the purpose here is to go between the nuts and bolts
# In our case, to make sure we catch and avoid circular connection suggestions
Expand All @@ -50,7 +57,12 @@ def AddWashers(
@pwf.as_function_node
def AddBolts(
gets_bolts: u(Storage, uri=EX.Shelf),
) -> u(Storage, derived_from="inputs.gets_bolts", triples=(EX.hasComponents, EX.bolt)):
) -> u(
Storage,
uri=EX.Shelf,
derived_from="inputs.gets_bolts",
triples=(EX.hasComponents, EX.bolt),
):
has_bolts = gets_bolts
return has_bolts

Expand All @@ -75,7 +87,12 @@ def AssembleShelf(
),
),
),
) -> u(Storage, derived_from="inputs.to_assemble", triples=(EX.hasState, EX.assembled)):
) -> u(
Storage,
uri=EX.Shelf,
derived_from="inputs.to_assemble",
triples=(EX.hasState, EX.assembled),
):
assembled = to_assemble
return assembled

Expand All @@ -91,7 +108,12 @@ def PlaceBooks(
),
),
*books: str,
) -> u(Storage, derived_from="inputs.bookshelf", triples=(EX.hasContents, EX.book)):
) -> u(
Storage,
uri=EX.Shelf,
derived_from="inputs.bookshelf",
triples=(EX.hasContents, EX.book),
):
bookshelf.contents = books
return bookshelf

Expand All @@ -109,7 +131,7 @@ def NoHints(shelf):
@pwf.as_function_node
def WrongHint(
fridge: u(Storage, uri=EX.Fridge),
) -> u(Storage, derived_from="inputs.fridge"):
) -> u(Storage, uri=EX.Fridge, derived_from="inputs.fridge"):
return fridge


Expand Down Expand Up @@ -160,13 +182,6 @@ def setUp(self):
self.wf.no_hints = NoHints()
self.wf.wrong_hint = WrongHint()

def test_unfulfilled_restrictions(self):
with self.assertRaises(
ChannelConnectionError,
msg=INHERITANCE_DISCLAIMER,
):
self.wf.bookshelf.inputs.bookshelf = self.wf.assembled.outputs.assembled

def test_exceptions(self):
with self.subTest("Connected input"):
for channel in [
Expand Down Expand Up @@ -258,10 +273,8 @@ def test_input_connection_suggestions(self):
with self.subTest("Fulfilled suggestions present"):
self.assertIn(self.wf.bolts, suggestions[self.wf.assembled])

with self.subTest(
"Side effect in derived from: unfulfilled restrictions get inherited"
):
self.assertNotIn(
with self.subTest("Unfulfilled upstream restrictions do not get inherited"):
self.assertIn(
self.wf.assembled,
suggestions[self.wf.bookshelf],
msg=INHERITANCE_DISCLAIMER,
Expand Down Expand Up @@ -322,10 +335,8 @@ def test_output_connection_suggestions(self):
with self.subTest("Fulfilled suggestions present"):
self.assertIn(self.wf.assembled, suggestions[self.wf.bolts])

with self.subTest(
"Side effect in derived from: unfulfilled restrictions get inherited"
):
self.assertNotIn(
with self.subTest("Unfulfilled upstream restrictions do not get inherited"):
self.assertIn(
self.wf.bookshelf,
suggestions[self.wf.assembled],
msg=INHERITANCE_DISCLAIMER,
Expand Down Expand Up @@ -393,10 +404,8 @@ def test_input_node_suggestions(self):
"might be nice in the future.",
)

with self.subTest(
"Side effect in derived from: unfulfilled restrictions get inherited"
):
self.assertNotIn(
with self.subTest("Unfulfilled upstream restrictions do not get inherited"):
self.assertIn(
AssembleShelf,
suggestions[self.wf.bookshelf],
msg=INHERITANCE_DISCLAIMER,
Expand All @@ -419,10 +428,8 @@ def test_output_node_suggestions(self):
hinted_corpus.remove(NoHints)
self.assertListEqual(hinted_corpus, suggestions[self.wf.only_type])

with self.subTest(
"Side effect in derived from: unfulfilled restrictions get inherited"
):
self.assertNotIn(
with self.subTest("Unfulfilled upstream restrictions do not get inherited"):
self.assertIn(
PlaceBooks,
suggestions[self.wf.assembled],
msg=INHERITANCE_DISCLAIMER,
Expand Down Expand Up @@ -473,6 +480,8 @@ def test_multiple_channels(self):
msg="All correctly typed channels should be suggested.",
)

for n, c in suggest_connections(wf.single.outputs.has_nuts):
print(n.full_label, c.label)
self.assertListEqual(
[
(wf.multiple, wf.multiple.inputs.data_typed),
Expand Down
13 changes: 10 additions & 3 deletions tests/unit/test_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,22 @@ class Clothes:
@pwf.as_function_node
def Wash(
clothes: u(Clothes, uri=EX.Clothes),
) -> u(Clothes, triples=(EX.hasProperty, EX.cleaned), derived_from="inputs.clothes"):
) -> u(
Clothes,
uri=EX.Clothes,
triples=(EX.hasProperty, EX.cleaned),
derived_from="inputs.clothes",
):
...
return clothes


@pwf.as_function_node
def Dye(clothes: u(Clothes, uri=EX.Clothes), color="blue") -> u(
Clothes,
triples=(EX.hasProperty, EX.color),
uri=EX.Clothes,
derived_from="inputs.clothes",
triples=(EX.hasProperty, EX.color),
):
...
return clothes
Expand Down Expand Up @@ -436,8 +442,9 @@ def Sell(
@pwf.as_function_node
def DyeWithCancel(clothes: Clothes, color="blue") -> u(
Clothes,
triples=(EX.hasProperty, EX.color),
uri=EX.Clothes,
derived_from="inputs.clothes",
triples=(EX.hasProperty, EX.color),
cancel=(EX.hasProperty, EX.cleaned),
):
return clothes
Expand Down
Loading