local-container
Execute all the steps of the pipeline in containers. Please refer to the note on containers on building images.
- Provides a way to test the containers and the execution of the pipeline in local environment.
- Any failure in cloud native container environments can be replicated in local environments.
- Ability to provide specialized compute environments for different steps of the pipeline.
- The scalability is still constrained by the resources in local environment.
parallel executions
Run logs that use a single json (eg. file-system) are not compatible with parallel executions due to race conditions to write the same file by different processes.
Use chunked
run log stores (eg. chunked-fs).
Configuration¶
executor: local-container
config:
docker_image: <required>
enable_parallel: false # (1)
auto_remove_container: true # (2)
run_in_local: false # (3)
environment: # (4)
...
overrides: # (5)
...
- By default, all tasks are sequentially executed. Provide
true
to enable tasks within parallel or map to be executed in parallel. - Set it to false, to debug a failed container.
- Setting it to true will behave exactly like a local executor.
- Pass any environment variables into the container.
- Please refer to step overrides for more details.
The docker_image
field is required and default image to execute tasks
of the pipeline. Individual tasks can
override the global defaults of executor by providing overrides
Debugging
auto_remove_container
allows you to run the failed container independently to
identify the issue that caused the failure.
run_in_local
allows you to execute a few tasks in local environment to allow
debugging and also selectively choose which step to run in container.
Example¶
Nearly all the examples seen in concepts can be executed using
the local-container
configuration. Below is one simple example to concretely show
the patterns.
Assumed to be present at examples/configs/local-container.yaml
The docker image is a variable and dynamically set during execution.
- Use local-container executor type to execute the pipeline.
- By default, all the tasks are executed in the docker image . Please refer to building docker images
- Pass any environment variables that are needed for the container.
- Store the run logs in the file-system. runnable will handle the access to them by mounting the file system into the container.
Running the SDK defined pipelines for any container based executions happens in multi-stage process.
- Generate the
yaml
definition file by:runnable_CONFIGURATION_FILE=examples/configs/local-container.yaml python examples/concepts/simple.py
- Build the docker image with yaml definition in it, called runnable:demo in current example.
- Execute the pipeline via the runnable CLI,
runnable_VAR_default_docker_image=runnable:demo runnable execute -f runnable-pipeline.yaml -c examples/configs/local-container.yaml
- You can provide a configuration file dynamically by using the environment
variable
runnable_CONFIGURATION_FILE
. Please see SDK for more details.
For yaml based definitions, the execution order is to:
- Build the docker image with the yaml definition in it, called runnable:demo in current example.
- Execute the pipeline via the runnable CLI:
runnable_VAR_default_docker_image=runnable:demo runnable execute -f examples/concepts/simple.yaml -c examples/configs/local-container.yaml
The run log structure is the same as any other local
executions apart from
an additional code identity with the information about the docker image.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
Compatibility¶
Step override¶
Individual steps of the pipeline can over-ride the default configuration by referring to the
specific override
defined in overrides
section of the executor configuration.
override
should be defined per executor and is only applicable for that specific
executor.
Example¶
Assumed to be present at examples/executors/local-container-override.yaml
In the example below, we define the default configuration in the executor configuration.
We also provide a override custom_docker_image
which overrides some of the default
configuration parameters.
As seen in the above example, running the SDK defined pipelines for any container based executions happens in multi-stage process.
- Generate the
yaml
definition file by:runnable_CONFIGURATION_FILE=examples/executors/local-container-override.yaml python examples/executors/step_overrides_container.py
-
Build the docker image with yaml definition in it. In this example, we build two docker images.
- runnable:3.8 as the default_docker_image.
- runnable:3.9 as the custom_docker_image.
Both the docker images are same except for the python version.
- Execute the pipeline via the runnable CLI,
runnable_VAR_default_docker_image=runnable:3.8 runnable_VAR_custom_docker_image=runnable:3.9 runnable execute -f runnable-pipeline.yaml -c examples/executors/local-container-override.yaml
You should see the console output of the step 1
to be 3.8
and key to be "value"
while the python version for step 2
to be 3.9 and key to be "not-value".
For yaml based definitions, the execution order is to:
-
Build the docker image with the yaml definition in it. In this example, we build two docker images.
- runnable:3.8 as the default_docker_image.
- runnable:3.9 as the custom_docker_image.
Both the docker images are same except for the python version.
-
Execute the pipeline via the runnable CLI:
runnable_VAR_default_docker_image=runnable:3.8 runnable_VAR_custom_docker_image=runnable:3.9 runnable execute -f examples/executors/step_overrides_container.yaml -c examples/executors/local-container-override.yaml
You should see the console output of the step 1
to be 3.8
and key to be "value"
while the python version for step 2
to be 3.9 and key to be "not-value".