Skip to content

Commit

Permalink
Add new config parameter for file sources temp dir and update the web…
Browse files Browse the repository at this point in the history
…dav file source
  • Loading branch information
sanjaysrikakulam committed Sep 27, 2024
1 parent 8381c02 commit 9e23ba7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
Binary file modified doc/source/admin/file_source_templates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/source/admin/file_source_webdav_configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/source/admin/file_source_webdav_configuration_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
user_tool_section_filters: List[str]
visualization_plugins_directory: str
workflow_resource_params_mapper: str
file_source_temp_dir: str

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down Expand Up @@ -1236,6 +1237,9 @@ def _load_theme(path: str, theme_dict: dict):
else:
_load_theme(self.themes_config_file, self.themes)

if self.file_source_temp_dir:
self.file_source_temp_dir = os.path.abspath(self.file_source_temp_dir)

def _process_celery_config(self):
if self.celery_conf and self.celery_conf.get("result_backend") is None:
# If the result_backend is not set, use a SQLite database in the data directory
Expand Down Expand Up @@ -1348,6 +1352,7 @@ def check(self):
self.template_cache_path,
self.tool_data_path,
self.user_library_import_dir,
self.file_source_temp_dir,
]
for path in paths_to_check:
self._ensure_directory(path)
Expand Down
5 changes: 5 additions & 0 deletions lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ galaxy:
# cleaned up in default Celery task configuration.
#short_term_storage_cleanup_interval: 3600

# The file_source_temp_dir is a temporary directory used by file sources
# that require temporary storage for file operations.
# Defaults to new_file_path.
#file_source_temp_dir: null

# Configured FileSource plugins.
# The value of this option will be resolved with respect to
# <config_dir>.
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4089,3 +4089,9 @@ mapping:
per_host: true
desc: |
Enable the integration of the Galaxy Help Forum in the tool panel. This requires the help_forum_api_url to be set.
file_source_temp_dir:
type: str
required: false
desc: |
Directory to store temporary files for file sources. This defaults to new_file_path if not set.
18 changes: 12 additions & 6 deletions lib/galaxy/files/sources/webdav.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
except ImportError:
WebDAVFS = None

import tempfile
from typing import (
Optional,
Union,
)

from galaxy import config
from . import (
FilesSourceOptions,
FilesSourceProperties,
Expand All @@ -23,11 +23,17 @@ class WebDavFilesSource(PyFilesystem2FilesSource):

def _open_fs(self, user_context=None, opts: Optional[FilesSourceOptions] = None):
props = self._serialization_props(user_context)
use_temp_files = props.pop("use_temp_files", None)
if use_temp_files is None:
# Default to True to avoid memory issues with large files.
props["use_temp_files"] = True
props["temp_path"] = props.get("temp_path", tempfile.TemporaryDirectory(prefix="webdav_"))

# Check if 'use_temp_files' and 'temp_path' are set in the config, otherwise fallback
props["use_temp_files"] = getattr(config, 'webdav_use_temp_files', True)
temp_path = getattr(config, 'file_source_temp_dir', None)

if temp_path is None:
# Fallback to props value or use new_file_path from config
new_file_path = getattr(config, 'new_file_path')
temp_path = props.get("temp_path", new_file_path)
props["temp_path"] = temp_path

extra_props: Union[FilesSourceProperties, dict] = opts.extra_props or {} if opts else {}
handle = WebDAVFS(**{**props, **extra_props})
return handle
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/files/templates/examples/production_webdav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@
login: '{{ variables.login }}'
writable: '{{ variables.writable }}'
password: '{{ secrets.password }}'
temp_path: null # Uses /tmp as default, configure it if needed
2 changes: 0 additions & 2 deletions lib/galaxy/files/templates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class WebdavFileSourceTemplateConfiguration(StrictModel):
login: Union[str, TemplateExpansion]
password: Union[str, TemplateExpansion]
writable: Union[bool, TemplateExpansion] = False
temp_path: Optional[Union[str, TemplateExpansion]] = None
template_start: Optional[str] = None
template_end: Optional[str] = None

Expand All @@ -140,7 +139,6 @@ class WebdavFileSourceConfiguration(StrictModel):
login: str
password: str
writable: bool = False
temp_path: Optional[str] = None


FileSourceTemplateConfiguration = Union[
Expand Down

0 comments on commit 9e23ba7

Please sign in to comment.