gada_pyrunner - Runners¶
Here is a full list of runners included in this package.
pymodule Runner¶
Can run a gada node from a Python package installed in PYTHONPATH without spawning a subprocess.
Basic Python package structure:
├── mycomponent
│ ├── __init__.py
│ ├── mynode.py
│ └── config.yml
Content of mynode.py:
def main(**kwargs):
print("hello world")
Sample config.yml:
nodes:
mynode:
runner: pymodule
module: mycomponent.mynode
entrypoint: main
Usage:
$ gada mycomponent.mynode
hello world
Full configuration¶
Based on Python package structure shown above:
nodes:
mynode:
runner: pymodule
[module: mycomponent.mynode]
[entrypoint: main]
Parameters:
module: Optional - Python module to load (default ismycomponent)entrypoint: Optional - Function to call frommodule(default ismain)
Handle command line arguments¶
The pymodule runner will call the entrypoint configured in config.yml with the
command line arguments. You can retrieve them by adding an argv parameter to
your entrypoint.
Content of mynode.py:
def main(argv, **kwargs):
print(argv)
Usage:
$ gada mycomponent.mynode 1 2
['mycomponent.mynode', '1', '2']
Note
argv[0] is the module that is loaded.