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

DM-45138: Move UWS queue name constant to worker module #214

Merged
merged 1 commit into from
Jul 16, 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
8 changes: 2 additions & 6 deletions src/vocutouts/uws/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

from . import schema
from .config import UWSConfig
from .constants import (
UWS_DATABASE_TIMEOUT,
UWS_EXPIRE_JOBS_SCHEDULE,
UWS_QUEUE_NAME,
)
from .constants import UWS_DATABASE_TIMEOUT, UWS_EXPIRE_JOBS_SCHEDULE
from .exceptions import UWSError
from .handlers import (
install_async_post_handler,
Expand All @@ -27,7 +23,7 @@
install_sync_post_handler,
uws_router,
)
from .uwsworker import WorkerSettings
from .uwsworker import UWS_QUEUE_NAME, WorkerSettings
from .workers import (
close_uws_worker_context,
create_uws_worker_context,
Expand Down
7 changes: 0 additions & 7 deletions src/vocutouts/uws/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"JOB_RESULT_TIMEOUT",
"UWS_DATABASE_TIMEOUT",
"UWS_EXPIRE_JOBS_SCHEDULE",
"UWS_QUEUE_NAME",
]

JOB_RESULT_TIMEOUT = timedelta(seconds=5)
Expand All @@ -36,9 +35,3 @@
microsecond=0,
)
"""Schedule for job expiration cron job, as `arq.cron.cron` parameters."""

UWS_QUEUE_NAME = "uws:queue"
"""Name of the arq queue for internal UWS messages.

Must match ``_UWS_QUEUE_NAME`` in :mod:`vocutouts.uws.uwsworker`.
"""
12 changes: 5 additions & 7 deletions src/vocutouts/uws/uwsworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
T = TypeVar("T", bound="BaseModel")
"""Type for job parameters."""

_UWS_QUEUE_NAME = "uws:queue"
"""Name of the arq queue for internal UWS messages.

Must match `~vocutouts.uws.constants.UWS_QUEUE_NAME`.
"""
UWS_QUEUE_NAME = "uws:queue"
"""Name of the arq queue for internal UWS messages."""

__all__ = [
"WorkerConfig",
Expand All @@ -46,6 +43,7 @@
"WorkerTransientError",
"WorkerUsageError",
"T",
"UWS_QUEUE_NAME",
"build_worker",
]

Expand Down Expand Up @@ -354,10 +352,10 @@ async def startup(ctx: dict[Any, Any]) -> None:
if config.arq_mode == ArqMode.production:
settings = config.arq_redis_settings
arq: ArqQueue = await RedisArqQueue.initialize(
settings, default_queue_name=_UWS_QUEUE_NAME
settings, default_queue_name=UWS_QUEUE_NAME
)
else:
arq = MockArqQueue(default_queue_name=_UWS_QUEUE_NAME)
arq = MockArqQueue(default_queue_name=UWS_QUEUE_NAME)

ctx["arq"] = arq
ctx["logger"] = logger
Expand Down
3 changes: 2 additions & 1 deletion tests/uws/workers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

from vocutouts.uws.app import UWSApplication
from vocutouts.uws.config import UWSConfig
from vocutouts.uws.constants import UWS_DATABASE_TIMEOUT, UWS_QUEUE_NAME
from vocutouts.uws.constants import UWS_DATABASE_TIMEOUT
from vocutouts.uws.dependencies import UWSFactory
from vocutouts.uws.models import ErrorCode, UWSJobParameter, UWSJobResult
from vocutouts.uws.storage import JobStore
from vocutouts.uws.uwsworker import (
UWS_QUEUE_NAME,
WorkerConfig,
WorkerFatalError,
WorkerJobInfo,
Expand Down