-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added Docstrings to base.py #35
base: main
Are you sure you want to change the base?
Changes from 1 commit
609fbf4
cb506f8
1401165
b62b468
d17be27
f405abe
426efb3
4c1c11f
2d8902d
7f7899f
015d97a
bfc6d7f
4c0b16d
4f98269
89bd975
5f4076b
f9df8a5
f95567f
d896999
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""The base module of znflow.""" | ||
from __future__ import annotations | ||
|
||
import contextlib | ||
|
@@ -43,23 +44,31 @@ class NodeBaseMixin: | |
|
||
@property | ||
def uuid(self): | ||
"""A method that generates a UUID to create a hashable object for each node.""" | ||
return self._uuid | ||
|
||
@uuid.setter | ||
def uuid(self, value): | ||
"""A method that checks for an existing UUID. | ||
|
||
If no UUID exists, it sets the previously defined UUID for the node. | ||
""" | ||
if self._uuid is not None: | ||
raise ValueError("uuid is already set") | ||
self._uuid = value | ||
|
||
def run(self): | ||
"""Run Method of NodeBaseMixin.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
raise NotImplementedError | ||
|
||
|
||
def get_graph(): | ||
"""Gets Graph from the NodeBaseMixin class.""" | ||
return NodeBaseMixin._graph_ | ||
|
||
|
||
def set_graph(value): | ||
"""Sets a value for the NodeBaseMixin graph.""" | ||
NodeBaseMixin._graph_ = value | ||
|
||
|
||
|
@@ -77,29 +86,35 @@ def get_attribute(obj, name, default=_get_attribute_none): | |
@dataclasses.dataclass(frozen=True) | ||
class Connection: | ||
"""A Connector for Nodes. | ||
|
||
instance: either a Node or FunctionFuture | ||
attribute: | ||
Node.attribute | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, this is on me, but could you change this to numpy docstrings format? |
||
or FunctionFuture.result | ||
or None if the class is passed and not an attribute | ||
or None if the class is passed and not an attribute. | ||
""" | ||
|
||
instance: any | ||
attribute: any | ||
|
||
@property | ||
def uuid(self): | ||
"""Gets value of the UUID.""" | ||
return self.instance.uuid | ||
|
||
@property | ||
def result(self): | ||
"""Returns the instance and if available, also the attribute.""" | ||
if self.attribute is None: | ||
return self.instance | ||
return getattr(self.instance, self.attribute) | ||
|
||
|
||
@dataclasses.dataclass | ||
class FunctionFuture(NodeBaseMixin): | ||
""" | ||
|
||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide proper docstring, or remove entirely |
||
function: typing.Callable | ||
args: typing.Tuple | ||
kwargs: typing.Dict | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a
Raises
section