Skip to content

fix: use user-specific temp directories to avoid permission errors#151

Closed
tranhoangtu-it wants to merge 1 commit intoaqlaboratory:mainfrom
tranhoangtu-it:fix/user-specific-temp-dirs
Closed

fix: use user-specific temp directories to avoid permission errors#151
tranhoangtu-it wants to merge 1 commit intoaqlaboratory:mainfrom
tranhoangtu-it:fix/user-specific-temp-dirs

Conversation

@tranhoangtu-it
Copy link
Copy Markdown

Summary

Append current username to default temp directory names to prevent PermissionError on 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 to os.getuid().

Test plan

  • Run on multi-user machine with two different users
  • Verify each user creates their own temp directory
  • Verify single-user usage still works

Closes #150

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
Copilot AI review requested due to automatic review settings March 28, 2026 10:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +25 to 32
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
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
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()}"
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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()}"
)

Copilot uses AI. Check for mistakes.

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()}"
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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()}"

Copilot uses AI. Check for mistakes.
Comment on lines 1605 to 1607
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()}"
)
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@jandom
Copy link
Copy Markdown
Collaborator

jandom commented Mar 31, 2026

Thank you for this contribution, we've merged it with #152 and both are superseded by #158

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.

[BUG] Multi-user machine /tmp/of3-directories cause errors

3 participants