User Guide#

 

This section is a practical step-by-step guide covering ways of execution workflow after setting up the environment.

Executing the Workflow#

Workflow is the organization of the work that needs to be performed into discrete units called tasks.

To execute the workflow, run the following command:

from bonsai.io import Workflow

# Initiate a workflow instance with default configurations
workflow = Workflow()
# Execute the whole workflow
workflow.execute() 

# Start executing the workflow from a certain task
workflow.execute(start="task_abc")

# Execute the workflow from a certain task till a certain task
workflow.execute(start="task_abc", stop="task_123")

Task#

Here is an example of interacting with a task in the workflow:

from bonsai.io import Config, Workflow

# Create a workflow instance
workflow = Workflow()

# List the names of all tasks registered in the workflow
workflow.list_tasks()

# Get the instance of a task
task = workflow.get_task(name = "task_name")

# Get the group name of a task
task.get_group_name()

# Get the information about a task
task

# Run the task
task.run()

# Run a specific task
workflow.run_task(name = "clean_stock_animal") # task name from .list_tasks() method

# Run a combination of several tasks
workflow.run_tasks(name_list = ["clean_stock_animal", "collect_fert_nutr"]) # any iterable collection (such as lists, tuples, or sets) of task names from .list_tasks() method

Task dependency#

When instantiating Workflow, you will receive WARNING for all tasks that have no upstream or downstream dependencies. Here is an example of checking the task dependency for specific task in the workflow:

# Get the instance of a task
task = workflow.get_task(name = "task_name")

# Check if this task has no upstream or downstream dependencies, which makes it isolated in the workflow
task.is_isolated()

# Check if the current task is a downstream task of the given task
task.is_downstream("upstream_task_name")

Configurations#

  • See all the configurable parameters by running the following command:

config = Config()
config.list_parameters()
  • Modify the configurable parameters (Default year is 2016):

Coming soon

Result analysis#

tools_to_analyze_results.py in the folder script can be used to analyze the recipes and footprints.