Skip to content

Commit 0f6ba88

Browse files
committed
Replace tuswsgi with tuspyserver
1 parent f23a469 commit 0f6ba88

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

lib/galaxy/dependencies/pinned-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ tomli==2.3.0 ; python_full_version < '3.11'
224224
tornado==6.5.2
225225
tqdm==4.67.1
226226
tuspy==1.1.0
227-
tuswsgi==0.5.5
227+
tuspyserver==4.2.0
228228
typing-extensions==4.15.0
229229
typing-inspection==0.4.2
230230
tzdata==2025.2

lib/galaxy/webapps/galaxy/buildapp.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from urllib.parse import urljoin
1212

1313
from paste import httpexceptions
14-
from tuswsgi import TusMiddleware
1514

1615
import galaxy.app
1716
import galaxy.datatypes.registry
@@ -1084,30 +1083,6 @@ def wrap_in_middleware(app, global_conf, application_stack, **local_conf):
10841083
from galaxy.web.framework.middleware.translogger import TransLogger
10851084

10861085
app = wrap_if_allowed(app, stack, TransLogger)
1087-
# TUS upload middleware
1088-
app = wrap_if_allowed(
1089-
app,
1090-
stack,
1091-
TusMiddleware,
1092-
kwargs={
1093-
"upload_path": urljoin(f"{application_stack.config.galaxy_url_prefix}/", "api/upload/resumable_upload"),
1094-
"tmp_dir": application_stack.config.tus_upload_store or application_stack.config.new_file_path,
1095-
"max_size": application_stack.config.maximum_upload_file_size,
1096-
},
1097-
)
1098-
# TUS upload middleware for job files....
1099-
app = wrap_if_allowed(
1100-
app,
1101-
stack,
1102-
TusMiddleware,
1103-
kwargs={
1104-
"upload_path": urljoin(f"{application_stack.config.galaxy_url_prefix}/", "api/job_files/resumable_upload"),
1105-
"tmp_dir": application_stack.config.tus_upload_store_job_files
1106-
or application_stack.config.tus_upload_store
1107-
or application_stack.config.new_file_path,
1108-
"max_size": application_stack.config.maximum_upload_file_size,
1109-
},
1110-
)
11111086
# X-Forwarded-Host handling
11121087
app = wrap_if_allowed(app, stack, XForwardedHostMiddleware)
11131088
# Request ID middleware

lib/galaxy/webapps/galaxy/fast_app.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import (
22
Any,
33
)
4+
from urllib.parse import urljoin
45

56
from a2wsgi import WSGIMiddleware
67
from fastapi import (
@@ -9,6 +10,7 @@
910
)
1011
from fastapi.openapi.constants import REF_TEMPLATE
1112
from starlette.middleware.cors import CORSMiddleware
13+
from tuspyserver import create_tus_router
1214

1315
from galaxy.schema.generics import CustomJsonSchema
1416
from galaxy.version import VERSION
@@ -165,6 +167,24 @@ def get_openapi_schema() -> dict[str, Any]:
165167
)
166168

167169

170+
def include_tus(app: FastAPI, gx_app):
171+
config = gx_app.config
172+
root_path = "" if config.galaxy_url_prefix == "/" else config.galaxy_url_prefix
173+
prefix = urljoin(root_path, "api/upload/resumable_upload")
174+
upload_tus_router = create_tus_router(
175+
prefix=prefix,
176+
files_dir=config.tus_upload_store or config.new_file_path,
177+
max_size=config.maximum_upload_file_size,
178+
)
179+
job_files_tus_router = create_tus_router(
180+
prefix=urljoin(root_path, "api/job_files/resumable_upload"),
181+
files_dir=config.tus_upload_store_job_files or config.tus_upload_store or config.new_file_path,
182+
max_size=config.maximum_upload_file_size,
183+
)
184+
app.include_router(upload_tus_router)
185+
app.include_router(job_files_tus_router)
186+
187+
168188
def initialize_fast_app(gx_wsgi_webapp, gx_app):
169189
root_path = "" if gx_app.config.galaxy_url_prefix == "/" else gx_app.config.galaxy_url_prefix
170190
app = get_fastapi_instance(root_path=root_path)
@@ -178,6 +198,7 @@ def initialize_fast_app(gx_wsgi_webapp, gx_app):
178198
include_legacy_openapi(app, gx_app)
179199
wsgi_handler = WSGIMiddleware(gx_wsgi_webapp)
180200
gx_app.haltables.append(("WSGI Middleware threadpool", wsgi_handler.executor.shutdown))
201+
include_tus(app, gx_app)
181202
app.mount("/", wsgi_handler) # type: ignore[arg-type]
182203
if gx_app.config.galaxy_url_prefix != "/":
183204
parent_app = FastAPI()

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ dependencies = [
101101
"starlette-context",
102102
"svgwrite",
103103
"tifffile",
104-
"tuswsgi",
105104
"typing-extensions",
105+
"tuspyserver",
106106
"uvicorn!=0.28.0", # https://github.com/galaxyproject/galaxy/issues/17669
107107
"uvloop>=0.21.0", # Python 3.13 support
108108
"WebOb>=1.8.9", # Python 3.13 support
@@ -257,6 +257,9 @@ constraint-dependencies = [
257257
"limits>=2.5.0", # prefer not downgrading this to upgrading packaging
258258
"scipy>=1.14.1; python_version>='3.10'", # Python 3.13 support
259259
]
260+
override-dependencies = [
261+
"fastapi; sys_platform == 'never'",
262+
]
260263
default-groups = []
261264
extra-index-url = ["https://wheels.galaxyproject.org/simple"]
262265
index-strategy = "unsafe-best-match"

0 commit comments

Comments
 (0)