Skip to content

Commit

Permalink
Merge pull request #112 from pyiron/test_docs
Browse files Browse the repository at this point in the history
Test docs
  • Loading branch information
liamhuber authored Dec 6, 2023
2 parents e6bc551 + 662fa16 commit d221e92
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 320 deletions.
3 changes: 3 additions & 0 deletions .binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ dependencies:
- python-graphviz =0.20.1
- toposort =1.10
- typeguard =4.1.5
- ase =3.22.1
- atomistics =0.1.12
- lammps
- phonopy =2.21.0
- pyiron_atomistics =0.3.5
- pyiron-data =0.0.24
- numpy =1.26.0
3 changes: 3 additions & 0 deletions .ci_support/environment-notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
channels:
- conda-forge
dependencies:
- ase =3.22.1
- atomistics =0.1.12
- lammps
- phonopy =2.21.0
- pyiron_atomistics =0.3.5
- pyiron-data =0.0.24
- numpy =1.26.0
78 changes: 40 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,50 +36,52 @@ Nodes (including macros) can be stored in plain text, and registered by future w
Nodes can be used by themselves and -- other than being "delayed" in that their computation needs to be requested after they're instantiated -- they feel an awful lot like the regular python functions they wrap:

```python
from pyiron_workflow import Workflow
>>> from pyiron_workflow import Workflow
>>>
>>> @Workflow.wrap_as.single_value_node()
... def add_one(x):
... return x + 1
>>>
>>> add_one(add_one(add_one(x=0)))()
3

@Workflow.wrap_as.single_value_node()
def add_one(x):
return x + 1

add_one(add_one(add_one(x=0)))()
>>> 3
```

But the intent is to collect them together into a workflow and leverage existing nodes:

```python
from pyiron_workflow import Workflow

@Workflow.wrap_as.single_value_node()
def add_one(x):
return x + 1

@Workflow.wrap_as.macro_node()
def add_three_macro(macro):
macro.start = add_one()
macro.middle = add_one(x=macro.start)
macro.end = add_one(x=macro.middle)
macro.inputs_map = {"start__x": "x"}
macro.outputs_map = {"end__x + 1": "y"}

Workflow.register(
"plotting",
"pyiron_workflow.node_library.plotting"
)

wf = Workflow("add_5_and_plot")
wf.add_one = add_one()
wf.add_three = add_three_macro(x=wf.add_one)
wf.plot = wf.create.plotting.Scatter(
x=wf.add_one,
y=wf.add_three.outputs.y
)

diagram = wf.draw()

import numpy as np
fig = wf(add_one__x=np.arange(5)).plot__fig
>>> from pyiron_workflow import Workflow
>>>
>>> @Workflow.wrap_as.single_value_node()
... def add_one(x):
... return x + 1
>>>
>>> @Workflow.wrap_as.macro_node()
... def add_three_macro(macro):
... macro.start = add_one()
... macro.middle = add_one(x=macro.start)
... macro.end = add_one(x=macro.middle)
... macro.inputs_map = {"start__x": "x"}
... macro.outputs_map = {"end__x + 1": "y"}
>>>
>>> Workflow.register(
... "plotting",
... "pyiron_workflow.node_library.plotting"
... )
>>>
>>> wf = Workflow("add_5_and_plot")
>>> wf.add_one = add_one()
>>> wf.add_three = add_three_macro(x=wf.add_one)
>>> wf.plot = wf.create.plotting.Scatter(
... x=wf.add_one,
... y=wf.add_three.outputs.y
... )
>>>
>>> diagram = wf.draw()
>>>
>>> import numpy as np
>>> fig = wf(add_one__x=np.arange(5)).plot__fig

```

Which gives the workflow `diagram`
Expand Down
181 changes: 0 additions & 181 deletions pyiron_base/_tests.py

This file was deleted.

6 changes: 4 additions & 2 deletions pyiron_workflow/executors/cloudpickleprocesspool.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class CloudpickleProcessPoolExecutor(ProcessPoolExecutor):
normal.
>>> from functools import partialmethod
>>>
>>> from pyiron_contrib.executors import CloudpickleProcessPoolExecutor
>>> from pyiron_workflow.executors.cloudpickleprocesspool import (
... CloudpickleProcessPoolExecutor
... )
>>>
>>> class Foo:
... '''
Expand Down Expand Up @@ -87,7 +89,7 @@ class CloudpickleProcessPoolExecutor(ProcessPoolExecutor):
... return as_dynamic_foo
>>>
>>> @dynamic_foo()
>>> def UnpicklableCallable(unpicklable_arg):
... def UnpicklableCallable(unpicklable_arg):
... unpicklable_arg.result = "This was an arg"
... return unpicklable_arg
>>>
Expand Down
Loading

0 comments on commit d221e92

Please sign in to comment.