29 Commits
Author SHA1 Message Date
mvdbeek 6a3af480e1 Fix type errors from the review changes
_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.
2026-11-23 11:57:31 +01:00
John Chilton a1e001103e Skip owners in history_update viewer fan-out too
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.
2026-11-23 11:39:41 +01:00
John Chilton 017523a90b Share fan-out between invocation_update and job_update handlers
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.
2026-11-23 11:39:41 +01:00
mvdbeek 6ffbe62fef Import kombu names from submodules in 26.2-only code
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.
2026-11-04 01:10:16 +01:00
mvdbeek c898f3da8b Merge branch 'release_26.1' into release_26.2
# Conflicts:
#	client/src/components/Panels/Menus/PanelViewMenu.vue
#	client/src/stores/collectionElementsStore.test.ts
#	client/src/stores/collectionElementsStore.ts
#	lib/galaxy/managers/jobs.py
#	lib/galaxy/model/__init__.py
#	lib/galaxy/tools/evaluation.py
#	lib/galaxy/tools/runtime.py
#	lib/galaxy/workflow/modules.py
#	lib/galaxy_test/api/test_workflows.py
#	lib/galaxy_test/base/populators.py
#	test/unit/app/test_celery.py
2026-10-28 06:34:13 +01:00
mvdbeek 04fe1e82c1 Merge branch 'release_26.0' into release_26.1
# Conflicts:
#	client/src/components/Common/GCard.vue
#	client/src/components/History/Layout/DetailsLayout.test.js
#	client/src/components/Libraries/LibraryPermissions/PermissionsInputField.test.js
#	client/src/components/Panels/Upload/methods/RemoteFilesUpload.vue
#	lib/galaxy/selenium/navigates_galaxy.py
#	lib/galaxy_test/api/test_jobs.py
#	lib/galaxy_test/selenium/framework.py
#	test/unit/app/queue_worker/test_queue_worker.py
2026-10-28 06:21:22 +01:00
mvdbeek 734eebca3a Build wait_for_var on wait_for in the queue worker tests 2026-10-26 16:31:27 +01:00
mvdbeek 13876a89d5 Wait for the heartbeat before sending queue worker test tasks
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.
2026-10-25 03:19:59 +01:00
mvdbeek e935b8d1bd Drop the unit test that called an app method on a stand-in app 2026-10-19 11:32:45 +02:00
John ChiltonandClaude Opus 5.5 1defee3e74 Gate tool search index writes in the app, not at call sites
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>
2026-10-19 11:32:44 +02:00
mvdbeek 8800453324 Merge branch 'release_26.1' into dev
# Conflicts:
#	.github/workflows/integration.yaml
#	client/src/components/Tool/ToolSourceSchema.json
#	client/visualizations.yml
#	lib/galaxy/files/sources/ftp.py
#	lib/galaxy/files/templates/models.py
#	lib/galaxy/job_execution/output_collect.py
#	lib/galaxy/queues/__init__.py
#	lib/galaxy/tool_util/deps/mulled/mulled_cache.py
#	lib/galaxy/tool_util/deps/mulled/util.py
#	lib/galaxy/tool_util/parameters/factory.py
#	lib/galaxy/tool_util_models/__init__.py
#	lib/galaxy/tool_util_models/tool_outputs.py
#	lib/galaxy/tools/actions/__init__.py
#	lib/galaxy/util/config_templates.py
#	test/integration/conftest.py
#	test/unit/app/tools/test_metadata.py
#	test/unit/files/test_template_models.py
2026-09-15 14:46:16 +02:00
mvdbeek 17750a6a1e Deliver SSE control tasks to webapp processes only
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.
2026-09-13 21:33:53 +02:00
mvdbeek 6d4eb20906 Merge branch 'release_26.1' into dev 2026-07-06 16:12:10 +02:00
paperbenni bec3d3ad9c Drop support for Python 3.8
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.
2026-06-25 15:12:05 +01:00
mvdbeek 261dba8c1d Isolate control-queue routing test on the shared postgres database
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.
2026-06-18 20:17:45 +02:00
mvdbeek d685743890 Keep the standalone SSE monitor out of the control-queue routing table
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.
2026-06-18 17:31:21 +02:00
mvdbeek 6e5eada944 Add SSE entry-point channel, dispatch observability, declare-queue cache
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.
2026-04-28 17:18:07 +02:00
Nicola Soranzo 0c6fe6e9a9 Add `+psycopg` to PostgreSQL connect string in remaining places 2026-03-25 20:18:38 +00:00
Nicola Soranzo 0629908541 Fix new UP031 errors from ruff 0.4.2 2024-04-29 00:09:38 +01:00
Nicola Soranzo 053ca5198e Enable `warn_unused_ignores` mypy option 2024-04-16 01:12:58 +01:00
Nicola Soranzo 330599c70f Fixes for new errors from ruff 0.3.2 2024-03-12 11:06:57 +00:00
Nicola Soranzo 37116c39a0 Fix type annotation of code using XML etree
by adding lxml-stubs to our typecheck requirements.
2024-01-26 18:41:09 +00:00
Nicola Soranzo d543702e4b pytest-postgresql requires psycopg
See https://github.com/ClearcodeHQ/pytest-postgresql#how-to-use

Fix failing queue_worker unit tests when psycopg2 is installed
(otherwise they are skipped):

```
$ pytest test/unit/app/queue_worker/test_database_heartbeat.py::test_database_heartbeat[postgres_app]
...
_________________________________________________________________________ ERROR at setup of test_database_heartbeat[postgres_app] _________________________________________________________________________

request = <SubRequest 'database_app' for <Function test_database_heartbeat[postgres_app]>>

    @pytest.fixture(params=["postgres_app", "sqlite_app", "sqlite_rabbitmq_app"])
    def database_app(request):
        if request.param == "postgres_app":
            if not which("initdb"):
                pytest.skip("initdb must be on PATH for postgresql fixture")
            if not psycopg2:
                pytest.skip("psycopg2 must be installed for postgresql fixture")
        if request.param == "sqlite_rabbitmq_app":
            if not os.environ.get("GALAXY_TEST_AMQP_INTERNAL_CONNECTION"):
                pytest.skip("rabbitmq tests will be skipped if GALAXY_TEST_AMQP_INTERNAL_CONNECTION env var is unset")
>       return request.getfixturevalue(request.param)

test/unit/app/queue_worker/conftest.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.10/site-packages/pytest_postgresql/factories/process.py:147: in postgresql_proc_fixture
    with DatabaseJanitor(
.venv/lib/python3.10/site-packages/pytest_postgresql/janitor.py:54: in __init__
    check_for_psycopg()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def check_for_psycopg() -> None:
        """
        Function checks whether psycopg was imported.

        Raises ImportError if not.
        """
        if not psycopg:
>           raise ImportError("No module named psycopg. Please install psycopg.")
E           ImportError: No module named psycopg. Please install psycopg.

.venv/lib/python3.10/site-packages/pytest_postgresql/compat.py:35: ImportError
```

Also, remove check for `initdb` in PATH, because on Ubuntu it's installed
in `/usr/lib/postgresql/VERSION/bin/initdb` .
2023-07-29 00:46:10 +01:00
mvdbeek 849219d45a Skip postgres unit tests from psycopg2 not installed 2023-07-29 00:46:09 +01:00
John Davis 0a20aa533d Fix unit test: process no longer in session
We don't keep the process in the session
2023-02-17 21:33:36 -05:00
Nicola Soranzo 69a3fd84f9 Add and fix type annotations 2022-07-26 23:56:33 +01:00
Nicola Soranzo 493db8669c Remove Python 2 support 2022-06-02 16:17:56 +01:00
Dannon Baker 623a5e165a Apply black formatting.
Apply isort.
2022-02-03 07:42:20 -05:00
John Chilton fe0c4ab4e2 Migrate more unit tests into galaxy-app's test suite. 2021-10-07 11:05:03 -04:00