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

Qol workflow reprs #658

Merged
merged 6 commits into from
May 2, 2023
Merged
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
1 change: 1 addition & 0 deletions .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- coveralls
- coverage
- codacy-coverage
- ipython
- matplotlib =3.7.1
- numpy =1.24.3
- pyiron_base =0.5.36
Expand Down
6 changes: 3 additions & 3 deletions notebooks/workflow_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "baec001264424daf8fbb8ca2bb4a7aad",
"model_id": "322f7f0435944dd2a35b2e6821f6d2db",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -492,7 +492,7 @@
"output_type": "stream",
"text": [
"n1 n1 n1 (GreaterThanHalf) output single-value: False\n",
"n2 n2 <pyiron_contrib.workflow.node.Node object at 0x14dabb7d0>\n",
"n2 n2 <pyiron_contrib.workflow.node.Node object at 0x1441b1990>\n",
"n3 n3 n3 (GreaterThanHalf) output single-value: False\n",
"n4 n4 n4 (GreaterThanHalf) output single-value: False\n",
"n5 n5 n5 (GreaterThanHalf) output single-value: False\n"
Expand Down Expand Up @@ -681,7 +681,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "80a9eac6-9953-4105-8c70-c1e14a698564",
"id": "cab89cc8-2409-4bdb-8b50-ccdf48e9ec5d",
"metadata": {},
"outputs": [],
"source": []
Expand Down
4 changes: 3 additions & 1 deletion pyiron_contrib/workflow/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import typing
from abc import ABC, abstractmethod
from json import dumps
from warnings import warn

from pyiron_contrib.workflow.has_channel import HasChannel
Expand Down Expand Up @@ -198,8 +199,9 @@ def __str__(self):

def to_dict(self):
d = super().to_dict()
d["value"] = self.value
d["value"] = repr(self.value)
d["ready"] = self.ready
return d


class InputData(DataChannel):
Expand Down
6 changes: 5 additions & 1 deletion pyiron_contrib/workflow/has_to_dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from abc import ABC, abstractmethod
from json import dumps

from IPython.display import JSON


class HasToDict(ABC):
@abstractmethod
Expand All @@ -10,6 +12,8 @@ def to_dict(self):
def _repr_json_(self):
return self.to_dict()

@property
def info(self):
print(dumps(self.to_dict(), indent=2))

def repr_json(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shoud be a repr_json or similar method used in notebooks to Display the object automatically as json

return JSON(self.to_dict())
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
],
'workflow': [
'python>=3.10',
'ipython',
'typeguard==3.0.2'
]
},
Expand Down