fix: use user-specific temp directories to avoid permission errors#151
fix: use user-specific temp directories to avoid permission errors#151tranhoangtu-it wants to merge 1 commit intoaqlaboratory:mainfrom
Conversation
Append username to default temp directory names so multiple users
on the same machine don't collide. Fixes PermissionError when
user B tries to write to directories created by user A.
Affected paths:
- /tmp/of3_colabfold_msas_{username}
- /tmp/of3_template_data_{username}
Closes aqlaboratory#150
There was a problem hiding this comment.
Pull request overview
This PR addresses multi-user /tmp permission collisions by namespacing OpenFold3’s default temp output directories with the current user identity.
Changes:
- Add a username helper and update ColabFold MSA server default output directory to
/tmp/of3_colabfold_msas_{username}. - Update template preprocessing default output directory to
/tmp/of3_template_data_{username}.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| openfold3/core/data/tools/colabfold_msa_server.py | Adds username lookup helper and updates default MSA temp directory naming to be user-specific. |
| openfold3/core/data/pipelines/preprocessing/template.py | Updates default template preprocessing temp directory naming to be user-specific. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _get_username() -> str: | ||
| """Get current username for user-specific temp directories.""" | ||
| try: | ||
| return getpass.getuser() | ||
| except Exception: | ||
| return str(os.getuid()) if hasattr(os, "getuid") else "default" | ||
| import time | ||
| import warnings |
There was a problem hiding this comment.
import time (and subsequent imports) now appear after _get_username() at module scope. This will trigger Ruff E402/I001 (imports not at top / import block split) and can break CI. Keep all imports together at the top, then define _get_username() below them (or move import time above the helper).
| server_url: Url = Url("https://api.colabfold.com") | ||
| save_mappings: bool = True | ||
| msa_output_directory: Path = Path(tempfile.gettempdir()) / "of3_colabfold_msas" | ||
| msa_output_directory: Path = Path(tempfile.gettempdir()) / f"of3_colabfold_msas_{_get_username()}" |
There was a problem hiding this comment.
This assignment line exceeds the repo's configured 88-character line length (see pyproject.toml), so ruff format --check is likely to fail. Please run ruff format or wrap the expression onto multiple lines.
| msa_output_directory: Path = Path(tempfile.gettempdir()) / f"of3_colabfold_msas_{_get_username()}" | |
| msa_output_directory: Path = ( | |
| Path(tempfile.gettempdir()) | |
| / f"of3_colabfold_msas_{_get_username()}" | |
| ) |
|
|
||
| self.output_directory = ( | ||
| self.output_directory or Path(tempfile.gettempdir()) / "of3_template_data" | ||
| self.output_directory or Path(tempfile.gettempdir()) / f"of3_template_data_{getpass.getuser()}" |
There was a problem hiding this comment.
This line likely exceeds the repo's 88-character limit and will be reformatted by ruff format --check. Please run ruff format or split the path construction across multiple lines.
| self.output_directory or Path(tempfile.gettempdir()) / f"of3_template_data_{getpass.getuser()}" | |
| self.output_directory | |
| or Path(tempfile.gettempdir()) | |
| / f"of3_template_data_{getpass.getuser()}" |
| self.output_directory = ( | ||
| self.output_directory or Path(tempfile.gettempdir()) / "of3_template_data" | ||
| self.output_directory or Path(tempfile.gettempdir()) / f"of3_template_data_{getpass.getuser()}" | ||
| ) |
There was a problem hiding this comment.
getpass.getuser() can raise in some environments (e.g., missing passwd entry / unset env vars). The PR description mentions a fallback to os.getuid(), but this call doesn't have one, so this change can still fail at runtime. Consider reusing the same helper/fallback logic used in colabfold_msa_server.py when building the temp directory name here.
Summary
Append current username to default temp directory names to prevent
PermissionErroron multi-user machines.Changes
colabfold_msa_server.py:/tmp/of3_colabfold_msas→/tmp/of3_colabfold_msas_{username}template.py:/tmp/of3_template_data→/tmp/of3_template_data_{username}Uses
getpass.getuser()with fallback toos.getuid().Test plan
Closes #150