Skip to content

Add consumableResources process directive for AWS Batch#6957

Closed
robsyme wants to merge 7 commits into
masterfrom
feat/aws-consumable-resource-directive
Closed

Add consumableResources process directive for AWS Batch#6957
robsyme wants to merge 7 commits into
masterfrom
feat/aws-consumable-resource-directive

Conversation

@robsyme

@robsyme robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add consumableResources process directive that maps to AWS Batch resource-aware scheduling
  • Enables license-seat-aware job scheduling — AWS Batch holds jobs in RUNNABLE until consumable resources are available
  • Supports string shorthand (consumableResources 'my-license' implies quantity 1), map syntax (consumableResources 'lic': 2), and is repeatable across multiple calls

Usage

process runDragen {
    consumableResources 'my-dragen-license'
    cpus 4
    memory '16 GB'

    script:
    """
    dragen --ref-dir /ref ...
    """
}

Implementation

  • Core module: Directive registered in ProcessBuilder.DIRECTIVES, handler methods for string/map syntax with ConfigList accumulation, TaskConfig.getConsumableResources() getter normalizing all input forms
  • nf-lang: ProcessDsl.DirectiveDsl updated for config validation
  • nf-amazon plugin: AwsBatchTaskHandler.configJobDefRequest() maps directive to ConsumableResourceProperties on RegisterJobDefinitionRequest via RegisterJobDefinitionModel; included in job definition hash
  • Docs: Full directive documentation in docs/reference/process.md with FIFO queue ordering caveat; added to AWS Batch executor's supported directives list

Closes #5917

Test plan

  • ProcessBuilderTest — string shorthand, map syntax, multi-resource, repeatable accumulation
  • TaskConfigTest — Map normalization, List passthrough, String shorthand, null handling
  • AwsBatchTaskHandlerTest — single resource, multiple resources, absent directive, hashing, no regression on existing tests
  • Full nf-amazon plugin test suite passes
  • Core module smoke tests pass (3 pre-existing failures unrelated to this change)
  • Live validation with AWS Batch consumable resource

🤖 Generated with Claude Code

@robsyme robsyme requested review from a team as code owners March 23, 2026 18:24
@netlify

netlify Bot commented Mar 23, 2026

Copy link
Copy Markdown

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 66a336a
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69c1aba5a98cf00007690024

@pditommaso

Copy link
Copy Markdown
Member

i'd prefer mapping this to a custom resource label instead of introducing yet another directive

@robsyme

robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

Re: resource labels - interesting approach.
I had considered resourceLabels as a way of tagging infrastructure pieces - a write-only feature - not something that would hold up or modify the execution.

@robsyme

robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

And to confirm - I have tested this one using real consumable resources.

image

... which causes the jobs to wait as expected:
CleanShot 2026-03-23 at 15 55 48

@bentsherman

Copy link
Copy Markdown
Member

@pditommaso if we implement this with a resource label, we'll have to think about how to namespace it properly. Let me know what you think:

// alt 1
resourceLabels 'consumable-resource:my-dragen-license': 1

// alt 2
resourceLabels 'consumable-resource': 'my-dragen-license=1'

@pditommaso

Copy link
Copy Markdown
Member

Maybe more the second, tho don't have a strong opinion, we should eval pros & cons of different syntax, including the need for sched.

Another option to avoid overloading the resourceLabels directive could be to introduce a dedicated one named hints or computeHints, or something along those lines

@bentsherman

Copy link
Copy Markdown
Member

I really like the idea of a hints directive or something like that. Same structure as resourceLabels but avoids the unintended side-effect of extra labels

@robsyme

robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

I'd definitely prefer hints (or similar) to overloading resourceLabels

@pditommaso

Copy link
Copy Markdown
Member

🙌

@robsyme

robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

If @bentsherman or @pditommaso give me a 👍 on this comment, I'll move this PR to hints with a "consumable-resource" namespace/prefix.

@pditommaso

Copy link
Copy Markdown
Member

Feel free to draft as non-binding. It'd be good to draft a spec/adr separately to "formalise" the new directive name/syntax etc.

@pditommaso

Copy link
Copy Markdown
Member

** separately ** 😄

@robsyme

robsyme commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator Author

Hahaha. I'll pull back the ADR and limit this PR to just the (draft) implementation

ADR (with real human input) for discussion: #6960

robsyme and others added 7 commits March 23, 2026 17:06
Add field, builder method, getter, and wire into toBatchRequest()
for AWS Batch consumable resource support.

Ref: #5917

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Register 'consumableResources' in the DIRECTIVES list and add handler
methods for string shorthand (implies quantity 1) and map syntax.
Repeatable — multiple calls accumulate into a ConfigList.

Ref: #5917

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Normalizes both DSL-accumulated ConfigList (list of [name, quantity]
pairs) and config-provided Map syntax into a uniform List<List>
representation.

Ref: #5917
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Map the consumableResources process directive to
ConsumableResourceProperties on RegisterJobDefinitionRequest.
Include consumable resources in the job definition hash to ensure
different resource configurations produce distinct job definitions.

Ref: #5917

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Document the new directive in the process reference with syntax
examples (string shorthand, map, repeatable), FIFO queue ordering
caveat, and AWS prerequisites. Add to the AWS Batch executor's
supported directives list.

Ref: #5917
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Register consumableResources in ProcessDsl.DirectiveDsl so the config
validator recognizes process.consumableResources. Handle plain String
input in TaskConfig.getConsumableResources() (e.g. from config
`process.consumableResources = 'my-license'`) by treating it as
quantity 1, matching the DSL shorthand behavior.

Ref: #5917
Signed-off-by: Rob Syme <rob.syme@gmail.com>
Replace the narrow consumableResources directive with a generic hints
directive that uses namespaced keys. The hints directive accepts a map
and is repeatable (multiple calls merge), following the resourceLabels
pattern.

The AWS Batch executor consumes consumable-resource:* prefixed hints
and maps them to ConsumableResourceProperties on the job definition.
Non-matching hints are silently ignored.

Syntax:
  hints 'consumable-resource:my-license': 1

Config:
  process.hints = ['consumable-resource:my-license': 1]

Ref: #5917
Signed-off-by: Rob Syme <rob.syme@gmail.com>
@robsyme robsyme force-pushed the feat/aws-consumable-resource-directive branch from 5e88d83 to 66a336a Compare March 23, 2026 21:07
@bentsherman

Copy link
Copy Markdown
Member

Closing in favor of #7034

@bentsherman bentsherman deleted the feat/aws-consumable-resource-directive branch May 20, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for AWS Batch Consumable Resources

3 participants