Skip to content

: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.

chore(batch-exports): move temporal wiring onto the facade (#108478)

Ross6172e2fc29ae
diff --git a/posthog/api/test/test_team_deletion.py b/posthog/api/test/test_team_deletion.py
index 0eb1f33dd438..0df46fbb7437 100644
--- a/posthog/api/test/test_team_deletion.py
+++ b/posthog/api/test/test_team_deletion.py
@@ -17,7 +17,7 @@ from posthog.temporal.common.schedule import describe_schedule
from posthog.temporal.common.test_utils import start_test_worker
from posthog.temporal.tests.delete_teams.inline import execute_deletion_workflows_inline
-from products.batch_exports.backend.temporal import ACTIVITIES, WORKFLOWS
+from products.batch_exports.backend.facade.temporal import ACTIVITIES, WORKFLOWS
from products.early_access_features.backend.models import EarlyAccessFeature
diff --git a/posthog/management/commands/execute_temporal_workflow.py b/posthog/management/commands/execute_temporal_workflow.py
index d66029466ad2..3c89acbb4350 100644
--- a/posthog/management/commands/execute_temporal_workflow.py
+++ b/posthog/management/commands/execute_temporal_workflow.py
@@ -28,7 +28,7 @@ from posthog.temporal.tests.utils.workflow import WORKFLOWS as TEST_WORKFLOWS
from posthog.temporal.usage_report import WORKFLOWS as USAGE_REPORTS_WORKFLOWS
from posthog.temporal.weekly_digest import WORKFLOWS as WEEKLY_DIGEST_WORKFLOWS
-from products.batch_exports.backend.temporal import WORKFLOWS as BATCH_EXPORT_WORKFLOWS
+from products.batch_exports.backend.facade.temporal import WORKFLOWS as BATCH_EXPORT_WORKFLOWS
from products.data_catalog.backend.facade.temporal import WORKFLOWS as DATA_CATALOG_DIGEST_WORKFLOWS
from products.error_tracking.backend.facade.temporal import WORKFLOWS as ERROR_TRACKING_WORKFLOWS
from products.logs.backend.temporal.retention_entitlements import WORKFLOWS as LOGS_RETENTION_ENTITLEMENTS_WORKFLOWS
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.py
index d272f4374cd9..a334a1af72a8 100644
--- a/posthog/management/commands/start_temporal_worker.py
+++ b/posthog/management/commands/start_temporal_worker.py
@@ -165,7 +165,7 @@ from products.autoresearch.backend.facade.temporal import (
ACTIVITIES as AUTORESEARCH_ACTIVITIES,
WORKFLOWS as AUTORESEARCH_WORKFLOWS,
)
-from products.batch_exports.backend.temporal import (
+from products.batch_exports.backend.facade.temporal import (
ACTIVITIES as BATCH_EXPORTS_ACTIVITIES,
WORKFLOWS as BATCH_EXPORTS_WORKFLOWS,
)
diff --git a/posthog/management/commands/start_temporal_workflow.py b/posthog/management/commands/start_temporal_workflow.py
index c12678fb4696..dbeb8daee17f 100644
--- a/posthog/management/commands/start_temporal_workflow.py
+++ b/posthog/management/commands/start_temporal_workflow.py
@@ -28,7 +28,7 @@ from posthog.temporal.tests.utils.workflow import WORKFLOWS as TEST_WORKFLOWS
from posthog.temporal.usage_report import WORKFLOWS as USAGE_REPORTS_WORKFLOWS
from posthog.temporal.weekly_digest import WORKFLOWS as WEEKLY_DIGEST_WORKFLOWS
-from products.batch_exports.backend.temporal import WORKFLOWS as BATCH_EXPORT_WORKFLOWS
+from products.batch_exports.backend.facade.temporal import WORKFLOWS as BATCH_EXPORT_WORKFLOWS
from products.data_catalog.backend.facade.temporal import WORKFLOWS as DATA_CATALOG_DIGEST_WORKFLOWS
from products.error_tracking.backend.facade.temporal import WORKFLOWS as ERROR_TRACKING_WORKFLOWS
from products.logs.backend.temporal.retention_entitlements import WORKFLOWS as LOGS_RETENTION_ENTITLEMENTS_WORKFLOWS
diff --git a/posthog/temporal/common/worker.py b/posthog/temporal/common/worker.py
index 9a9e36a00e30..931f94bd86a1 100644
--- a/posthog/temporal/common/worker.py
+++ b/posthog/temporal/common/worker.py
@@ -63,7 +63,7 @@ from products.alerts.backend.facade.temporal import (
ALERTS_PLATFORM_LATENCY_HISTOGRAM_METRICS,
AlertsPlatformTelemetryInterceptor,
)
-from products.batch_exports.backend.temporal.metrics import BatchExportsMetricsInterceptor
+from products.batch_exports.backend.facade.temporal import BatchExportsMetricsInterceptor
from products.experiments.backend.temporal.recalculation_metrics import (
EXPERIMENT_METRICS_RECALCULATION_ATTEMPT_HISTOGRAM_BUCKETS,
EXPERIMENT_METRICS_RECALCULATION_ATTEMPT_HISTOGRAM_METRICS,
diff --git a/posthog/temporal/tests/conftest.py b/posthog/temporal/tests/conftest.py
index 39b562aaa31d..058648fe8045 100644
--- a/posthog/temporal/tests/conftest.py
+++ b/posthog/temporal/tests/conftest.py
@@ -137,7 +137,7 @@ async def workflows(request):
try:
return request.param
except AttributeError:
- from products.batch_exports.backend.temporal import WORKFLOWS
+ from products.batch_exports.backend.facade.temporal import WORKFLOWS
return WORKFLOWS
@@ -152,7 +152,7 @@ async def activities(request):
try:
return request.param
except AttributeError:
- from products.batch_exports.backend.temporal import ACTIVITIES
+ from products.batch_exports.backend.facade.temporal import ACTIVITIES
return ACTIVITIES
diff --git a/posthog/temporal/tests/test_encryption_codec.py b/posthog/temporal/tests/test_encryption_codec.py
index 92734720e446..0f0e49ea3aa6 100644
--- a/posthog/temporal/tests/test_encryption_codec.py
+++ b/posthog/temporal/tests/test_encryption_codec.py
@@ -16,8 +16,8 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.temporal.common.codec import EncryptionCodec, _load_as_bytes, _prepare_key, _resize_key
-from products.batch_exports.backend.service import NoOpInputs
-from products.batch_exports.backend.temporal.noop import NoOpWorkflow, noop_activity
+from products.batch_exports.backend.facade.temporal import NoOpWorkflow, noop_activity
+from products.batch_exports.backend.facade.testing import build_noop_inputs
@pytest.mark.parametrize(
@@ -191,12 +191,7 @@ async def test_payloads_are_encrypted():
input_str = str(uuid.uuid4())
no_op_result_str = f"OK - {input_str}"
- inputs = NoOpInputs(
- arg=input_str,
- batch_export_id="123",
- team_id=1,
- backfill_details=None,
- )
+ inputs = build_noop_inputs(arg=input_str, team_id=1, batch_export_id="123")
# The no-op Workflow can only produce a limited set of results, so we'll check if the events match any of these.
# Either it's the final result (no_op_result_str), the input to an activity (no_op_activity_input_str), or the
diff --git a/products/batch_exports/backend/tests/management/test_backfill_batch_export_runs.py b/products/batch_exports/backend/tests/management/test_backfill_batch_export_runs.py
index 755ac4468603..981e966dcd89 100644
--- a/products/batch_exports/backend/tests/management/test_backfill_batch_export_runs.py
+++ b/products/batch_exports/backend/tests/management/test_backfill_batch_export_runs.py
@@ -17,7 +17,6 @@ from temporalio.service import RPCError
from posthog.models import Organization, Team
from posthog.temporal.common.client import sync_connect
from posthog.temporal.common.test_utils import start_test_worker
-from posthog.temporal.tests.utils.models import create_batch_export
from products.batch_exports.backend.management.commands.backfill_batch_export_runs import (
find_missing_intervals,
@@ -26,6 +25,7 @@ from products.batch_exports.backend.management.commands.backfill_batch_export_ru
from products.batch_exports.backend.models.batch_export import BatchExport, BatchExportDestination, BatchExportRun
from products.batch_exports.backend.temporal import ACTIVITIES, WORKFLOWS
from products.batch_exports.backend.tests.temporal.backfills.conftest import wait_for_workflows
+from products.batch_exports.backend.tests.temporal.utils.models import create_batch_export
@pytest.fixture
diff --git a/products/batch_exports/backend/tests/temporal/backfills/conftest.py b/products/batch_exports/backend/tests/temporal/backfills/conftest.py
index add8e2742f95..08b36059f272 100644
--- a/products/batch_exports/backend/tests/temporal/backfills/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/backfills/conftest.py
@@ -6,7 +6,8 @@ import pytest
import temporalio.client
from posthog.temporal.tests.utils.events import generate_test_events_in_clickhouse
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
+
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
async def wait_for_workflows(
diff --git a/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py b/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py
index f6b8af9c1b4d..48899a603cb0 100644
--- a/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py
@@ -13,19 +13,18 @@ import temporalio.common
import temporalio.exceptions
from asgiref.sync import sync_to_async
-from posthog.temporal.tests.utils.models import (
- acreate_batch_export,
- adelete_batch_export,
- afetch_batch_export,
- afetch_batch_export_backfills,
-)
-
from products.batch_exports.backend.models.batch_export import BatchExportBackfill
from products.batch_exports.backend.temporal.backfill_batch_export import (
BackfillBatchExportInputs,
BackfillBatchExportWorkflow,
)
from products.batch_exports.backend.tests.temporal.utils.clickhouse import truncate_events
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export,
+ afetch_batch_export_backfills,
+)
from products.batch_exports.backend.tests.temporal.utils.s3 import create_test_client, delete_all_from_s3
from .conftest import assert_backfill_details_in_workflow_events, wait_for_workflows
diff --git a/products/batch_exports/backend/tests/temporal/destinations/azure_blob/test_workflow_error_states.py b/products/batch_exports/backend/tests/temporal/destinations/azure_blob/test_workflow_error_states.py
index d882ee07387d..29ece4774fd6 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/azure_blob/test_workflow_error_states.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/azure_blob/test_workflow_error_states.py
@@ -12,8 +12,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run
from products.batch_exports.backend.temporal.destinations.azure_blob_batch_export import (
AzureBlobBatchExportInputs,
@@ -24,6 +22,7 @@ from products.batch_exports.backend.temporal.pipeline.internal_stage import (
BatchExportInsertIntoInternalStageInputs,
InternalStageResult,
)
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.workflow import (
NeverFinishingActivity,
mocked_start_batch_export_run,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/azure_blob/utils.py b/products/batch_exports/backend/tests/temporal/destinations/azure_blob/utils.py
index c569521cf499..e4403f4fd7ef 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/azure_blob/utils.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/azure_blob/utils.py
@@ -15,8 +15,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-
from products.batch_exports.backend.service import BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
from products.batch_exports.backend.temporal.destinations.azure_blob_batch_export import (
@@ -31,6 +29,7 @@ from products.batch_exports.backend.temporal.pipeline.internal_stage import inse
from products.batch_exports.backend.temporal.queue import RecordBatchQueue
from products.batch_exports.backend.temporal.record_batch_model import SessionsRecordBatchModel
from products.batch_exports.backend.tests.temporal.utils.clickhouse_test_producer import ClickHouseTestProducer
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.records import get_record_batch_from_queue
diff --git a/products/batch_exports/backend/tests/temporal/destinations/base_destination_tests.py b/products/batch_exports/backend/tests/temporal/destinations/base_destination_tests.py
index e6c0faf347d8..0e1afe3dc415 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/base_destination_tests.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/base_destination_tests.py
@@ -25,7 +25,6 @@ from posthog.models.integration import Integration
from posthog.models.team import Team
from posthog.temporal.common.base import PostHogWorkflow
from posthog.temporal.common.logger import BATCH_EXPORT_WORKFLOW_TYPES as LOGGER_BATCH_EXPORT_WORKFLOW_TYPES
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
from products.batch_exports.backend.models.batch_export import BatchExport
from products.batch_exports.backend.service import (
@@ -42,6 +41,11 @@ from products.batch_exports.backend.temporal.pipeline.internal_stage import inse
from products.batch_exports.backend.temporal.queue import RecordBatchQueue
from products.batch_exports.backend.temporal.record_batch_model import SessionsRecordBatchModel
from products.batch_exports.backend.tests.temporal.utils.clickhouse_test_producer import ClickHouseTestProducer
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
from products.batch_exports.backend.tests.temporal.utils.records import (
get_record_batch_from_queue,
remove_duplicates_from_records,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/bigquery/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/bigquery/test_workflow.py
index 19e4dd25713f..fbb6266c46ef 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/bigquery/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/bigquery/test_workflow.py
@@ -14,8 +14,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
-
from products.batch_exports.backend.service import (
BackfillDetails,
BatchExportModel,
@@ -34,6 +32,11 @@ from products.batch_exports.backend.tests.temporal.destinations.bigquery.utils i
TEST_TIME,
assert_clickhouse_records_in_bigquery,
)
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
from products.batch_exports.backend.tests.temporal.utils.workflow import (
NeverFinishingActivity,
mocked_start_batch_export_run,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_activity.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_activity.py
index 65f7ea932b7c..f20156f61946 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_activity.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_activity.py
@@ -6,8 +6,6 @@ from django.test import override_settings
from temporalio.testing._activity import ActivityEnvironment
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
-
from products.batch_exports.backend.models.batch_export import BatchExportFileDownload, BatchExportRun
from products.batch_exports.backend.service import BatchExportInsertInputs, BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.destinations.file_download_batch_export import (
@@ -28,6 +26,7 @@ from products.batch_exports.backend.tests.temporal.destinations.s3.utils import
assert_clickhouse_records_in_s3,
has_valid_credentials,
)
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
pytestmark = [
pytest.mark.requires_vendor_credentials(check=has_valid_credentials),
diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_workflow.py
index faa85b70a551..cee7a746ac85 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_workflow.py
@@ -11,8 +11,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
-
from products.batch_exports.backend.models.batch_export import BatchExportFileDownload
from products.batch_exports.backend.service import BatchExportModel, FileDownloadBatchExportInputs
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
@@ -26,6 +24,11 @@ from products.batch_exports.backend.tests.temporal.destinations.s3.utils import
assert_clickhouse_records_in_s3,
has_valid_credentials,
)
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
from products.batch_exports.backend.tests.temporal.utils.workflow import fail_on_application_error
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
diff --git a/products/batch_exports/backend/tests/temporal/destinations/postgres/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/postgres/conftest.py
index ad01beb44983..1e8cc10b78f1 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/postgres/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/postgres/conftest.py
@@ -92,7 +92,7 @@ def table_name(ateam, interval):
@pytest_asyncio.fixture
async def postgres_batch_export(ateam, table_name, postgres_config, interval, exclude_events, temporal_client):
- from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
+ from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
destination_data = {
"type": "Postgres",
diff --git a/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
index 1a790b4e109e..8a7edffc74af 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/postgres/test_workflow.py
@@ -15,8 +15,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-
from products.batch_exports.backend.service import BackfillDetails, BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
from products.batch_exports.backend.temporal.destinations.postgres_batch_export import (
@@ -29,6 +27,7 @@ from products.batch_exports.backend.tests.temporal.destinations.postgres.utils i
TEST_MODELS,
assert_clickhouse_records_in_postgres,
)
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.workflow import (
WORKFLOW_REAL_TIME_LIMIT_SECONDS,
NeverFinishingActivity,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/redshift/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/redshift/test_workflow.py
index 5243ac42063a..803f08c6d99c 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/redshift/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/redshift/test_workflow.py
@@ -15,8 +15,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
-
from products.batch_exports.backend.models.batch_export import BatchExport
from products.batch_exports.backend.service import BatchExportModel, BatchExportSchema, RedshiftCopyInputs
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
@@ -32,6 +30,11 @@ from products.batch_exports.backend.tests.temporal.destinations.redshift.utils i
TEST_MODELS,
assert_clickhouse_records_in_redshift,
)
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
from products.batch_exports.backend.tests.temporal.utils.s3 import delete_all_from_s3
from products.batch_exports.backend.tests.temporal.utils.workflow import mocked_start_batch_export_run
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
index 4013484d6abf..2f0172920ffb 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
@@ -12,8 +12,8 @@ import pytest_asyncio
import botocore.exceptions
from posthog.models.integration import Integration
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
from products.batch_exports.backend.tests.temporal.utils.s3 import aws_role, create_test_client, delete_all_from_s3
if typing.TYPE_CHECKING:
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
index beb037715a6f..7a2e89c95b87 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
@@ -17,8 +17,6 @@ from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from types_aiobotocore_s3.client import S3Client
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-
from products.batch_exports.backend.service import BatchExportModel
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run
from products.batch_exports.backend.temporal.destinations.s3_batch_export import (
@@ -33,6 +31,7 @@ from products.batch_exports.backend.temporal.pipeline.internal_stage import (
insert_into_internal_stage_activity,
)
from products.batch_exports.backend.tests.temporal.destinations.s3.utils import assert_clickhouse_records_in_s3
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.workflow import (
NeverFinishingActivity,
mocked_start_batch_export_run,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
index 9f261561756a..769ce9eaca9d 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
@@ -5,8 +5,6 @@ import pytest
import aioboto3
import pytest_asyncio
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
-
from products.batch_exports.backend.service import BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.destinations.constants import (
COMPRESSION_EXTENSIONS,
@@ -14,6 +12,7 @@ from products.batch_exports.backend.temporal.destinations.constants import (
)
from products.batch_exports.backend.temporal.destinations.s3_batch_export import SUPPORTED_COMPRESSIONS
from products.batch_exports.backend.tests.temporal.destinations.s3.utils import run_s3_batch_export_workflow
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
from products.batch_exports.backend.tests.temporal.utils.s3 import delete_all_from_s3
pytestmark = [
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
index 093106e800f3..428246e42543 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
@@ -7,7 +7,6 @@ import aioboto3
import pytest_asyncio
from posthog.models.integration import Integration
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
from products.batch_exports.backend.service import BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.destinations.constants import (
@@ -20,6 +19,7 @@ from products.batch_exports.backend.tests.temporal.destinations.s3.utils import
has_valid_credentials,
run_s3_batch_export_workflow,
)
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
from products.batch_exports.backend.tests.temporal.utils.s3 import delete_all_from_s3
pytestmark = [
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
index a43dd14ba56e..a796dbc7fec0 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
@@ -19,7 +19,6 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.hogql import ast
from posthog.temporal.common.clickhouse import ClickHouseClient
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.hogql_source import parse_hogql_select_for_batch_export
from products.batch_exports.backend.service import (
@@ -52,6 +51,7 @@ from products.batch_exports.backend.temporal.record_batch_model import (
SessionsRecordBatchModel,
)
from products.batch_exports.backend.tests.temporal.utils.clickhouse_test_producer import ClickHouseTestProducer
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.records import get_record_batch_from_queue
from products.batch_exports.backend.tests.temporal.utils.s3 import assert_file_in_s3, assert_no_files_in_s3
diff --git a/products/batch_exports/backend/tests/temporal/destinations/snowflake/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/snowflake/conftest.py
index 942360f90865..304c951f7e1e 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/snowflake/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/snowflake/conftest.py
@@ -10,10 +10,10 @@ import pytest_asyncio
import snowflake.connector
from posthog.models.integration import Integration, SnowflakeIntegration
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
from products.batch_exports.backend.models.batch_export import BatchExport
from products.batch_exports.backend.temporal.destinations.snowflake_batch_export import load_private_key
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
@pytest.fixture
diff --git a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
index 4be4449df606..3209826fa5e6 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow.py
@@ -21,7 +21,6 @@ from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.temporal.tests.utils.events import generate_test_events_in_clickhouse
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.models.batch_export import BatchExport, BatchExportRun
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
@@ -35,6 +34,7 @@ from products.batch_exports.backend.tests.temporal.destinations.snowflake.utils
TEST_TIME,
FakeSnowflakeConnection,
)
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.tests.temporal.utils.workflow import (
WORKFLOW_REAL_TIME_LIMIT_SECONDS,
NeverFinishingActivity,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow_e2e.py b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow_e2e.py
index ef7010f24490..be5904fea9a5 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow_e2e.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/snowflake/test_workflow_e2e.py
@@ -19,7 +19,6 @@ from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.temporal.tests.utils.events import generate_test_events_in_clickhouse
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.service import BackfillDetails, BatchExportModel, BatchExportSchema
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
@@ -35,6 +34,7 @@ from products.batch_exports.backend.tests.temporal.destinations.snowflake.utils
TEST_TIME,
assert_clickhouse_records_in_snowflake,
)
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
pytestmark = [
pytest.mark.asyncio,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py
index 131ef02a879d..bdb43bbc8a9d 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py
@@ -21,7 +21,6 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.sync import database_sync_to_async
from posthog.temporal.common.clickhouse import ClickHouseClient
from posthog.temporal.tests.utils.events import generate_test_events_in_clickhouse
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
from products.batch_exports.backend.service import BackfillDetails, BatchExportModel
from products.batch_exports.backend.temporal.batch_exports import (
@@ -39,6 +38,11 @@ from products.batch_exports.backend.temporal.destinations.http_batch_export impo
insert_into_http_activity,
)
from products.batch_exports.backend.temporal.filters import compose_filters_clause
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
from products.batch_exports.backend.tests.temporal.utils.workflow import (
NeverFinishingActivity,
mocked_start_batch_export_run,
diff --git a/products/batch_exports/backend/tests/temporal/destinations/workflows/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/workflows/test_workflow.py
index e3e0a48c7f06..4c5f6fc18788 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/workflows/test_workflow.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/workflows/test_workflow.py
@@ -10,8 +10,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
-
from products.batch_exports.backend.service import BatchExportModel
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
from products.batch_exports.backend.temporal.destinations.workflows_batch_export import (
@@ -23,6 +21,11 @@ from products.batch_exports.backend.temporal.pipeline.internal_stage import inse
from products.batch_exports.backend.tests.temporal.destinations.workflows.utils import (
assert_clickhouse_records_were_handled,
)
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
pytestmark = [
pytest.mark.asyncio,
diff --git a/products/batch_exports/backend/tests/temporal/pipeline/test_entrypoint.py b/products/batch_exports/backend/tests/temporal/pipeline/test_entrypoint.py
index b2080b17847c..760847f2a64e 100644
--- a/products/batch_exports/backend/tests/temporal/pipeline/test_entrypoint.py
+++ b/products/batch_exports/backend/tests/temporal/pipeline/test_entrypoint.py
@@ -17,7 +17,6 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.temporal.common.base import PostHogWorkflow
from posthog.temporal.common.clickhouse import ClickHouseMemoryLimitExceededError
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
from products.batch_exports.backend.models.batch_export import BatchExport, BatchExportDestination
from products.batch_exports.backend.service import BaseBatchExportInputs, BatchExportInsertInputs, BatchExportModel
@@ -31,6 +30,7 @@ from products.batch_exports.backend.temporal.pipeline.entrypoint import execute_
from products.batch_exports.backend.temporal.pipeline.internal_stage import insert_into_internal_stage_activity
from products.batch_exports.backend.temporal.pipeline.types import BatchExportResult
from products.batch_exports.backend.temporal.utils import handle_non_retryable_errors
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
diff --git a/products/batch_exports/backend/tests/temporal/test_batch_export_utils.py b/products/batch_exports/backend/tests/temporal/test_batch_export_utils.py
index 748f2ee767e4..547ac3e16f83 100644
--- a/products/batch_exports/backend/tests/temporal/test_batch_export_utils.py
+++ b/products/batch_exports/backend/tests/temporal/test_batch_export_utils.py
@@ -5,10 +5,9 @@ import pytest
import pytest_asyncio
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export
-
from products.batch_exports.backend.models.batch_export import BatchExportRun
from products.batch_exports.backend.temporal.utils import set_status_to_running_task
+from products.batch_exports.backend.tests.temporal.utils.models import acreate_batch_export, adelete_batch_export
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
diff --git a/products/batch_exports/backend/tests/temporal/test_billing_limits.py b/products/batch_exports/backend/tests/temporal/test_billing_limits.py
index b997580bc9cb..5b4c12110246 100644
--- a/products/batch_exports/backend/tests/temporal/test_billing_limits.py
+++ b/products/batch_exports/backend/tests/temporal/test_billing_limits.py
@@ -24,8 +24,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-
from products.batch_exports.backend.models.batch_export import BatchExport, BatchExportDestination, BatchExportRun
from products.batch_exports.backend.service import (
AzureBlobBatchExportInputs,
@@ -48,6 +46,7 @@ from products.batch_exports.backend.temporal.destinations.postgres_batch_export
from products.batch_exports.backend.temporal.destinations.redshift_batch_export import RedshiftBatchExportWorkflow
from products.batch_exports.backend.temporal.destinations.s3_batch_export import S3BatchExportWorkflow
from products.batch_exports.backend.temporal.destinations.snowflake_batch_export import SnowflakeBatchExportWorkflow
+from products.batch_exports.backend.tests.temporal.utils.models import afetch_batch_export_runs
pytestmark = [
pytest.mark.asyncio,
diff --git a/products/batch_exports/backend/tests/temporal/test_monitoring.py b/products/batch_exports/backend/tests/temporal/test_monitoring.py
index 16be6eb0fec9..0cbf7eb060d7 100644
--- a/products/batch_exports/backend/tests/temporal/test_monitoring.py
+++ b/products/batch_exports/backend/tests/temporal/test_monitoring.py
@@ -11,8 +11,6 @@ from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
-from posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_export, afetch_batch_export_runs
-
from products.batch_exports.backend.models.batch_export import BatchExportRun
from products.batch_exports.backend.service import afetch_batch_export_runs_in_range
from products.batch_exports.backend.temporal.monitoring import (
@@ -32,6 +30,11 @@ from products.batch_exports.backend.tests.temporal.utils.clickhouse import (
create_clickhouse_tables_and_views,
truncate_events,
)
+from products.batch_exports.backend.tests.temporal.utils.models import (
+ acreate_batch_export,
+ adelete_batch_export,
+ afetch_batch_export_runs,
+)
pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]
diff --git a/posthog/temporal/tests/utils/models.py b/products/batch_exports/backend/tests/temporal/utils/models.py
similarity index 100%
rename from posthog/temporal/tests/utils/models.py
rename to products/batch_exports/backend/tests/temporal/utils/models.py
diff --git a/tach.toml b/tach.toml
index 71545ff8c5f8..52e83cb5d7e4 100644
--- a/tach.toml
+++ b/tach.toml
@@ -1302,27 +1302,16 @@ from = [
"products.batch_exports",
]
-# Legacy leaks — core (posthog), cdp and warehouse_sources still import these batch_exports
-# internals directly. Each entry names its crossing and the facade that replaces it. The block
+# Legacy leaks — cdp and warehouse_sources still import these batch_exports internals
+# directly. Each entry names its crossing and the facade that replaces it. The block
# drains as those callers move, and keeps backend:contract-check off until it is empty.
# tach interfaces have no consumer scoping, so this block opens the listed paths to every module,
# not only to the consumers named below.
[[interfaces]]
expose = [
- # The shared Temporal test utilities read the models.
- # Exit: move the utilities into the product.
- "backend\\.models.*",
- # The shared Temporal test utilities, the payload codec test and the warehouse_sources S3
- # writer reach the service layer.
- # Exit: facade.testing and contracts.AWSCredentials.
+ # The warehouse_sources S3 writer reads AWSCredentials from the service layer.
+ # Exit: facade.pipeline.
"backend\\.service.*",
- # The worker bootstrap commands, the worker's metrics interceptor, the shared Temporal test
- # conftest and the team-deletion test register the workflows and activities.
- # Exit: facade.temporal.
- "backend\\.temporal\\.ACTIVITIES",
- "backend\\.temporal\\.WORKFLOWS",
- "backend\\.temporal\\.metrics.*",
- "backend\\.temporal\\.noop.*",
# The warehouse_sources data-import writers reuse the destination clients and the stream
# transformers.
# Exit: facade.pipeline.