Skip to content

let tempfile determine temp dir location#68

Open
rpetit3 wants to merge 1 commit into
sanger-pathogens:masterfrom
rpetit3:rp3-mkdtemp-patch
Open

let tempfile determine temp dir location#68
rpetit3 wants to merge 1 commit into
sanger-pathogens:masterfrom
rpetit3:rp3-mkdtemp-patch

Conversation

@rpetit3

@rpetit3 rpetit3 commented Jun 15, 2022

Copy link
Copy Markdown

I ran into the following issue trying to use the Seroba docker container

docker run --rm -u $(id -u):$(id -g) -v ${PWD}:/data quay.io/biocontainers/seroba:1.0.2--pyhdfd78af_1 seroba runSerotyping /data/sample7_1.fq.gz /data/sample7_2.fq.gz /data/test7
Traceback (most recent call last):
  File "/usr/local/bin/seroba", line 88, in <module>
    args.func(args)
  File "/usr/local/lib/python3.8/site-packages/seroba/tasks/sero_run.py", line 19, in run
    sero.run()
  File "/usr/local/lib/python3.8/site-packages/seroba/serotyping.py", line 468, in run
    self._run_kmc()
  File "/usr/local/lib/python3.8/site-packages/seroba/serotyping.py", line 55, in _run_kmc
    temp_dir = tempfile.mkdtemp(prefix = 'temp.kmc', dir=os.getcwd())
  File "/usr/local/lib/python3.8/tempfile.py", line 358, in mkdtemp
    _os.mkdir(file, 0o700)
PermissionError: [Errno 13] Permission denied: '/temp.kmco4ebdaal'

This PR allows tempfile to figure out where to make the temp dir (see https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir)

Python searches a standard list of directories to find one which the calling user can create files in. The list is:

The directory named by the TMPDIR environment variable.
The directory named by the TEMP environment variable.
The directory named by the TMP environment variable.
A platform-specific location:
    - On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order
    - On all other platforms, the directories /tmp, /var/tmp, and /usr/tmp, in that order.

As a last resort, the current working directory.

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.

1 participant