Mixins
Mixins allow to define and reuse parts of jobs in live mode and tasks in batch mode.
To define a mixin, use the top-level mixins section:
1
...
2
mixins:
3
credentials:
4
volumes:
5
- secret:some_key:/var/some_key
6
env:
7
KEY_LOCATION: /var/some_key
8
...
Copied!
Mixins can define the same properties as "job" and "task" do, except for the "id" field in batch mode. To apply a mixin, use the mixins property:
1
...
2
jobs:
3
test_a:
4
mixins: [ credentials ]
5
...
Copied!
When applied, all fields defined in the mixin will be merged into the job definition. You can apply multiple mixins simultaneously. If some of the applied mixins share a property or/and this property is defined in a task, the following rules are applied:
  • If the property is scalar (int/string/bool), the value from the job definition will be used. If the value is absent in the job definiton, it will be taken from the rightmost of the mixins that define this property.
1
mixins:
2
mix1:
3
image: example_mix1
4
mix2:
5
image: example_mix2
6
jobs:
7
job1:
8
mixins: [mix1, mix2]
9
image: example
10
job2:
11
mixins: [mix1, mix2]
Copied!
In this case, job1 will use the example image and job2 will use the example_mix2 image.
  • If the property is a list, than all lists will be concatenated.
  • If the property is a dictionary, the rule for scalar values will be applied to each value from the dictionary.
Mixins can inherit from each other:
1
mixins:
2
mix1:
3
env:
4
TEST: 1
5
mix2:
6
mixins: [ mix1 ]
7
image: example
8
``` ([#498](https://github.com/neuro-inc/neuro-flow/issues/498))
Copied!
Last modified 1mo ago
Copy link