Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing unnecessary output folders #69

Merged
merged 3 commits into from
Sep 19, 2018
Merged

Removing unnecessary output folders #69

merged 3 commits into from
Sep 19, 2018

Conversation

vsoch
Copy link
Member

@vsoch vsoch commented Sep 18, 2018

This PR will address and close #68 by only generating a name for an output folder, and recreating the folder only given that a save is called.

@vsoch
Copy link
Member Author

vsoch commented Sep 18, 2018

@fimafurman is your approval of the PR indication that we are good to go? Just want to double check that you have checked.

@fimafurman
Copy link

fimafurman commented Sep 18, 2018 via email

@vsoch
Copy link
Member Author

vsoch commented Sep 18, 2018

okay I just added a function to cleanly generate just a name (so you will need to test again!) along with a test for the function. Notably, I like seeing in my /tmp that a folder is associated with software, so I added to the function that the temporary directories include the temporary folder with a prefix. Here is an example

from deid.utils import get_temporary_name
import os

# Default just uses prefix deid, can be for file or folder technically (it's just a name in whatever the systems temp is defined at)
tmpname = get_temporary_name()

print(tmpname)
/tmp/deid-xek2hlc8

# Note that it doesn't exist, not because we removed it, but because we used tempfile's function to get the name only
os.path.exists(tmpname)
False

# We can also specify a prefix, for example, to associate that it's the cleaner calling it
tmpname = get_temporary_name(prefix='clean')
print(tmpname)
/tmp/deid-clean-cx4ujlrr

# And if we want (not used here) we can add an extension, so it is also useful for a file
tmpname = get_temporary_name(prefix='pancakes', ext='dcm')

print(tmpname)
/tmp/deid-pancakes-t0zcn76p.dcm

@fimafurman
Copy link

fimafurman commented Sep 18, 2018 via email

@vsoch
Copy link
Member Author

vsoch commented Sep 18, 2018

okey doke. Thanks @fimafurman !

@fimafurman
Copy link

Looks good and it does not create a folder in vain, so great improvement!

@vsoch
Copy link
Member Author

vsoch commented Sep 19, 2018

okay great! Merging.

@vsoch vsoch merged commit 808bbf6 into master Sep 19, 2018
@vsoch vsoch deleted the rm/tempdir branch September 19, 2018 15:49
@vsoch
Copy link
Member Author

vsoch commented Sep 19, 2018

https://pypi.org/project/deid/0.1.18/

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.

Runaway temp folder appears to be leaked for every clean operation.
2 participants