pyiron / pyiron_workflow

Graph-and-node based workflows
BSD 3-Clause "New" or "Revised" License
12 stars 1 forks source link

[minor] Make `Function` IO info available at the class level #266

Closed liamhuber closed 7 months ago

liamhuber commented 7 months ago

This will be useful for building nodes that take other node classes as input and want to build their own corresponding IO based on that class's IO without having to instantiate it first. It also borders on necessary for the long-term goal of being able to suggest nodes to users based on ontological (or regular...) type hints ala ironflow.

Example:

from pyiron_workflow import Workflow

@Workflow.wrap_as.function_node("xplus1", "xminus1")
def PlusMinusBound0(x: int) -> tuple[int, int | None]:
    return x + 1, None if x - 1 < 0 else x - 1

print(PlusMinusBound0.preview_output_channels())
>>> {'xplus1': int, 'xminus1': int | None}

print(PlusMinusBound0.preview_input_channels())
>>> {'x': (<class 'int'>, NOT_DATA)}

Tasks:

Non-goals:

Minor bump as the signature for AbstractFunction has changed.

github-actions[bot] commented 7 months ago

Binder :point_left: Launch a binder notebook on branch _pyiron/pyiron_workflow/class_channelspecs

codacy-production[bot] commented 7 months ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.05% (target: -1.00%) :white_check_mark: 98.46%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (52497d602cb374048145c9c54d93412f7839a66e) | 3411 | 2991 | 87.69% | | | Head commit (98d457080dc53ef38554b73e6f95c5303eeab3b0) | 3418 (+7) | 2999 (+8) | 87.74% (**+0.05%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#266) | 65 | 64 | **98.46%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

liamhuber commented 7 months ago

Windows unit tests failed with

graphviz.backend.execute.CalledProcessError: Command '[WindowsPath('dot'), '-Kdot', '-Tpdf', '-O', 'start_graph']' returned non-zero exit status 1. [stderr: b'Warning: Could not load "C:\\Miniconda3\\envs\\my-env\\Library\\bin\\gvplugin_pango.dll" - It was found, so perhaps one of its dependents was not.  Try ldd.\r\nWarning: Could not load "C:\\Miniconda3\\envs\\my-env\\Library\\bin\\gvplugin_pango.dll" - It was found, so perhaps one of its dependents was not.  Try ldd.\r\nFormat: "pdf" not recognized. Use one of: bmp canon cmap cmapx cmapx_np dot dot_json emf emfplus eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 metafile mp pdf pic plain plain-ext png pov ps ps2 svg tif tiff tk webp xdot xdot1.2 xdot1.4 xdot_json\r\n']

Doesn't look directly related to these changes, but I might need to go back and pin graphviz to some other version.

liamhuber commented 7 months ago

Yyyep.

======================================================================
ERROR: test_draw (test_node.TestNode.test_draw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Miniconda3\envs\my-env\Lib\site-packages\graphviz\backend\execute.py", line 88, in run_check
    proc.check_returncode()
  File "C:\Miniconda3\envs\my-env\Lib\subprocess.py", line 502, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '[WindowsPath('dot'), '-Kdot', '-Tpdf', '-O', 'start_graph']' returned non-zero exit status 1.
liamhuber commented 7 months ago

Windows error needs to be fixed, but it's from graphviz and unrelated to these changes.