Edit this page on our live server and create a PR by running command !create-pr in the console panel

The depends statement

  • Difficulty level: easy
  • Time need to lean: 10 minutes or less
  • Key points:
    • Step depends accepts regular Python aguments
    • Step depends are usually used to create dependencies but variables _depends can be used directly

The depends statement defines the dependency targets of a SoS step and are usually used to create step dependencies. You can check out the How to create dependencies between SoS steps tutorial for a quick overview of the use of input statements.

Direct input of unnamed or named dependency files

Similar to the list of input files in the input: statement, you can list dependency files in depends statement.

In [1]:
[###] 3 steps processed (3 jobs completed)

Depends on another step

You can explicitly depend on another step as a way to execute another step before the step:

In [2]:
[##] 2 steps processed (2 jobs completed)

Depends on variables shared by another step

Another usage is that if you step depends on a variable that is generated from another step, you have to shared the variable from the step that generates it, and depends on the variable in the step that uses it.

In [3]:
[##] 2 steps processed (2 jobs completed)

Depends on other types of targets such as system resource

SoS allows many the use of many types of targets, which are generally speaking object that you can check its existence. You can check the existence of libraries (and install them if not available in some cases), and check the available of certain executables, or if your system has the required resources. These targets generally are used in the depends statement of steps.

For example, the following workflow checks if command file exists before running the shell script that uses it.

In [4]:
depends_statement.ipynb: ASCII text, with very long lines