Running and visualizing nodes¶
The run and the viz functions are companion tools that allow you to execute and visualize the nodes defined in your code.
Run¶
Running nodes with Ordeq is as simple as calling the run function from the ordeq package:
| main.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
This function accepts any number of functions, modules, or packages as input and will execute the nodes defined within them.
This allows you to adapt the structure of your codebase to the complexity of your project.
For small projects, you might keep everything in a single script.
To run all nodes defined in that script, simply pass the module itself to run:
| main.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
For larger projects, you can organize your nodes into separate modules or packages.
For example, separating nodes into a different module nodes.py with identical functionality:
| main.py | |
|---|---|
1 2 3 4 5 | |
| nodes.py | |
|---|---|
1 2 3 4 5 6 | |
Modular pipelines¶
You can run pipelines multiple times with different inputs using run.
We refer to this as modular pipelines.
This is particularly useful when you want to reuse a pipeline for different data or configurations without duplicating code.
For example, Ordeq uses this pattern in the ordeq_dev_tools package to generate release notes for multiple packages:
| main.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
What is happening here is that for each package name in package_names, the run function is called with the generate_release_notes pipeline.
The io argument is used to provide specific inputs to the nodes within that pipeline, replacing the placeholders in generate_release_notes.
This allows the same pipeline to be executed multiple times with different inputs, creating clarity and modularity in the code.
Logging¶
By default, Ordeq logs execution progress using the INFO level.
The default Python logging level is WARNING, so to see Ordeq logs, you need to set the logging level to INFO or lower:
| main.py | |
|---|---|
1 2 3 4 5 6 7 8 | |
Viz¶
The viz function from the ordeq_viz package allows you to visualize the nodes and their dependencies in a graph format:
| main.py | |
|---|---|
1 2 3 4 5 6 | |
Just as run, the viz function accepts functions, modules, or packages as input and will generate a visual representation of the nodes and their dependencies.
Notebooks¶
In notebook environments, you can directly visualize the graph without saving it to a file:
| notebook.ipynb | |
|---|---|
1 2 3 4 5 6 | |
Jupyter supports this since version 7.1.
Similarly for Marimo notebooks, you can display the diagram directly:
| notebook.py | |
|---|---|
1 2 3 4 5 6 | |
Combining run and viz¶
You can also combine both run and viz in a single script to execute the nodes and visualize the workflow:
| main.py | |
|---|---|
1 2 3 4 5 6 7 8 | |
This is particularly powerful for debugging and understanding complex workflows.
Split screen development
Split screen view in your IDE is very handy for working with source code, run and viz outputs side by side.