Skip to content

add flux adapter - #1037

Open
Oglopf wants to merge 3 commits into
masterfrom
add-flux-adapter
Open

Oglopf wants to merge 3 commits into
masterfrom
add-flux-adapter

Conversation

@Oglopf

@Oglopf Oglopf commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a native job adapter for Flux (adapter: "flux"), for sites that run Flux as their system scheduler. Today the only route is the PSI/J adapter with a Flux executor, which needs Python and the Flux bindings on the submit host and hides Flux-specific job detail.

It's built on the flux CLI:

Adapter method Flux command
submit flux batch (script on stdin)
info, status flux jobs --json ID
info_all / info_where_owner flux jobs --json -A / -u USER
hold / release flux job urgency ID hold / default
delete flux cancel ID

Supports job dependencies (after maps to afterstart). No job arrays: submitting one raises instead of being silently ignored.

Related issue

Closes #1035

Testing

  • Tests included
  • No tests needed — reason: ___

50 minitests in test/job/adapters/flux_test.rb. The flux jobs --json fixtures are real output from flux-core 0.89.0 (fluxrm/flux-sched) for running, held, pending, time-limited and canceled jobs, plus the real error text for unknown job IDs. Several behaviors below were checked by hand against that instance and are noted in the tests.

Checklist

  • Follows project code style and conventions
  • Documentation provided (if new feature, adapter or behavior change)
  • This is a large feature and was discussed in an issue first (if applicable)

Docs for the adapter config (bin, bin_overrides, submit_host, strict_host_checking, flux_uri) will follow in ood-documentation.

Anything else?

Things worth a close look:

  • Job IDs are returned in decimal. Flux prints F58 IDs (ƒiFkbMhFM) by default, which don't belong in URLs, file paths or batch connect session files. The decoder is checked against real ID pairs, and every flux command accepts decimal as input.

  • Output is treated as UTF-8 regardless of locale. F58 IDs appear in error messages too (ƒ68GN: unknown job id). Under a C locale, matching that text raised ArgumentError, so delete on an unknown job crashed instead of being ignored. Same class of fix as the Slurm adapter's UTF-8 change in force utf-8 encoding #842.

  • One slot by default. flux batch refuses to submit without a size, so the adapter adds -n 1 unless cores or native args (-N, -n, --nodes, --nslots) already size the job.

  • The environment, the main design decision. Flux copies the whole submit environment by default, so with copy_environment unset the adapter clears it with --env=-*, matching what other adapters do. Checked against a real instance, that leaves jobs with no HOME, USER or PATH, and a #!/bin/bash -l login shell doesn't bring PATH back. Slurm avoids this because --export=NONE implies --get-user-env; Flux has no equivalent. So, following the Kubernetes adapter's default_env, the adapter sets:

    • USER, LOGNAME, HOME and SHELL from the user database (not the PUN's environment)
    • a system PATH, with the configured bin: directory first so flux run works inside batch scripts

    job_environment overrides any of these. Open question for Flux sites: is a fixed system PATH right, or do sites expect something from their own job shell config?

  • User lookup is by uid, not Etc.getlogin. The Kubernetes adapter uses getlogin, which can return nil in a process with no terminal, like a PUN. That's possibly a latent issue there, out of scope here.

  • Not yet covered by real output: FAILED and TIMEOUT results (the test instance had one node, so those jobs stayed queued), and multi-job info_all output. The {"jobs": [...]} wrapper is confirmed against real output, but the test assembles its jobs from single-job fixtures. Both get replaced by recordings once scheduler_recordings has a Flux backend.

  • Out of scope for v1: cluster_info, per-job GPU counts (would need flux job info ID R per job), job arrays, and Flux instances nested inside another scheduler's allocation.

🤖 Generated with Claude Code

Oglopf and others added 2 commits October 9, 2026 10:30
Matches the other adapters since #1014: the Flux adapter passes native
straight to flux batch, so it takes a list, and anything else now gets
the same clear JobAdapterError instead of failing later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@johrstrom johrstrom self-assigned this Oct 14, 2026
Comment thread lib/ood_core/job/adapters/flux.rb Outdated

# Object used for simplified communication with Flux
# @api private
class Batch

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.

I wonder if it's better to split these files up? I always get sort of lost looking at slurm with everything in one file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Haha, same and I agree. Split Batch into flux/batch.rb and JobId into flux/job_id.rb, same layout as the LSF and SGE adapters. flux.rb is now just the factory and the adapter. I left the info parsing in flux.rb so the adapter methods sit next to what they return, but happy to pull that out too if you’d rather. And looking at what was recently done with Slurm maybe I should just go ahead and do that actually.

Following review, and the layout the LSF and SGE adapters use:

- flux/batch.rb: Batch, which runs the flux CLI and parses its JSON
- flux/job_id.rb: JobId, the F58 to decimal conversion
- flux.rb: the factory and the adapter (submit, info, state mapping)

A pure move: constant names are unchanged, so callers and tests are
untouched. The split files use the compact class form, like
lsf/batch.rb, and are required from inside the Flux class body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Add Adapter for Flux Scheduler

2 participants