:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(health-checks): import JobOwners without booting the dagster package (#86772)
Daniel RC17f7dce8c8ca
diff --git a/.github/workflows/ci-dagster.yml b/.github/workflows/ci-dagster.ymlindex 37ce25231e9b..0ef7d65685b1 100644--- a/.github/workflows/ci-dagster.yml+++ b/.github/workflows/ci-dagster.yml@@ -129,6 +129,7 @@ jobs:- 'posthog/exceptions_capture.py'- 'posthog/metrics.py'- 'posthog/git.py'+ - 'posthog/job_owners.py'- 'posthog/llm/**'- 'posthog/person_db_router.py'- 'posthog/persons_db.py'diff --git a/posthog/dags/common/__init__.py b/posthog/dags/common/__init__.pyindex ed112200e685..1a498d65df76 100644--- a/posthog/dags/common/__init__.py+++ b/posthog/dags/common/__init__.py@@ -1,3 +1,5 @@+from posthog.job_owners import JobOwners+from .common import (check_for_concurrent_runs,chunk_ranges,@@ -5,7 +7,6 @@ from .common import (settings_with_log_comment,skip_if_already_running,)-from .owners import JobOwners__all__ = ["JobOwners",diff --git a/posthog/dags/common/owners.py b/posthog/job_owners.pysimilarity index 77%rename from posthog/dags/common/owners.pyrename to posthog/job_owners.pyindex 186a2c7774d7..1edd3eed9f58 100644--- a/posthog/dags/common/owners.py+++ b/posthog/job_owners.py@@ -2,6 +2,12 @@ from enum import Enumclass JobOwners(str, Enum):+ """Team that owns a scheduled job, used for alert routing.++ Lives outside `posthog.dags` because Temporal and product code tag jobs with it too, and+ importing anything under `posthog.dags` runs that package's Django bootstrap.+ """+TEAM_ANALYTICS_PLATFORM = "team-analytics-platform"TEAM_BILLING = "team-billing"TEAM_CLICKHOUSE = "team-clickhouse"@@ -9,7 +15,6 @@ class JobOwners(str, Enum):TEAM_DATA_STACK = "team-data-stack"TEAM_DATA_TOOLS = "team-data-tools"TEAM_ERROR_TRACKING = "team-error-tracking"-TEAM_GROWTH = "team-growth"TEAM_INGESTION = "team-ingestion"TEAM_LOGS = "team-logs"diff --git a/posthog/temporal/health_checks/framework.py b/posthog/temporal/health_checks/framework.pyindex 36ebd233031b..471ae1f0f0bc 100644--- a/posthog/temporal/health_checks/framework.py+++ b/posthog/temporal/health_checks/framework.py@@ -7,7 +7,7 @@ from typing import Anyfrom django.conf import settingsfrom posthog.clickhouse.query_tagging import Product-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import DEFAULT_EXECUTION_POLICY, HealthExecutionPolicyfrom posthog.temporal.health_checks.models import DEFAULT_ACTIVE_SINCE_DAYS, HealthCheckResultdiff --git a/posthog/temporal/health_checks/tests/test_framework.py b/posthog/temporal/health_checks/tests/test_framework.pyindex 502b72a16587..6f17d6644378 100644--- a/posthog/temporal/health_checks/tests/test_framework.py+++ b/posthog/temporal/health_checks/tests/test_framework.py@@ -2,7 +2,7 @@ from typing import Anyimport pytest-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.temporal.health_checks.framework import HealthCheckRegistrationdiff --git a/posthog/test/repo_invariants/test_dagster_package_isolation.py b/posthog/test/repo_invariants/test_dagster_package_isolation.pynew file mode 100644index 000000000000..4ebf5b232f40--- /dev/null+++ b/posthog/test/repo_invariants/test_dagster_package_isolation.py@@ -0,0 +1,27 @@+import sys+import subprocess++# A clean interpreter: pytest has already imported half the world, so this process cannot tell+# which import pulled the package in.+_SNAPSHOT = """+import os+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")+import django+django.setup()+import posthog.temporal.health_checks.processing+from posthog.temporal.health_checks.registry import ensure_registry_loaded+ensure_registry_loaded()+import sys+print("posthog.dags" in sys.modules)+"""+++def test_health_check_processing_does_not_import_the_dagster_package() -> None:+ result = subprocess.run([sys.executable, "-c", _SNAPSHOT], capture_output=True, text=True, timeout=120)++ assert result.returncode == 0, f"import failed:\n{result.stderr[-2000:]}"+ assert result.stdout.strip() == "False", (+ "Importing the Temporal health checks pulled in posthog.dags, whose __init__ runs "+ "django.setup(). That re-applies LOGGING, and disable_existing_loggers turns off every "+ "logger built before it. Import shared symbols such as JobOwners from posthog.job_owners."+ )diff --git a/products/cdp/backend/temporal/health_checks/ingestion_warnings.py b/products/cdp/backend/temporal/health_checks/ingestion_warnings.pyindex 1b83afead789..6adbc0df807f 100644--- a/products/cdp/backend/temporal/health_checks/ingestion_warnings.py+++ b/products/cdp/backend/temporal/health_checks/ingestion_warnings.py@@ -1,6 +1,6 @@import structlog-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.models.ingestion_warnings.sql_v2 import DISTRIBUTED_TABLE_NAMEfrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYdiff --git a/products/data_warehouse/backend/temporal/health_checks/external_data_failure.py b/products/data_warehouse/backend/temporal/health_checks/external_data_failure.pyindex 04fd67999c63..2797228c4173 100644--- a/products/data_warehouse/backend/temporal/health_checks/external_data_failure.py+++ b/products/data_warehouse/backend/temporal/health_checks/external_data_failure.py@@ -3,7 +3,7 @@ import datetime as dtfrom django.db.models import Qfrom django.utils import timezone-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import DEFAULT_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import AlertContent, HealthCheck, Remediationdiff --git a/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py b/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.pyindex 7881f5d295d4..b01061916528 100644--- a/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py+++ b/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py@@ -1,6 +1,6 @@from django.db.models import Q-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import DEFAULT_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/error_tracking/backend/temporal/health_checks/missing_source_maps.py b/products/error_tracking/backend/temporal/health_checks/missing_source_maps.pyindex f4accf47511f..1f7a42482491 100644--- a/products/error_tracking/backend/temporal/health_checks/missing_source_maps.py+++ b/products/error_tracking/backend/temporal/health_checks/missing_source_maps.py@@ -1,5 +1,5 @@from posthog.clickhouse.query_tagging import Product-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import HealthExecutionPolicyfrom posthog.temporal.health_checks.framework import AlertContent, HealthCheck, Remediationdiff --git a/products/growth/backend/temporal/health_checks/sdk_outdated.py b/products/growth/backend/temporal/health_checks/sdk_outdated.pyindex 41eb8fc37060..783d2744c3e5 100644--- a/products/growth/backend/temporal/health_checks/sdk_outdated.py+++ b/products/growth/backend/temporal/health_checks/sdk_outdated.py@@ -4,7 +4,7 @@ from typing import Anyimport structlog-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.redis import get_clientfrom posthog.temporal.health_checks.detectors import HealthExecutionPolicydiff --git a/products/web_analytics/backend/max_tools.py b/products/web_analytics/backend/max_tools.pyindex bb161b17cbe3..f2474363ab49 100644--- a/products/web_analytics/backend/max_tools.py+++ b/products/web_analytics/backend/max_tools.py@@ -18,9 +18,9 @@ from posthog.hogql.parser import parse_expr, parse_selectfrom posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.query_tagging import Product, tags_context-from posthog.dags.common.owners import JobOwnersfrom posthog.hogql_queries.property_values_query_runner import PropertyValuesQueryRunnerfrom posthog.hogql_queries.query_runner import ExecutionMode+from posthog.job_owners import JobOwnersfrom posthog.models import Team, Userfrom posthog.models.health_issue import HealthIssuefrom posthog.queries.property_values import get_person_property_values_for_keydiff --git a/products/web_analytics/backend/temporal/health_checks/authorized_urls.py b/products/web_analytics/backend/temporal/health_checks/authorized_urls.pyindex dbd2bc0c376f..3720728dea44 100644--- a/products/web_analytics/backend/temporal/health_checks/authorized_urls.py+++ b/products/web_analytics/backend/temporal/health_checks/authorized_urls.py@@ -1,6 +1,6 @@from django.db.models import Q-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.models.team import Teamfrom posthog.temporal.health_checks.detectors import DEFAULT_EXECUTION_POLICYdiff --git a/products/web_analytics/backend/temporal/health_checks/no_live_events.py b/products/web_analytics/backend/temporal/health_checks/no_live_events.pyindex 89b1eae6fb33..12954b362d5d 100644--- a/products/web_analytics/backend/temporal/health_checks/no_live_events.py+++ b/products/web_analytics/backend/temporal/health_checks/no_live_events.py@@ -1,5 +1,5 @@from posthog.clickhouse.query_tagging import Product-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/web_analytics/backend/temporal/health_checks/no_pageleave_events.py b/products/web_analytics/backend/temporal/health_checks/no_pageleave_events.pyindex 6f6a06bb696d..e327620a4c02 100644--- a/products/web_analytics/backend/temporal/health_checks/no_pageleave_events.py+++ b/products/web_analytics/backend/temporal/health_checks/no_pageleave_events.py@@ -1,5 +1,5 @@from posthog.clickhouse.query_tagging import Product-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/web_analytics/backend/temporal/health_checks/partial_proxy.py b/products/web_analytics/backend/temporal/health_checks/partial_proxy.pyindex 7b6ac41b406d..63e7af2f2fc4 100644--- a/products/web_analytics/backend/temporal/health_checks/partial_proxy.py+++ b/products/web_analytics/backend/temporal/health_checks/partial_proxy.py@@ -1,7 +1,7 @@import refrom collections import defaultdict-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/web_analytics/backend/temporal/health_checks/path_cleaning_suggestions.py b/products/web_analytics/backend/temporal/health_checks/path_cleaning_suggestions.pyindex 7e1fb490150d..b464a3e58100 100644--- a/products/web_analytics/backend/temporal/health_checks/path_cleaning_suggestions.py+++ b/products/web_analytics/backend/temporal/health_checks/path_cleaning_suggestions.py@@ -3,7 +3,7 @@ from django.conf import settingsimport structlogfrom posthog.clickhouse.query_tagging import Product-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models import Teamfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import HealthExecutionPolicydiff --git a/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py b/products/web_analytics/backend/temporal/health_checks/reverse_proxy.pyindex fdd5ee559c68..996e5ba77e41 100644--- a/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py+++ b/products/web_analytics/backend/temporal/health_checks/reverse_proxy.py@@ -1,4 +1,4 @@-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/web_analytics/backend/temporal/health_checks/scroll_depth.py b/products/web_analytics/backend/temporal/health_checks/scroll_depth.pyindex 20af5fa84662..b7dd641f6332 100644--- a/products/web_analytics/backend/temporal/health_checks/scroll_depth.py+++ b/products/web_analytics/backend/temporal/health_checks/scroll_depth.py@@ -1,4 +1,4 @@-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (diff --git a/products/web_analytics/backend/temporal/health_checks/web_vitals.py b/products/web_analytics/backend/temporal/health_checks/web_vitals.pyindex ecd2b4675d7c..03f034219a05 100644--- a/products/web_analytics/backend/temporal/health_checks/web_vitals.py+++ b/products/web_analytics/backend/temporal/health_checks/web_vitals.py@@ -1,4 +1,4 @@-from posthog.dags.common.owners import JobOwners+from posthog.job_owners import JobOwnersfrom posthog.models.health_issue import HealthIssuefrom posthog.temporal.health_checks.detectors import CLICKHOUSE_BATCH_EXECUTION_POLICYfrom posthog.temporal.health_checks.framework import (