Skip to content

fix: default TEMPDIR to system temp so S3 works with read-only CWD - #3372

Open
Shriprasad-P wants to merge 3 commits into
Netflix:masterfrom
Shriprasad-P:cursor/fix-s3-cwd-writeable-854-b94d
Open

Shriprasad-P wants to merge 3 commits into
Netflix:masterfrom
Shriprasad-P:cursor/fix-s3-cwd-writeable-854-b94d

Conversation

@Shriprasad-P

Copy link
Copy Markdown

Fixes

Fixes #854

Summary

Default TEMPDIR to tempfile.gettempdir() instead of ., so the S3 client no longer requires the current working directory to be writable.

Test plan

  • Added unit test that instantiates S3 from a read-only CWD
  • Existing S3 unit tests still pass

@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes the default Metaflow temporary directory from the current working directory to Python’s system temporary directory, allowing S3 initialization from a read-only working directory.

  • Preserves explicit METAFLOW_TEMPDIR and tmproot overrides.
  • Updates S3 documentation and remote-runtime comments to describe the new default.
  • Tests default and configured behavior in isolated subprocesses, avoiding import-time state leakage.

Confidence Score: 5/5

The PR appears safe to merge; no actionable new issue or outstanding previous finding remains.

The current implementation preserves configured overrides, uses the system temporary directory by default, and isolates import-time configuration checks in subprocesses. The earlier state-leak finding was manually resolved without an explanatory reply, and the current subprocess implementation removes the shared module-reload behavior that caused it.

Important Files Changed

Filename Overview
metaflow/metaflow_config.py Defaults TEMPDIR to tempfile.gettempdir() while preserving configuration overrides.
metaflow/plugins/datatools/s3/s3.py Updates the S3 API documentation to accurately describe temporary-directory precedence.
metaflow/plugins/aws/batch/batch_decorator.py Updates the Batch runtime comment to reflect the system temporary-directory default.
metaflow/plugins/kubernetes/kubernetes_decorator.py Updates the Kubernetes runtime comment to reflect the system temporary-directory default.
test/unit/test_s3_readonly_cwd.py Adds subprocess-isolated coverage for read-only working directories and explicit temp-directory overrides.

Reviews (4): Last reviewed commit: "Isolate S3 tempdir tests in subprocesses" | Re-trigger Greptile

Comment thread metaflow/metaflow_config.py
Comment thread test/unit/test_s3_readonly_cwd.py Outdated
@Shriprasad-P
Shriprasad-P force-pushed the cursor/fix-s3-cwd-writeable-854-b94d branch from 88d4d64 to 6c18caf Compare September 12, 2026 19:28
Shriprasad-P and others added 2 commits September 14, 2026 08:40
The S3 client was using the current working directory (CWD) as the
default location for temporary files. This caused issues when the CWD
was read-only or not writable.

Changed TEMPDIR default from '.' to tempfile.gettempdir() which uses
the system's temporary directory (typically /tmp on Unix systems).

Added test to verify S3 client works correctly in read-only directories.

Fixes Netflix#854
@Shriprasad-P
Shriprasad-P force-pushed the cursor/fix-s3-cwd-writeable-854-b94d branch from 6c18caf to e5fd50e Compare September 14, 2026 03:11
Comment thread test/unit/test_s3_readonly_cwd.py Outdated
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.

S3 client should not expect current directory to be writeable

2 participants