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

Support running multiple tusds and controlling the value of hooks-http #119

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gravity/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ class TusdSettings(BaseModel):
upload_dir: str = Field(description="""
Directory to store uploads in.
Must match ``tus_upload_store`` setting in ``galaxy:`` section.
""")
hooks_http: str = Field(default="/api/upload/hooks", description="""
Value of tusd -hooks-httpd option

the default of is suitable for using tusd for Galaxy uploads and should not be changed unless you are using tusd for
other purposes such as Pulsar staging.

The value of galaxy_infrastructure_url is automatically prepended if the option starts with a `/`
""")
hooks_enabled_events: str = Field(default="pre-create", description="""
Comma-separated string of enabled tusd hooks.
Expand Down Expand Up @@ -377,7 +385,7 @@ class Settings(BaseSettings):
gx_it_proxy: GxItProxySettings = Field(default={}, description="Configuration for gx-it-proxy.")
# The default value for tusd is a little awkward, but is a convenient way to ensure that if
# a user enables tusd that they most also set upload_dir, and yet have the default be valid.
tusd: TusdSettings = Field(default={'upload_dir': ''}, description="""
tusd: Union[List[TusdSettings], TusdSettings] = Field(default={'upload_dir': ''}, description="""
Configuration for tusd server (https://github.com/tus/tusd).
The ``tusd`` binary must be installed manually and made available on PATH (e.g in galaxy's .venv/bin directory).
""")
Expand Down
9 changes: 6 additions & 3 deletions gravity/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,20 @@ def _validate_settings(cls, v, values):
class GalaxyTUSDService(Service):
_service_type = "tusd"
service_name = "tusd"
_service_list_allowed = True
_graceful_method = GracefulMethod.NONE
_command_template = "{settings[tusd_path]} -host={settings[host]} -port={settings[port]}" \
" -upload-dir={settings[upload_dir]}" \
" -hooks-http={app_config[galaxy_infrastructure_url]}/api/upload/hooks" \
" -hooks-http={settings[hooks_http]}" \
" -hooks-http-forward-headers=X-Api-Key,Cookie {settings[extra_args]}" \
" -hooks-enabled-events {settings[hooks_enabled_events]}"

@validator("settings")
def _validate_settings(cls, v, values):
if not values["config"].app_config["galaxy_infrastructure_url"]:
gravity.io.exception("To run tusd syou need to set galaxy_infrastructure_url in the galaxy section of galaxy.yml")
if v["hooks_http"].startswith("/"):
if not values["config"].app_config["galaxy_infrastructure_url"]:
gravity.io.exception("To run tusd you need to set galaxy_infrastructure_url in the galaxy section of galaxy.yml")
v["hooks_http"] = f'{values["config"].app_config["galaxy_infrastructure_url"]}{v["hooks_http"]}'
return v


Expand Down
Loading