Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags to batch jobs #974

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Daniel Murcia <danmur97@outlook.com> Daniel Murcia <42251914+danmur97@users.nore
Daniel Salazar <podany270895@gmail.com> Daniel Salazar <dsalaza4@eafit.edu.co>
Daniel Salazar <podany270895@gmail.com> Daniel Salazar <dsalazar@fluidattacks.com>
Daniel Salazar <podany270895@gmail.com> Daniel Salazar <podany270895@gmail.com>
David Acevedo <dacevedoa12@gmail.com> David Acevedo <dacevedoa12@gmail.com>
David Arnold <david.arnold@iohk.io> David Arnold <david.arnold@iohk.io>
David Arnold <david.arnold@iohk.io> David Arnold <dgx.arnold@gmail.com>
Diego Restrepo <drestrepo@fluidattacks.com> Diego Restrepo Mesa <36453706+drestrepom@users.noreply.github.com>
Expand Down
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
4 changes: 2 additions & 2 deletions src/args/make-node-js-modules/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function main {
&& case "${bin_type}" in
object)
info Generating binaries from "${package_json}" \
&& jq -er '.bin | to_entries[].key' < "${package_json}" > bins.lst \
&& jq -er '.bin | to_entries[].value' < "${package_json}" > bin_locations.lst \
&& jq -r '.bin | to_entries[].key' < "${package_json}" > bins.lst \
&& jq -r '.bin | to_entries[].value' < "${package_json}" > bin_locations.lst \
&& mapfile -t bins < bins.lst \
&& mapfile -t bin_locations < bin_locations.lst \
&& for ((index = 0; index < "${#bins[@]}"; index++)); do
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