mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-31 10:32:11 +08:00
Merge pull request #20502 from davelopez/add_redis_conditional_dependency
[25.0] Add redis conditional dependency
This commit is contained in:
@@ -320,6 +320,19 @@ class ConditionalDependencies:
|
||||
def check_rucio_clients(self):
|
||||
return "rucio" in self.object_stores
|
||||
|
||||
def check_redis(self):
|
||||
celery_enabled = self.config.get("enable_celery_tasks", False)
|
||||
celery_conf = self.config.get("celery_conf") or {}
|
||||
celery_result_backend = celery_conf.get("result_backend") or ""
|
||||
celery_broker_url = celery_conf.get("broker_url") or ""
|
||||
|
||||
def is_redis_url(url: str) -> bool:
|
||||
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#conf-redis-result-backend
|
||||
protocol = url.split("://")[0]
|
||||
return protocol in {"redis", "rediss", "redis+socket", "socket"}
|
||||
|
||||
return celery_enabled and is_redis_url(celery_result_backend) or is_redis_url(celery_broker_url)
|
||||
|
||||
|
||||
def optional(config_file=None):
|
||||
if not config_file:
|
||||
|
||||
@@ -15,6 +15,7 @@ galaxycloudrunner
|
||||
pkce
|
||||
total-perspective-vortex>=2.3.2,<3
|
||||
openai
|
||||
redis>=5.3.0
|
||||
|
||||
# For file sources plugins
|
||||
fs.webdavfs>=0.4.2 # type: webdav
|
||||
|
||||
@@ -3,6 +3,8 @@ from contextlib import contextmanager
|
||||
from shutil import rmtree
|
||||
from tempfile import mkdtemp
|
||||
|
||||
import pytest
|
||||
|
||||
from galaxy.dependencies import ConditionalDependencies
|
||||
|
||||
AZURE_BLOB_TEST_CONFIG = """<object_store type="azure_blob">
|
||||
@@ -122,6 +124,44 @@ def test_vault_hashicorp_configured():
|
||||
assert not cds.check_custos_sdk()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config,expected",
|
||||
[
|
||||
(
|
||||
{
|
||||
"enable_celery_tasks": True,
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{
|
||||
"enable_celery_tasks": True,
|
||||
"celery_conf": {"result_backend": None},
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{
|
||||
"enable_celery_tasks": True,
|
||||
"celery_conf": {"broker_url": "redis://localhost:6379/0"},
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{
|
||||
"enable_celery_tasks": True,
|
||||
"celery_conf": {"result_backend": "redis://localhost:6379/0"},
|
||||
},
|
||||
True,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_conditional_redis(config, expected):
|
||||
with _config_context() as cc:
|
||||
cds = cc.get_cond_deps(config=config)
|
||||
assert cds.check_redis() is expected
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _config_context():
|
||||
config_dir = mkdtemp()
|
||||
|
||||
Reference in New Issue
Block a user