Create a command¶
To create a first level command, import
from outflow.core.commands import Command, RootCommand and subclass Command and decorate with
from outflow.core.commands import Command, RootCommand @RootCommand.subcommand() class MyCommand(Command): def setup_tasks(self): # instantiate tasks and setup the workflow
This command will be available at :
$ python manage.py my_command
If you want to create subcommands of a common command (think
git commit), first create a non-invokable top level command:
@RootCommand.subcommand(invokable=False) class Git(Command): pass
This command will print its help if called directly.
Then, create a subcommand of the previous one.
@Git.subcommand(invokable=False) class Clone(Command): def setup_tasks(self): ...
Outflow ships with a bunch of useful commands, available through the
management command :
$ python -m outflow management ... or $ python manage.py management ...
python manage.py management shell
This command will execute an
IPythonTask. This is useful for development and debugging, because you are inside an outflow pipeline so you have acces to everything you would in a pipeline execution : the pipeline context, the database session, the config and settings. You can also import tasks and execute them like so (if you provide them with the expected inputs)
In : from namespace.plugin.tasks import FirstTask, SecondTask In : first_task = FirstTask() # instanciate the task In : my_input = 42 In : first_task_result = first_task(input1=my_input) # call the task with the inputs as kwargs In : second_task = SecondTask() In : second_task(first_task_result) # tasks return dictionaries so you can call the next task of the workflow directly with the result of the previous task
python manage.py management display_config
Prints the path of the configuration file.