_delete_jobs takes the job condition and builds both the UPDATE and, without
RETURNING, the SELECT from it, instead of reading the optional whereclause
back from the statement. Job.state is typed non-null, so _record_job drops
its unreachable None check. The fan-out unit tests pass their fake app as a
MinimalManagerApp.
One de-dup policy for all history-viewer pushes: owners subscribed to their
own history get history_update once, as for invocation_update and job_update.
Extract _push_routed_items for the owner/session/viewer grouping both
handlers copied; unit-test owner dedup, session delivery and resync fan-out
with a real SSEConnectionManager.
The package tests install kombu 5.7.0, whose lazy top-level __init__
doesn't explicitly re-export Connection or Queue (see #24682). Apply the
same submodule imports to the tool source store populator and the
control routing test. kombu 5.7 also ships py.typed, so the
disallow_subclassing_any ignore on GalaxyQueueWorker is unused there.
Mark it unused-ignore so mypy passes with both the pinned 5.6.2 and 5.7.
Producers on the SQLAlchemy transports route control tasks to the queues
of processes found in the heartbeat table. A task sent before the test
process's first heartbeat is committed is never delivered, which a slow
first heartbeat on a fresh postgres database turned into
assert 'foo' == 'bar'. Also give wait_for_var a 20s deadline instead of
2.75s of polling.
remove_tool_by_id still reindexed from whichever process served the
uninstall; move the config watcher check into reindex_tool_search and
ensure_tool_search_index so every caller obeys it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Job handlers were running every history_update, notify_users and
entry_point_update task, logging "received 'history_update' task,
executing now." at whatever rate the history audit monitor fires, then
pushing into a connection map that is always empty there.
SSEEventDispatcher passed a webapp-only queue list as declare_queues, but
kombu's declare= only creates entities -- the broker routes by binding
key, and every process binds control.*, which the dispatcher also
published on. The filter only bit on virtual transports, where the
producer's in-memory routing table is the declare list.
Webapp processes now additionally bind web.control and the dispatcher
publishes there. The key sits outside the control. namespace on purpose:
RabbitMQ reads * as exactly one word, but kombu's virtual transports
compile it to .*?[^.], which matches across dots, so control.web would
still have matched control.* and landed everywhere.
Using explicit bindings makes kombu clear Queue.exchange, so
ControlTask.exchange now reads the module-level exchange instead.
Bindings are installed at process start, so web workers only receive SSE
events again once they have restarted.
Drop Python 3.8 support in 5 Pulsar-compatible packages
(job_metrics, tool_util, tool_util_models, util, objectstore)
and run pyupgrade --py310-plus on their source code.
- Bump requires-python from >=3.8 to >=3.10 in all 5 packages
- Remove Python 3.8 and 3.9 classifiers
- Remove ruff per-file-ignores for UP rules on these paths
- Remove backports.zoneinfo conditional dependency
- Remove pydyf<0.11 pin from conditional-requirements.txt
- Update Makefile pyupgrade target (remove PY38_PYUPGRADE_PATHS)
- Update CI workflow to test with Python 3.10 instead of 3.8
Clean up unused deprecated typing imports after pyupgrade
Remove now-unused typing imports (Dict, List, Optional, Set, Tuple,
Type, Union) that became dead after pyupgrade --py310-plus converted
annotations to use built-in types and | syntax.
Also run ruff check --fix --select=UP007,UP045 across the entire
codebase to convert remaining Optional[X] -> X | None and
Union[X, Y] -> X | Y patterns.
Enable ruff UP007/UP045 for Python 3.10 union syntax
Remove UP007 (Union[X,Y] -> X | Y) and UP045 (Optional[X] -> X | None)
from the ruff ignore list and convert all type aliases across the
codebase. These rules were deferred while Python 3.9 was supported;
requires-python is now >=3.10.
A custom script was used because neither ruff --fix nor
pyupgrade --py310-plus converts Optional[X]/Union[X,Y] in type alias
positions (e.g. X = Union[A, B]) — they only handle annotation
positions (e.g. def f(x: Optional[int])). All 167 violations were
module-level type aliases. A few edge cases were fixed manually:
single-element Union[X,], typing.Union qualified refs, runtime
Optional[type] calls, and Annotated[Optional[...]] pydantic fields.
Fix UP007 autofix regression with string forward reference type aliases
Commit fa6bd955a0 enabled ruff UP007/UP045 and auto-fixed
module-level type aliases using Union with string forward
references, producing invalid 'str | str' expressions.
This was a known ruff bug (charliermarsh/ruff#826) that has since
been fixed in later ruff versions, but this codebase was
converted before the fix was in place.
Revert to Union syntax and restore TYPE_CHECKING imports that
ruff's TCH rule cleaned up as a side effect when it thought the
forward references were unused.
The postgres_app fixture reuses one session-scoped database, so the
WorkerProcess rows inserted by these tests collided on re-insert (unique
violation on the second test) and leaked into test_database_heartbeat,
which then saw 3 active processes instead of 0. The sqlite variants pass
because each gets a fresh tempfile-backed database per test.
Clear the worker_process table before and after each test via an app
fixture so the routing tests are self-isolating.
The standalone galaxy-sse-monitor registers a DatabaseHeartbeat WorkerProcess
row so webapps defer the history-audit-monitor role to it (and re-elect a
webapp within one interval if it dies). But it runs no control consumer, so
including its row in all_control_queues_for_declare made producers declare and
feed a control queue that nothing drains.
Set the heartbeat's app_type concretely from the caller (WEBAPP for webapps,
SSE_MONITOR for the monitor) instead of inferring it from is_webapp and a
server_name prefix, and exclude SSE_MONITOR rows from the general control-task
declare path. The webapp_only path (SSE event fan-out) is unchanged; job
handlers (NULL app_type) are still routed to.
Three related additions to the SSE notification pipeline, bundled here
because they share ``SSEEventDispatcher._send`` as their modification
point:
1. Interactive-tool entry-point SSE channel
- ``entry_point_update`` dispatcher method + queue-worker handler.
- ``InteractiveToolManager.configure_entry_points`` dispatches a
wake-up event after the DB commit; the client refetches
``/api/entry_points`` on receipt (no payload).
- Frontend: new SSE event type, store subscription with XOR polling
fallback via ``enable_sse_entry_point_updates`` config flag.
- Integration + selenium tests.
2. Queue and SSE observability metrics
- Counters, timers, and periodic gauges for SSE dispatch, control-queue
task execution, control-queue depth (via kombu passive declare),
active SSE connections, dropped events, and active WorkerProcess
rows. Flow through the existing ``galaxy_statsd_client`` — no new
infra. Gauges are scheduled via Celery beat at ``queue_metrics_interval``
seconds (default 15). All instrumentation no-ops when statsd isn't
configured.
- Sub-emitter failures log once at WARNING and bump a
``galaxy.queue_metrics.error`` counter tagged by emitter so broken
emitters are visible in metrics without log spam.
3. Active-worker control-queue cache
- 30 s TTL cache on ``all_control_queues_for_declare`` with RLock
stampede protection. At 1000+ events/s this eliminates ~30 DB
round-trips/s per webapp for data that only changes on 60 s
heartbeat cadence. Empty results are not cached — would otherwise
silently drop every SSE event during the startup window.