Skip to content
Snippets Groups Projects
Commit 9fa28626 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Changed workflow temp location from `$(HOME)/workspaces_tmp`...

Changed workflow temp location from `$(HOME)/workspaces_tmp` (`/root/workspaces_tmp` in the container) to `/tmp/workspaces_tmp`
parent c1a8b488
No related branches found
No related tags found
1 merge request!144Change workflow temporary directory location
Pipeline #1044 passed
......@@ -4,10 +4,10 @@
usage: tmpdir_eraser [-h] [-p PATH_TO_DIRS]
Temporary directory eraser. Removes directories created by executing workflows that are no longer in use.
Defaults to checking $(HOME)/workspaces_tmp for temporary dirs.
Defaults to checking /tmp/workspaces_tmp for temporary dirs.
optional arguments:
-h, --help show this help message and exit
-p PATH_TO_DIRS, --path-to-dirs PATH_TO_DIRS
path to Workspaces temp directories
```
\ No newline at end of file
```
......@@ -15,7 +15,7 @@ from workspaces.workflow.schema import WorkflowRequest
_DESCRIPTION = """
Temporary directory eraser. Removes directories created by executing workflows that are no longer in use.
Defaults to checking $(HOME)/workspaces_tmp for temporary dirs.
Defaults to checking /tmp/workspaces_tmp for temporary dirs.
"""
logger = logging.getLogger("tmpdir_eraser")
......@@ -77,7 +77,7 @@ def list_difference(l1: Iterable, l2: Iterable) -> Iterable:
def get_unused_dirs(
path_to_tmpdirs: str = str(Path.home()) + "/workspaces_tmp",
path_to_tmpdirs: str = "/tmp/workspaces_tmp",
) -> List[str]:
"""
Get dirs that are not used by any WorkflowRequests
......@@ -87,8 +87,7 @@ def get_unused_dirs(
"""
all_dirs = os.listdir(path_to_tmpdirs)
used_dirs = [
d[0].replace(path_to_tmpdirs + "/", "")
for d in query_for_tmpdirs(connect_to_database())
d[0].replace(path_to_tmpdirs + "/", "") for d in query_for_tmpdirs(connect_to_database())
]
# Remove used dirs from list of all dirs
unused_dirs = list_difference(all_dirs, used_dirs)
......
......@@ -137,9 +137,10 @@ class WorkflowService(WorkflowServiceIF):
"""
# 1. create a temporary directory
# TODO: decide where to put temp directory and make capo property
if not os.path.isdir(str(Path.home()) + "/workspaces_tmp"):
os.mkdir(str(Path.home()) + "/workspaces_tmp")
temp_folder = Path(mkdtemp(dir=str(Path.home()) + "/workspaces_tmp"))
temp_folder_path = "/tmp/workspaces_tmp"
if not os.path.isdir(temp_folder_path):
os.mkdir(temp_folder_path)
temp_folder = Path(mkdtemp(dir=temp_folder_path))
logger.info("Settled on temp folder %s", temp_folder)
# 2. spool each of the temp files to it
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment