mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-16 07:19:13 +08:00
Add option to disable the fetch_data celery task
To disable, set the task's route to "disabled" in galaxy.yml:
enable_celery_tasks: true
celery_conf:
task_routes:
galaxy.fetch_data: disabled
This commit is contained in:
@@ -135,6 +135,7 @@ LOGGING_CONFIG_DEFAULT: Dict[str, Any] = {
|
||||
"""Default value for logging configuration, passed to :func:`logging.config.dictConfig`"""
|
||||
|
||||
VERSION_JSON_FILE = "version.json"
|
||||
DISABLED_FLAG = "disabled" # Used to mark a config option as disabled
|
||||
|
||||
|
||||
def configure_logging(config, facts=None):
|
||||
@@ -1276,6 +1277,15 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
|
||||
f"Config option '{key}' is deprecated and will be removed in a future release. Please consult the latest version of the sample configuration file."
|
||||
)
|
||||
|
||||
def is_fetch_with_celery_enabled(self):
|
||||
celery_enabled = self.enable_celery_tasks
|
||||
fetch_disabled = (
|
||||
self.celery_conf
|
||||
and self.celery_conf["task_routes"]
|
||||
and self.celery_conf["task_routes"]["galaxy.fetch_data"] == DISABLED_FLAG
|
||||
)
|
||||
return celery_enabled and not fetch_disabled
|
||||
|
||||
@staticmethod
|
||||
def _parse_allowed_origin_hostnames(allowed_origin_hostnames):
|
||||
"""
|
||||
|
||||
@@ -180,7 +180,7 @@ def execute(
|
||||
tool_id = tool.id
|
||||
for job2 in execution_tracker.successful_jobs:
|
||||
# Put the job in the queue if tracking in memory
|
||||
if tool_id == "__DATA_FETCH__" and tool.app.config.enable_celery_tasks:
|
||||
if tool_id == "__DATA_FETCH__" and tool.app.config.is_fetch_with_celery_enabled:
|
||||
job_id = job2.id
|
||||
from galaxy.celery.tasks import (
|
||||
fetch_data,
|
||||
|
||||
@@ -6,7 +6,7 @@ from galaxy import config
|
||||
from galaxy.util.properties import running_from_source
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture()
|
||||
def appconfig():
|
||||
return config.GalaxyAppConfiguration(override_tempdir=False)
|
||||
|
||||
@@ -42,3 +42,34 @@ def test_base_config_if_running_not_from_source(monkeypatch):
|
||||
assert appconfig.config_dir == os.getcwd()
|
||||
assert appconfig.data_dir == os.path.join(appconfig.config_dir, "data")
|
||||
assert appconfig.managed_config_dir == os.path.join(appconfig.data_dir, "config")
|
||||
|
||||
|
||||
class TestIsFetchWithCeleryEnabled:
|
||||
def test_disabled_if_celery_disabled(self, appconfig):
|
||||
appconfig.enable_celery_tasks = False
|
||||
assert not appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
def test_enabled_if_no_celeryconf(self, appconfig):
|
||||
appconfig.enable_celery_tasks = True
|
||||
appconfig.enable_celery_conf = None
|
||||
assert appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
def test_enabled_if_no_task_routes(self, appconfig):
|
||||
appconfig.enable_celery_tasks = True
|
||||
appconfig.celery_conf["task_routes"] = None
|
||||
assert appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
def test_enabled_if_no_route(self, appconfig):
|
||||
appconfig.enable_celery_tasks = True
|
||||
appconfig.celery_conf["task_routes"]["galaxy.fetch_data"] = None
|
||||
assert appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
def test_enabled_if_has_route(self, appconfig):
|
||||
appconfig.enable_celery_tasks = True
|
||||
appconfig.celery_conf["task_routes"]["galaxy.fetch_data"] = "my_route"
|
||||
assert appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
def test_disabled_if_disabled_flag(self, appconfig):
|
||||
appconfig.enable_celery_tasks = True
|
||||
appconfig.celery_conf["task_routes"]["galaxy.fetch_data"] = config.DISABLED_FLAG
|
||||
assert not appconfig.is_fetch_with_celery_enabled()
|
||||
|
||||
Reference in New Issue
Block a user