11# Writing custom nodes
22
33In the previous tutorials and how-to guides, you learned that dependencies and products
4- can be represented as plain Python objects with {class}` pytask.PythonNode ` or as paths
5- where every {class}` pathlib.Path ` is converted to a {class}` pytask.PathNode ` .
4+ can be represented as plain Python objects with {class}` ~ pytask.PythonNode` or as paths
5+ where every {class}` pathlib.Path ` is converted to a {class}` ~ pytask.PathNode` .
66
77In this how-to guide, you will learn about the general concept of nodes and how to write
88your own to improve your workflows.
@@ -54,13 +54,13 @@ A custom node needs to follow an interface so that pytask can perform several ac
5454- Load and save values when tasks are executed.
5555
5656This interface is defined by protocols [ ^ structural-subtyping ] . A custom node must
57- follow at least the protocol {class}` pytask.PNode ` or, even better,
58- {class}` pytask.PPathNode ` if it is based on a path. The common node for paths,
59- {class}` pytask.PathNode ` , follows the protocol {class}` pytask.PPathNode ` .
57+ follow at least the protocol {class}` ~ pytask.PNode` or, even better,
58+ {class}` ~ pytask.PPathNode` if it is based on a path. The common node for paths,
59+ {class}` ~ pytask.PathNode` , follows the protocol {class}` ~ pytask.PPathNode` .
6060
6161## ` PickleNode `
6262
63- Since our {class}` PickleNode ` will only vary slightly from {class}` pytask.PathNode ` , we
63+ Since our {class}` PickleNode ` will only vary slightly from {class}` ~ pytask.PathNode` , we
6464use it as a template, and with some minor modifications, we arrive at the following
6565class.
6666
8585
8686Here are some explanations.
8787
88- - The node does not need to inherit from the protocol {class}` pytask.PPathNode ` , but you
89- can do it to be more explicit.
88+ - The node does not need to inherit from the protocol {class}` ~ pytask.PPathNode` , but
89+ you can do it to be more explicit.
9090- The node has two attributes
9191 - ` name ` identifies the node in the DAG, so the name must be unique.
9292 - ` path ` holds the path to the file and identifies the node as a path node that is
@@ -107,9 +107,10 @@ Nodes are an important in concept pytask. They allow to pytask to build a DAG an
107107generate a workflow, and they also allow users to extract IO operations from the task
108108function into the nodes.
109109
110- pytask only implements two node types, {class}` PathNode ` and {class}` PythonNode ` , but
111- many more are possible. In the future, there should probably be a plugin that implements
112- nodes for many other data sources like AWS S3 or databases. [ ^ kedro ]
110+ pytask only implements two node types, {class}` ~pytask.PathNode ` and
111+ {class}` ~pytask.PythonNode ` , but many more are possible. In the future, there should
112+ probably be a plugin that implements nodes for many other data sources like AWS S3 or
113+ databases. [ ^ kedro ]
113114
114115## References
115116
0 commit comments