Merge pull request #13313 from mvdbeek/tus_config_dir

[22.01] Add config variable for setting tus upload directory
This commit is contained in:
Marius van den Beek
2022-02-08 11:15:43 +01:00
committed by GitHub
6 changed files with 35 additions and 2 deletions
+12
View File
@@ -2342,6 +2342,18 @@
:Type: str
~~~~~~~~~~~~~~~~~~~~
``tus_upload_store``
~~~~~~~~~~~~~~~~~~~~
:Description:
The upload store is a temporary directory in which files uploaded
by the tus middleware or server will be placed. Defaults to
new_file_path if not set.
:Default: ``None``
:Type: str
~~~~~~~~~~~~~~~~~~~~~
``chunk_upload_size``
~~~~~~~~~~~~~~~~~~~~~
+5
View File
@@ -622,6 +622,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
involucro_path: str
mulled_channels: List[str]
nginx_upload_store: str
tus_upload_store: str
pretty_datetime_format: str
visualization_plugins_directory: str
galaxy_infrastructure_url: str
@@ -866,6 +867,9 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
if self.nginx_upload_store:
self.nginx_upload_store = os.path.abspath(self.nginx_upload_store)
if self.tus_upload_store:
self.tus_upload_store = os.path.abspath(self.tus_upload_store)
self.object_store = kwargs.get('object_store', 'disk')
self.object_store_check_old_style = string_as_bool(kwargs.get('object_store_check_old_style', False))
self.object_store_cache_path = self._in_root_dir(kwargs.get("object_store_cache_path", self._in_data_dir("object_store_cache")))
@@ -1095,6 +1099,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
self.managed_config_dir,
self.new_file_path,
self.nginx_upload_store,
self.tus_upload_store,
self.object_store_cache_path,
self.template_cache_path,
self.tool_data_path,
@@ -1189,6 +1189,11 @@ galaxy:
# documentation for the corresponding nginx configuration.
#nginx_upload_job_files_path: null
# The upload store is a temporary directory in which files uploaded by
# the tus middleware or server will be placed. Defaults to
# new_file_path if not set.
#tus_upload_store: null
# Galaxy can upload user files in chunks without using nginx. Enable
# the chunk uploader by specifying a chunk size larger than 0. The
# chunk size is specified in bytes (default: 10MB).
@@ -1709,6 +1709,14 @@ mapping:
operations on the remote end. See the Galaxy nginx documentation for the
corresponding nginx configuration.
tus_upload_store:
type: str
required: False
desc: |
The upload store is a temporary directory in which files uploaded by the
tus middleware or server will be placed.
Defaults to new_file_path if not set.
chunk_upload_size:
type: int
default: 10485760
+4 -1
View File
@@ -600,10 +600,13 @@ class FileToolParameter(ToolParameter):
if 'session_id' in value:
# handle api upload
session_id = value["session_id"]
upload_store = trans.app.config.new_file_path
upload_store = trans.app.config.tus_upload_store or trans.app.config.new_file_path
if re.match(r'^[\w-]+$', session_id) is None:
raise ValueError("Invalid session id format.")
local_filename = os.path.abspath(os.path.join(upload_store, session_id))
if upload_store != trans.app.config.new_file_path and not os.path.exists(local_filename):
# Fallback for old chunked API, remove in 22.05
local_filename = os.path.abspath(os.path.join(trans.app.config.new_file_path, session_id))
else:
# handle nginx upload
upload_store = trans.app.config.nginx_upload_store
+1 -1
View File
@@ -1391,7 +1391,7 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf):
# TUS upload middleware
app = wrap_if_allowed(app, stack, TusMiddleware, kwargs={
'upload_path': urljoin(f"{application_stack.config.galaxy_url_prefix}/", 'api/upload/resumable_upload'),
'tmp_dir': application_stack.config.new_file_path,
'tmp_dir': application_stack.config.tus_upload_store or application_stack.config.new_file_path,
'max_size': application_stack.config.maximum_upload_file_size
})
# api batch call processing middleware