Skip to content

feat: make --aws-batch-job-role optional for pre-existing job definitions#52

Open
nh13 wants to merge 2 commits into
snakemake:mainfrom
nh13:nh_preflight-job-def-role-combo
Open

feat: make --aws-batch-job-role optional for pre-existing job definitions#52
nh13 wants to merge 2 commits into
snakemake:mainfrom
nh13:nh_preflight-job-def-role-combo

Conversation

@nh13

@nh13 nh13 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

A pre-existing job definition (--aws-batch-job-definition) carries its own role, so the plugin rejects --aws-batch-job-role in that mode. But job_role was required: True at the settings layer, forcing users to supply the very flag pre-existing mode rejects — so the setting-level pre-existing path was effectively unusable (it always tripped the "cannot combine" guard).

This makes job_role optional at the settings layer and enforces it conditionally in the startup preflight check:

  • Reject --aws-batch-job-role combined with --aws-batch-job-definition (fail fast, before any queue/IAM call).
  • Require --aws-batch-job-role in the default register-per-job mode, where it is baked into each registered definition — preserving the previous guarantee, now enforced in preflight rather than by required: True.

Docs and unit tests updated. Stacked on #49 (preflight validation); the first commit is #49's and will drop out once that merges.

Summary by CodeRabbit

  • New Features

    • Added AWS Batch startup validation to detect invalid queues, compute environments, and missing IAM roles before jobs are submitted.
    • Added conditional validation for job definitions and job roles, with clear errors for incompatible or incomplete settings.
    • Transient AWS errors and unavailable permissions produce warnings while allowing execution to continue.
  • Documentation

    • Documented preflight checks, required permissions, and job definition/job role configuration rules.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nh13, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22ff1edf-b43c-4271-b297-5e93fbbedc94

📥 Commits

Reviewing files that changed from the base of the PR and between 65a84ea and 938a7d1.

📒 Files selected for processing (4)
  • docs/further.md
  • snakemake_executor_plugin_aws_batch/__init__.py
  • tests/test_preflight.py
  • tests/tests_mocked_api.py
📝 Walkthrough

Walkthrough

The executor now performs AWS Batch and optional IAM role preflight validation during startup, failing on confirmed misconfiguration while continuing through uncertain API or permission states. Documentation and tests cover these checks and mocked workflows bypass them.

Changes

AWS Batch preflight validation

Layer / File(s) Summary
Preflight orchestration and configuration checks
snakemake_executor_plugin_aws_batch/__init__.py, docs/further.md
Startup validation invokes Batch checks, applies conditional job-role rules, and documents pre-existing job-definition behavior.
Batch and IAM resource checks
snakemake_executor_plugin_aws_batch/__init__.py, docs/further.md
Queue, compute-environment, and IAM role checks distinguish confirmed failures from transient, permission, or otherwise uncertain conditions.
Preflight behavior coverage
tests/test_preflight.py, tests/tests_mocked_api.py
Tests cover invalid resources, recoverable states, role errors, conditional configuration, and mocked workflows that bypass AWS-backed preflight calls.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Executor
  participant AWS Batch
  participant IAM
  Executor->>AWS Batch: Describe job queue and compute environments
  AWS Batch-->>Executor: Return resource states
  Executor->>IAM: Get configured role
  IAM-->>Executor: Return role or error
  Executor-->>Executor: Fail on confirmed misconfiguration or continue
Loading

Possibly related PRs

Suggested reviewers: cademirch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making --aws-batch-job-role optional when using a pre-existing job definition.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nh13
nh13 force-pushed the nh_preflight-job-def-role-combo branch 2 times, most recently from 12733ce to d82bf31 Compare July 16, 2026 17:26
@nh13 nh13 changed the title feat: fail fast at preflight when job_definition and job_role are combined feat: make --aws-batch-job-role optional for pre-existing job definitions Jul 16, 2026
@nh13
nh13 force-pushed the nh_preflight-job-def-role-combo branch from d82bf31 to 65a84ea Compare July 16, 2026 18:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@snakemake_executor_plugin_aws_batch/__init__.py`:
- Around line 457-467: Update the compute-environment validation loop in the
preflight logic to aggregate usability across all queue-attached compute
environments rather than adding a fatal problem for each individual disabled,
invalid, or zero-capacity environment. Only report failure when every attached
compute environment is unusable, while allowing execution when at least one is
healthy; add a regression test covering a queue with mixed healthy and unhealthy
compute environments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 01a10571-f671-49fb-9193-a8ed11f5b5ef

📥 Commits

Reviewing files that changed from the base of the PR and between bc0a9af and 65a84ea.

📒 Files selected for processing (4)
  • docs/further.md
  • snakemake_executor_plugin_aws_batch/__init__.py
  • tests/test_preflight.py
  • tests/tests_mocked_api.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/tests_mocked_api.py
  • docs/further.md
  • tests/test_preflight.py

Comment thread snakemake_executor_plugin_aws_batch/__init__.py
nh13 added 2 commits July 16, 2026 14:11
…role

Run a best-effort validation in __post_init__, before any job is submitted, so
a definitively misconfigured setup fails fast with a clear error instead of
leaving jobs stuck forever:

- _queue_problems(): inspect the configured job queue and its compute
  environment(s); report a disabled/invalid queue or compute environment, a
  fatal queue status (INVALID/DELETING/DELETED), or maxvCpus=0.
- _preflight_validate(): raise WorkflowError on any confirmed problem, then
  check the job role.
- _validate_job_role(): iam:GetRole existence check; NoSuchEntity fails fast,
  anything else (most importantly a missing iam:GetRole permission) degrades.

The check is conservative about uncertainty: a transient API error, a queue
mid-update, or a missing describe/iam permission degrades to a debug message
and the workflow proceeds. Only a confirmed-bad configuration blocks. Documented
in docs/further.md; the workflow-level mocked test short-circuits preflight the
same way it short-circuits platform detection.
…ions

A pre-existing job definition (`--aws-batch-job-definition`) carries its own role, so the plugin rejects `--aws-batch-job-role` in that mode. But `job_role` was `required: True`, forcing users to supply the very flag pre-existing mode rejects — making the setting-level pre-existing path unusable.

Make `job_role` optional at the settings layer and enforce it conditionally in the preflight check: fail fast when it is combined with `--aws-batch-job-definition`, and when it is omitted in the default register-per-job mode (where it is baked into each registered definition). Update the docs and tests accordingly.
@nh13
nh13 force-pushed the nh_preflight-job-def-role-combo branch from 65a84ea to 938a7d1 Compare July 16, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant