Skip to content

Commit

Permalink
Merge pull request #974 from danmur97/main
Browse files Browse the repository at this point in the history
Add tags to batch jobs
  • Loading branch information
kamadorueda authored Oct 25, 2022
2 parents 22c92c3 + 76a1bd6 commit c8316d0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,9 @@ Types:
If the value of attempts is greater than one,
the job is retried on failure the same number of attempts as the value.
Defaults to `1`.
- tags (`attrsOf str`): Optional.
Tags to apply to the batch job.
Defaults to `{ }`.
- attemptDurationSeconds (`ints.positive`): Optional.
The time duration in seconds
(measured from the job attempt's startedAt timestamp)
Expand Down
8 changes: 8 additions & 0 deletions src/args/compute-on-aws-batch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
queue,
name,
setup,
tags,
vcpus,
}:
makeScript {
Expand Down Expand Up @@ -65,6 +66,13 @@ makeScript {
__argName__ = name;
__argParallel__ = parallel;
__argQueue__ = queue;
__argTags__ = let
tag_names = builtins.attrNames tags;
encode_tag = key: "${key}=${tags."${key}"}";
encoded = map encode_tag tag_names;
encoded_tags = builtins.concatStringsSep "," encoded;
in
encoded_tags;
};
searchPaths = {
bin = [
Expand Down
2 changes: 2 additions & 0 deletions src/args/compute-on-aws-batch/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function main {
local name="__argName__"
local queue="__argQueue__"
local parallel="__argParallel__"
local tags="__argTags__"
local submit_job_args

: \
Expand Down Expand Up @@ -76,6 +77,7 @@ function main {
--job-definition "${definition}"
--retry-strategy "attempts=${attempts}"
--timeout "attemptDurationSeconds=${attempt_duration_seconds}"
--tags "${tags}"
) \
&& if [ "${parallel}" -gt "1" ]; then
submit_job_args+=(--array-properties "size=${parallel}")
Expand Down
5 changes: 5 additions & 0 deletions src/evaluator/modules/compute-on-aws-batch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
inherit (config) parallel;
inherit (config) queue;
inherit (config) setup;
inherit (config) tags;
inherit (config) vcpus;
};
};
Expand Down Expand Up @@ -73,6 +74,10 @@ in {
default = [];
type = lib.types.listOf lib.types.package;
};
tags = lib.mkOption {
default = {};
type = lib.types.attrsOf lib.types.str;
};
vcpus = lib.mkOption {
type = lib.types.ints.positive;
};
Expand Down

0 comments on commit c8316d0

Please sign in to comment.