Skip to content

fix: fall back from an inherited TMPDIR the container cannot write - #68

Merged
DimaMolod merged 1 commit into
mainfrom
fix/issue-65-container-tmpdir
Oct 13, 2026
Merged

DimaMolod merged 1 commit into
mainfrom
fix/issue-65-container-tmpdir

Conversation

@DimaMolod

Copy link
Copy Markdown
Collaborator

A SLURM prolog can set TMPDIR to job-local scratch (here /scratch/jobs/<jobid>) that is not bound into the container. Python's tempfile silently skips an unwritable TMPDIR, but XLA's ptxas writes its tmpxft_* files there directly and aborts. In the October campaign that failed 151 AF3 inference jobs, and every retry inherited the same path.

This implements option 1 from the issue.

Changes

  • container_tmpdir_guard() in rules/common.smk returns a bash prologue that runs inside the container:
    • it keeps $TMPDIR when it is a writable, searchable directory;
    • otherwise it switches to container_tmpdir (default /tmp) and logs one [container-tmpdir] line;
    • if the fallback is unusable too, it exits 1 before any work starts.
  • All six container rules run it first: create_mmseqs2_gpu_msa_shard, finalize_mmseqs2_features, create_features, structure_inference, analyze_structure, recursive_report. It is passed as a callable param, because Snakemake applies wildcards to string params and would try to format ${TMPDIR:-}.
  • container_tmpdir in config/config.yaml, and a README troubleshooting entry for ptxas fatal: Could not open output file … tmpxft_*.

Testing

  • Reproduced first. A new test renders the real structure_inference shell with a dry run, then runs its prologue under set -euo pipefail with TMPDIR below an unbound path and writes a tmpxft_* file natively.
    • On main it fails with …/job-tmp/tmpxft_regression: Not a directory.
    • With the guard it passes and logs the fallback once.
  • Strict-bash tests of the guard:
    • unset or empty TMPDIR;
    • usable scratch kept without a log line, whether it exists or can be created;
    • read-only and unsearchable directories fall back;
    • an unusable fallback (a file, read-only, unsearchable) stops before any work;
    • a fallback path containing spaces, quotes, $, backticks and braces stays literal.
  • Coverage test. A dry-run test parses the Snakefile for every container: rule and checks that each renders with the guard first, in both feature modes. A new container rule without the guard fails it.
  • Full suite: 188 passed, 1 skipped; with Local MMseqs2: a database rebuilt in place under the same identifier is never re-searched #56 and Inference memory settings are coupled: base RAM is also the unified-memory margin, the host coefficient also routes GPUs, and retries barely escalate #66 merged on top, 213 passed, 1 skipped.
  • Not run: containers or GPU inference on the cluster.

Notes

  • Option 2 (APPTAINERENV_TMPDIR=/tmp) was not used. It always overrides, including a bound and faster job-local TMPDIR; the guard leaves those alone.
  • container_tmpdir adds no bind mount. A fallback outside the container's default mounts has to be bound by the site.

Closes #65.

🤖 Generated with Claude Code

A site prolog can set TMPDIR to job-local scratch that is not bound into
the container. Python's tempfile silently skips it, but native tools such
as XLA's ptxas write there directly and abort, and every retry inherits
the same path.

Every container rule now starts with a bash guard that keeps a writable,
searchable TMPDIR, otherwise switches to container_tmpdir (default /tmp)
with one [container-tmpdir] log line, and stops before any work if the
fallback itself is unusable.

Closes #65.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DimaMolod
DimaMolod merged commit 85b60f5 into main Oct 13, 2026
2 checks passed
@DimaMolod
DimaMolod deleted the fix/issue-65-container-tmpdir branch October 13, 2026 08:10
DimaMolod added a commit that referenced this pull request Oct 13, 2026
docs: take back the README additions from #68 and #70
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.

Container rules inherit a host TMPDIR that isn't bound inside the container, so XLA's ptxas fails

1 participant