: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
chore(batch-exports): move views into `presentation/` (#111810)
Rossa6f293b70c41
diff --git a/posthog/api/documentation.py b/posthog/api/documentation.pyindex 73962bb37500..5d5860fdf698 100644--- a/posthog/api/documentation.py+++ b/posthog/api/documentation.py@@ -729,7 +729,7 @@ _ORG_PROJECTS_FINAL_RE = re.compile(r"^/api/organizations/[^/]+/projects/")def _get_product_from_module(module: str) -> str | None:- """Extract product folder name from module path like 'products.batch_exports.backend.api'."""+ """Extract product folder name from module path like 'products.batch_exports.backend.presentation.views'."""if is_product_module(module):parts = module.split(".")if len(parts) >= 2:diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 84f0922048c7..7f25c61442f6 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -84,8 +84,8 @@1 products/apm/backend/logic/anomaly_detection/types.py1 products/apm/backend/logic/anomaly_detection/validation/simulation.py1 products/approvals/backend/decorators.py-1 products/batch_exports/backend/api/batch_export.py-1 products/batch_exports/backend/api/destination_tests/base.py+1 products/batch_exports/backend/presentation/views/batch_export.py+1 products/batch_exports/backend/presentation/views/destination_tests/base.py1 products/batch_exports/backend/debug/debugger.py1 products/batch_exports/backend/temporal/destinations/azure_blob_batch_export.py1 products/batch_exports/backend/temporal/destinations/bigquery_batch_export.pydiff --git a/posthog/test/repo_invariants/test_pagination_contract.py b/posthog/test/repo_invariants/test_pagination_contract.pyindex 933b57639551..a09b655f7f99 100644--- a/posthog/test/repo_invariants/test_pagination_contract.py+++ b/posthog/test/repo_invariants/test_pagination_contract.py@@ -105,7 +105,7 @@ EXISTING_CUSTOM_LIST_VIEWSETS = {"products.autoresearch.backend.presentation.views.views.AutoresearchRunViewSet","products.autoresearch.backend.presentation.views.views.AutoresearchSuggestionViewSet","products.autoresearch.backend.presentation.views.views.AutoresearchTrainingRunViewSet",- "products.batch_exports.backend.api.batch_export.BatchExportRunViewSet",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportRunViewSet","products.business_knowledge.backend.api.playground.BusinessKnowledgePlaygroundChatViewSet","products.business_knowledge.backend.api.views.KnowledgeGapSuggestionViewSet","products.business_knowledge.backend.api.views.KnowledgeSourceViewSet",diff --git a/posthog/test/repo_invariants/test_serializer_timestamp_guard.py b/posthog/test/repo_invariants/test_serializer_timestamp_guard.pyindex dc89374ca063..a9f62f27229d 100644--- a/posthog/test/repo_invariants/test_serializer_timestamp_guard.py+++ b/posthog/test/repo_invariants/test_serializer_timestamp_guard.py@@ -101,16 +101,16 @@ REVIEWED_WRITABLE: dict[str, str] = {"products.actions.backend.api.action.ActionSerializer.pinned_at": "TODO: server-derived on pin. update() discards the supplied value and stores its own now(); only the null that unpins is the client's","products.alerts.backend.presentation.views.alert.AlertSerializer.snoozed_until": "TODO: server-derived. The client sends a relative date string and update() resolves it to the stored instant","products.annotations.backend.api.annotation.AnnotationSerializer.date_marker": "Client sets when the annotation happened, to place it on a chart",- "products.batch_exports.backend.api.batch_export.BatchExportBackfillSerializer.adjusted_start_at": "TODO: server-owned, the backfill derives it from the earliest available data",- "products.batch_exports.backend.api.batch_export.BatchExportBackfillSerializer.end_at": "Client requests the data interval to backfill",- "products.batch_exports.backend.api.batch_export.BatchExportBackfillSerializer.finished_at": "TODO: server-owned, written by the backfill workflow when it ends",- "products.batch_exports.backend.api.batch_export.BatchExportBackfillSerializer.start_at": "Client requests the data interval to backfill",- "products.batch_exports.backend.api.batch_export.BatchExportRunSerializer.data_interval_end": "Response shape for the POST cancel and retry actions, which take no request body",- "products.batch_exports.backend.api.batch_export.BatchExportRunSerializer.data_interval_start": "Response shape for the POST cancel and retry actions, which take no request body",- "products.batch_exports.backend.api.batch_export.BatchExportRunSerializer.finished_at": "Response shape for the POST cancel and retry actions, which take no request body",- "products.batch_exports.backend.api.batch_export.BatchExportSerializer.end_at": "Client-supplied bound, runs after it are not triggered",- "products.batch_exports.backend.api.batch_export.BatchExportSerializer.last_paused_at": "TODO: written by the pause action, make read-only",- "products.batch_exports.backend.api.batch_export.BatchExportSerializer.start_at": "Client-supplied bound, runs before it are not triggered",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportBackfillSerializer.adjusted_start_at": "TODO: server-owned, the backfill derives it from the earliest available data",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportBackfillSerializer.end_at": "Client requests the data interval to backfill",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportBackfillSerializer.finished_at": "TODO: server-owned, written by the backfill workflow when it ends",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportBackfillSerializer.start_at": "Client requests the data interval to backfill",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportRunSerializer.data_interval_end": "Response shape for the POST cancel and retry actions, which take no request body",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportRunSerializer.data_interval_start": "Response shape for the POST cancel and retry actions, which take no request body",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportRunSerializer.finished_at": "Response shape for the POST cancel and retry actions, which take no request body",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportSerializer.end_at": "Client-supplied bound, runs after it are not triggered",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportSerializer.last_paused_at": "TODO: written by the pause action, make read-only",+ "products.batch_exports.backend.presentation.views.batch_export.BatchExportSerializer.start_at": "Client-supplied bound, runs before it are not triggered","products.billing_alerts.backend.presentation.serializers.BillingAlertConfigurationSerializer.snoozed_until": "Client-set instant: a plain DateTimeField that ModelSerializer writes to the column unchanged, with no relative-duration parsing on this path","products.conversations.backend.api.tickets.TicketSerializer.sla_due_at": "Client or a workflow sets the SLA deadline, and null clears it","products.conversations.backend.api.tickets.TicketSerializer.snoozed_until": "Client-set instant: the ticket action assigns validated_data['snoozed_until'] to ticket.snoozed_until, with no relative-duration parsing on this path",diff --git a/products/batch_exports/backend/api/test/__init__.py b/products/batch_exports/backend/api/test/__init__.pydeleted file mode 100644index e69de29bb2d1..000000000000diff --git a/products/batch_exports/backend/presentation/__init__.py b/products/batch_exports/backend/presentation/__init__.pynew file mode 100644index 000000000000..1b037f5d5bd4--- /dev/null+++ b/products/batch_exports/backend/presentation/__init__.py@@ -0,0 +1 @@+"""HTTP presentation layer of the batch_exports product (DRF viewsets and serializers)."""diff --git a/products/batch_exports/backend/api/__init__.py b/products/batch_exports/backend/presentation/views/__init__.pysimilarity index 100%rename from products/batch_exports/backend/api/__init__.pyrename to products/batch_exports/backend/presentation/views/__init__.pydiff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/presentation/views/batch_export.pysimilarity index 99%rename from products/batch_exports/backend/api/batch_export.pyrename to products/batch_exports/backend/presentation/views/batch_export.pyindex 670c2aabef41..8457d274d7be 100644--- a/products/batch_exports/backend/api/batch_export.py+++ b/products/batch_exports/backend/presentation/views/batch_export.py@@ -52,12 +52,6 @@ from posthog.temporal.common.client import sync_connectfrom posthog.utils import relative_date_parse, str_to_boolfrom products.access_control.backend.facade.api import get_restricted_properties_with_group_type_index_for_team-from products.batch_exports.backend.api.destination_tests import get_destination_test-from products.batch_exports.backend.api.utils import (- HOGQL_MODIFIERS_HELP_TEXT,- HogQLModifiersField,- check_hogql_batch_exports_enabled,-)from products.batch_exports.backend.facade.contracts import InvalidBatchExportFiltersfrom products.batch_exports.backend.filters import SUPPORTED_FILTER_TYPES_DISPLAY, validate_batch_export_filtersfrom products.batch_exports.backend.hogql_source import (@@ -80,6 +74,12 @@ from products.batch_exports.backend.models.batch_export import (BatchExportRun,BatchExportSource,)+from products.batch_exports.backend.presentation.views.destination_tests import get_destination_test+from products.batch_exports.backend.presentation.views.utils import (+ HOGQL_MODIFIERS_HELP_TEXT,+ HogQLModifiersField,+ check_hogql_batch_exports_enabled,+)from products.batch_exports.backend.service import (DESTINATION_WORKFLOWS,BaseBatchExportInputs,diff --git a/products/batch_exports/backend/api/destination_tests/__init__.py b/products/batch_exports/backend/presentation/views/destination_tests/__init__.pysimilarity index 56%rename from products/batch_exports/backend/api/destination_tests/__init__.pyrename to products/batch_exports/backend/presentation/views/destination_tests/__init__.pyindex b1065dd1c975..2106e7fb1680 100644--- a/products/batch_exports/backend/api/destination_tests/__init__.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/__init__.py@@ -1,4 +1,4 @@-from products.batch_exports.backend.api.destination_tests.base import DestinationTest+from products.batch_exports.backend.presentation.views.destination_tests.base import DestinationTestdef get_destination_test(@@ -11,33 +11,37 @@ def get_destination_test(SDKs off the API import path — only the requested destination's SDK loads."""if destination == "S3Compatible":- from products.batch_exports.backend.api.destination_tests.s3 import S3CompatibleDestinationTest # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.s3 import ( # noqa: PLC0415+ S3CompatibleDestinationTest,+ )return S3CompatibleDestinationTest()elif destination == "AwsS3":- from products.batch_exports.backend.api.destination_tests.s3 import AwsS3DestinationTest # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.s3 import ( # noqa: PLC0415+ AwsS3DestinationTest,+ )return AwsS3DestinationTest()elif destination == "BigQuery":- from products.batch_exports.backend.api.destination_tests.bigquery import ( # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.bigquery import ( # noqa: PLC0415BigQueryDestinationTest,)return BigQueryDestinationTest()elif destination == "Snowflake":- from products.batch_exports.backend.api.destination_tests.snowflake import ( # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.snowflake import ( # noqa: PLC0415SnowflakeDestinationTest,)return SnowflakeDestinationTest()elif destination == "Databricks":- from products.batch_exports.backend.api.destination_tests.databricks import ( # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.databricks import ( # noqa: PLC0415DatabricksDestinationTest,)return DatabricksDestinationTest()elif destination == "AzureBlob":- from products.batch_exports.backend.api.destination_tests.azure_blob import ( # noqa: PLC0415+ from products.batch_exports.backend.presentation.views.destination_tests.azure_blob import ( # noqa: PLC0415AzureBlobDestinationTest,)diff --git a/products/batch_exports/backend/api/destination_tests/azure_blob.py b/products/batch_exports/backend/presentation/views/destination_tests/azure_blob.pysimilarity index 97%rename from products/batch_exports/backend/api/destination_tests/azure_blob.pyrename to products/batch_exports/backend/presentation/views/destination_tests/azure_blob.pyindex e19c3307609b..2c8a5df11bda 100644--- a/products/batch_exports/backend/api/destination_tests/azure_blob.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/azure_blob.py@@ -2,7 +2,7 @@ import collections.abcfrom posthog.models.integration.azure_blob import strip_leading_whitespace, validate_azure_blob_connection_string-from products.batch_exports.backend.api.destination_tests.base import (+from products.batch_exports.backend.presentation.views.destination_tests.base import (DestinationTest,DestinationTestStep,DestinationTestStepResult,diff --git a/products/batch_exports/backend/api/destination_tests/base.py b/products/batch_exports/backend/presentation/views/destination_tests/base.pysimilarity index 100%rename from products/batch_exports/backend/api/destination_tests/base.pyrename to products/batch_exports/backend/presentation/views/destination_tests/base.pydiff --git a/products/batch_exports/backend/api/destination_tests/bigquery.py b/products/batch_exports/backend/presentation/views/destination_tests/bigquery.pysimilarity index 99%rename from products/batch_exports/backend/api/destination_tests/bigquery.pyrename to products/batch_exports/backend/presentation/views/destination_tests/bigquery.pyindex b59fe5550052..c812e05fcdaf 100644--- a/products/batch_exports/backend/api/destination_tests/bigquery.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/bigquery.py@@ -7,7 +7,7 @@ from google.cloud import bigquery, iam_admin_v1from posthog.models.integration import GoogleCloudServiceAccountIntegration-from products.batch_exports.backend.api.destination_tests.base import (+from products.batch_exports.backend.presentation.views.destination_tests.base import (DestinationTest,DestinationTestStep,DestinationTestStepResult,diff --git a/products/batch_exports/backend/api/destination_tests/databricks.py b/products/batch_exports/backend/presentation/views/destination_tests/databricks.pysimilarity index 99%rename from products/batch_exports/backend/api/destination_tests/databricks.pyrename to products/batch_exports/backend/presentation/views/destination_tests/databricks.pyindex c7d782932d2b..2919e31306b0 100644--- a/products/batch_exports/backend/api/destination_tests/databricks.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/databricks.py@@ -2,7 +2,7 @@ import contextlibimport collections.abcfrom collections.abc import AsyncGenerator-from products.batch_exports.backend.api.destination_tests.base import (+from products.batch_exports.backend.presentation.views.destination_tests.base import (DestinationTest,DestinationTestStep,DestinationTestStepResult,diff --git a/products/batch_exports/backend/api/destination_tests/s3.py b/products/batch_exports/backend/presentation/views/destination_tests/s3.pysimilarity index 99%rename from products/batch_exports/backend/api/destination_tests/s3.pyrename to products/batch_exports/backend/presentation/views/destination_tests/s3.pyindex 0d5e5e2d165c..8f888072d22c 100644--- a/products/batch_exports/backend/api/destination_tests/s3.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/s3.py@@ -1,6 +1,6 @@import collections.abc-from products.batch_exports.backend.api.destination_tests.base import (+from products.batch_exports.backend.presentation.views.destination_tests.base import (DestinationTest,DestinationTestStep,DestinationTestStepResult,diff --git a/products/batch_exports/backend/api/destination_tests/snowflake.py b/products/batch_exports/backend/presentation/views/destination_tests/snowflake.pysimilarity index 99%rename from products/batch_exports/backend/api/destination_tests/snowflake.pyrename to products/batch_exports/backend/presentation/views/destination_tests/snowflake.pyindex e9c1056fa65e..f9c78b7d69f3 100644--- a/products/batch_exports/backend/api/destination_tests/snowflake.py+++ b/products/batch_exports/backend/presentation/views/destination_tests/snowflake.py@@ -1,7 +1,7 @@import asyncioimport collections.abc-from products.batch_exports.backend.api.destination_tests.base import (+from products.batch_exports.backend.presentation.views.destination_tests.base import (DestinationTest,DestinationTestStep,DestinationTestStepResult,diff --git a/products/batch_exports/backend/api/file_download.py b/products/batch_exports/backend/presentation/views/file_download.pysimilarity index 99%rename from products/batch_exports/backend/api/file_download.pyrename to products/batch_exports/backend/presentation/views/file_download.pyindex a6c125459c86..dfe9b59a71c9 100644--- a/products/batch_exports/backend/api/file_download.py+++ b/products/batch_exports/backend/presentation/views/file_download.py@@ -34,11 +34,6 @@ from posthog.models import Team, Userfrom posthog.rate_limit import BatchExportsCountRowsBurstRateThrottle, BatchExportsCountRowsSustainedRateThrottlefrom posthog.temporal.common.client import sync_connect-from products.batch_exports.backend.api.utils import (- HOGQL_MODIFIERS_HELP_TEXT,- HogQLModifiersField,- check_hogql_batch_exports_enabled,-)from products.batch_exports.backend.hogql_source import (UnsupportedHogQLQueryError,find_interval_placeholders,@@ -53,6 +48,11 @@ from products.batch_exports.backend.models.batch_export import (BatchExportRun,BatchExportSource,)+from products.batch_exports.backend.presentation.views.utils import (+ HOGQL_MODIFIERS_HELP_TEXT,+ HogQLModifiersField,+ check_hogql_batch_exports_enabled,+)from products.batch_exports.backend.service import (BatchExportModel,cancel_running_batch_export_run,diff --git a/products/batch_exports/backend/api/utils.py b/products/batch_exports/backend/presentation/views/utils.pysimilarity index 100%rename from products/batch_exports/backend/api/utils.pyrename to products/batch_exports/backend/presentation/views/utils.pydiff --git a/products/batch_exports/backend/routes.py b/products/batch_exports/backend/routes.pyindex 6dbcf7db4335..ad0e5aea91cc 100644--- a/products/batch_exports/backend/routes.py+++ b/products/batch_exports/backend/routes.py@@ -1,6 +1,6 @@from posthog.api.routing import RouterRegistry-from products.batch_exports.backend.api import (+from products.batch_exports.backend.presentation.views import (batch_export as batch_exports,file_download,)diff --git a/products/batch_exports/backend/tests/api/backfills/test_create.py b/products/batch_exports/backend/tests/api/backfills/test_create.pyindex 1734496a4ad7..583222e8aaf5 100644--- a/products/batch_exports/backend/tests/api/backfills/test_create.py+++ b/products/batch_exports/backend/tests/api/backfills/test_create.py@@ -423,7 +423,10 @@ def test_batch_export_earliest_backfill_rejected_without_feature_flag(batch_export = _create_batch_export_ok(client, team, aws_s3_integration.id, "persons")batch_export_id = batch_export["id"]- with patch("products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled", return_value=False):+ with patch(+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",+ return_value=False,+ ):response = backfill_batch_export(client,team.pk,@@ -566,7 +569,10 @@ def test_batch_export_earliest_backfill_allowed_with_feature_flag(batch_export = _create_batch_export_ok(client, team, aws_s3_integration.id, "persons")batch_export_id = batch_export["id"]- with patch("products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled", return_value=True):+ with patch(+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",+ return_value=True,+ ):response = backfill_batch_export(client,team.pk,@@ -653,9 +659,12 @@ def test_batch_export_backfill_hogql_interval_validation()with (- patch("products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled", return_value=True),- patch("products.batch_exports.backend.api.batch_export.sync_connect") as connect,- patch("products.batch_exports.backend.api.batch_export.backfill_export") as backfill,+ patch(+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",+ return_value=True,+ ),+ patch("products.batch_exports.backend.presentation.views.batch_export.sync_connect") as connect,+ patch("products.batch_exports.backend.presentation.views.batch_export.backfill_export") as backfill,):response = backfill_batch_export(client, team.pk, str(batch_export.pk), start_at, "2021-01-01T01:00:00+00:00")diff --git a/products/batch_exports/backend/tests/api/conftest.py b/products/batch_exports/backend/tests/api/conftest.pyindex 2f2bb7383dbc..6ecd1c42ae03 100644--- a/products/batch_exports/backend/tests/api/conftest.py+++ b/products/batch_exports/backend/tests/api/conftest.py@@ -141,7 +141,7 @@ def s3_compatible_integration(team, user):def hogql_batch_exports_enabled():"""Enable the hogql-batch-exports feature flag for the duration of a test."""with mock.patch(- "products.batch_exports.backend.api.utils.posthoganalytics.feature_enabled", return_value=True+ "products.batch_exports.backend.presentation.views.utils.posthoganalytics.feature_enabled", return_value=True) as feature_enabled:yield feature_enableddiff --git a/products/batch_exports/backend/tests/api/destination_tests/test_azure_blob_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_azure_blob_destination_tests.pyindex 6e6d0943d152..482dc0a2d856 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_azure_blob_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_azure_blob_destination_tests.py@@ -5,7 +5,10 @@ import pytestfrom azure.storage.blob.aio import BlobServiceClient-from products.batch_exports.backend.api.destination_tests.azure_blob import AzureBlobContainerTestStep, Status+from products.batch_exports.backend.presentation.views.destination_tests.azure_blob import (+ AzureBlobContainerTestStep,+ Status,+)from products.batch_exports.backend.tests.temporal.destinations.azure_blob.conftest import AZURITE_CONNECTION_STRINGpytestmark = [pytest.mark.asyncio]diff --git a/products/batch_exports/backend/tests/api/destination_tests/test_bigquery_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_bigquery_destination_tests.pyindex 0ca54d890ac7..a574f744c14d 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_bigquery_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_bigquery_destination_tests.py@@ -12,7 +12,7 @@ from google.cloud import bigquery, exceptionsfrom posthog.models.integration import GoogleCloudServiceAccountIntegration-from products.batch_exports.backend.api.destination_tests.bigquery import (+from products.batch_exports.backend.presentation.views.destination_tests.bigquery import (BigQueryDatasetTestStep,BigQueryImpersonateServiceAccountTestStep,BigQueryProjectTestStep,diff --git a/products/batch_exports/backend/tests/api/destination_tests/test_databricks_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_databricks_destination_tests.pyindex 489843079893..5f3956d2bcd3 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_databricks_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_databricks_destination_tests.py@@ -7,8 +7,8 @@ from unittest.mock import patchfrom databricks import sqlfrom databricks.sdk.core import Config, oauth_service_principal-from products.batch_exports.backend.api.destination_tests.base import Status-from products.batch_exports.backend.api.destination_tests.databricks import (+from products.batch_exports.backend.presentation.views.destination_tests.base import Status+from products.batch_exports.backend.presentation.views.destination_tests.databricks import (DatabricksCatalogTestStep,DatabricksEstablishConnectionTestStep,DatabricksSchemaTestStep,@@ -247,7 +247,7 @@ class TestDatabricksVolumeTestStep:and one where it doesn't."""with patch(- "products.batch_exports.backend.api.destination_tests.databricks.DatabricksClient.acreate_volume",+ "products.batch_exports.backend.presentation.views.destination_tests.databricks.DatabricksClient.acreate_volume",side_effect=DatabricksInsufficientPermissionsError("CREATE VOLUME", "Insufficient permissions"),):test_step = DatabricksVolumeTestStep(diff --git a/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.pyindex 52e26ae42070..a52fccf9f61f 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py@@ -5,8 +5,8 @@ import pytestfrom django.conf import settingsfrom django.test import override_settings-from products.batch_exports.backend.api.destination_tests import get_destination_test-from products.batch_exports.backend.api.destination_tests.s3 import (+from products.batch_exports.backend.presentation.views.destination_tests import get_destination_test+from products.batch_exports.backend.presentation.views.destination_tests.s3 import (AwsS3DestinationTest,S3AssumeRoleTestStep,S3CompatibleDestinationTest,diff --git a/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.pyindex 3d0d0ca26d9c..a32dd42f4c13 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_snowflake_destination_tests.py@@ -5,7 +5,7 @@ import pytestimport snowflake.connector-from products.batch_exports.backend.api.destination_tests.snowflake import (+from products.batch_exports.backend.presentation.views.destination_tests.snowflake import (SnowflakeDatabaseTestStep,SnowflakeEstablishConnectionTestStep,SnowflakeSchemaTestStep,diff --git a/products/batch_exports/backend/tests/api/test_create.py b/products/batch_exports/backend/tests/api/test_create.pyindex bece3c9ede49..9333bc3937df 100644--- a/products/batch_exports/backend/tests/api/test_create.py+++ b/products/batch_exports/backend/tests/api/test_create.py@@ -227,7 +227,7 @@ def test_create_batch_export_with_different_intervals_timezones_and_interval_off# ensure high-frequency-batch-exports feature flag is enabledwith mock.patch(- "products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled",+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",return_value=True,):response = create_batch_export(@@ -429,7 +429,7 @@ def test_cannot_create_a_batch_export_with_higher_frequencies_if_not_enabled(client.force_login(user)with mock.patch(- "products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled",+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",return_value=False,) as feature_enabled:response = create_batch_export(@@ -765,7 +765,7 @@ def test_cannot_create_batch_export_with_hogql_model_if_not_enabled():client.force_login(user)with mock.patch(- "products.batch_exports.backend.api.utils.posthoganalytics.feature_enabled", return_value=False+ "products.batch_exports.backend.presentation.views.utils.posthoganalytics.feature_enabled", return_value=False) as feature_enabled:response = create_batch_export(client, team.pk, hogql_batch_export_data)diff --git a/products/batch_exports/backend/tests/api/test_create_workflows.py b/products/batch_exports/backend/tests/api/test_create_workflows.pyindex b7e7c78124af..7daa7fb656b2 100644--- a/products/batch_exports/backend/tests/api/test_create_workflows.py+++ b/products/batch_exports/backend/tests/api/test_create_workflows.py@@ -17,7 +17,8 @@ pytestmark = [@pytest.fixturedef enable_backfilling_workflows(team):with mock.patch(- "products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled", return_value=True+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",+ return_value=True,) as feature_enabled:yielddiff --git a/products/batch_exports/backend/tests/api/test_list.py b/products/batch_exports/backend/tests/api/test_list.pyindex 2ba11d4f4a93..6c07fff21640 100644--- a/products/batch_exports/backend/tests/api/test_list.py+++ b/products/batch_exports/backend/tests/api/test_list.py@@ -86,7 +86,8 @@ def test_list_is_partitioned_by_team(client: HttpClient, organization, team, use@pytest.fixturedef enable_backfilling_workflows(team):with mock.patch(- "products.batch_exports.backend.api.batch_export.posthoganalytics.feature_enabled", return_value=True+ "products.batch_exports.backend.presentation.views.batch_export.posthoganalytics.feature_enabled",+ return_value=True,) as feature_enabled:yielddiff --git a/products/batch_exports/backend/tests/api/test_serializers.py b/products/batch_exports/backend/tests/api/test_serializers.pyindex 38d4108a401e..30952fa725b4 100644--- a/products/batch_exports/backend/tests/api/test_serializers.py+++ b/products/batch_exports/backend/tests/api/test_serializers.py@@ -16,7 +16,7 @@ from posthog.api.scoped_related_fields import TeamScopedPrimaryKeyRelatedFieldfrom posthog.models import Organization, PropertyDefinition, Teamfrom posthog.models.integration import Integration-from products.batch_exports.backend.api.batch_export import (+from products.batch_exports.backend.presentation.views.batch_export import (BatchExportDestinationSerializer,BatchExportSerializer,parse_events_hogql_query,@@ -165,7 +165,7 @@ class TestSerializeHogQLQueryToBatchExportSchema(BaseTest):)with (patch(- "products.batch_exports.backend.api.batch_export."+ "products.batch_exports.backend.presentation.views.batch_export.""get_restricted_properties_with_group_type_index_for_team",return_value=restrictions,),@@ -186,7 +186,9 @@ class TestSerializeHogQLQueryToBatchExportSchema(BaseTest):assert "mat_$browser" in expression@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- @patch("products.batch_exports.backend.api.batch_export.get_restricted_properties_with_group_type_index_for_team")+ @patch(+ "products.batch_exports.backend.presentation.views.batch_export.get_restricted_properties_with_group_type_index_for_team"+ )@patch("posthog.models.event.new_events_schema.use_new_events_schema", return_value=True)def test_restricted_property_query_is_not_recompiled_without_user(self, _use_new_events_schema, get_restricted_properties@@ -216,7 +218,9 @@ class TestSerializeHogQLQueryToBatchExportSchema(BaseTest):])@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- @patch("products.batch_exports.backend.api.batch_export.get_restricted_properties_with_group_type_index_for_team")+ @patch(+ "products.batch_exports.backend.presentation.views.batch_export.get_restricted_properties_with_group_type_index_for_team"+ )@patch("posthog.models.event.new_events_schema.use_new_events_schema", return_value=True)def test_native_export_hides_a_restricted_flag(self, _name: str, query: str, expected: str, _use_new_events_schema, get_restricted_propertiesdiff --git a/products/batch_exports/backend/tests/api/test_test.py b/products/batch_exports/backend/tests/api/test_test.pyindex 632b746d2973..ac5bbe790aef 100644--- a/products/batch_exports/backend/tests/api/test_test.py+++ b/products/batch_exports/backend/tests/api/test_test.py@@ -13,13 +13,13 @@ from rest_framework import statusfrom posthog.models import Integration-from products.batch_exports.backend.api.destination_tests.base import DestinationTestStepResult, Status-from products.batch_exports.backend.api.destination_tests.bigquery import BigQueryProjectTestStep-from products.batch_exports.backend.api.destination_tests.databricks import (+from products.batch_exports.backend.models.batch_export import BatchExportDestination+from products.batch_exports.backend.presentation.views.destination_tests.base import DestinationTestStepResult, Status+from products.batch_exports.backend.presentation.views.destination_tests.bigquery import BigQueryProjectTestStep+from products.batch_exports.backend.presentation.views.destination_tests.databricks import (DatabricksDestinationTest,DatabricksEstablishConnectionTestStep,)-from products.batch_exports.backend.models.batch_export import BatchExportDestinationfrom products.batch_exports.backend.tests.api.operations import create_batch_export_okpytestmark = [@@ -219,7 +219,7 @@ def test_run_test_step_rejects_destination_type_change(}with unittest.mock.patch(- "products.batch_exports.backend.api.batch_export.get_destination_test"+ "products.batch_exports.backend.presentation.views.batch_export.get_destination_test") as mock_get_destination_test:response = client.post(f"/api/projects/{team.pk}/batch_exports/{batch_export['id']}/run_test_step",@@ -348,7 +348,7 @@ def test_can_run_bigquery_test_step_with_castable_type()with unittest.mock.patch(- "products.batch_exports.backend.api.destination_tests.base.DestinationTest.run_step"+ "products.batch_exports.backend.presentation.views.destination_tests.base.DestinationTest.run_step") as run_step_mocked:fake_test_step = BigQueryProjectTestStep()fake_test_step.result = DestinationTestStepResult(status=Status.PASSED, message=None)@@ -404,7 +404,7 @@ def test_can_run_databricks_test_step_for_new_destination(client.force_login(user)with unittest.mock.patch(- "products.batch_exports.backend.api.batch_export.get_destination_test"+ "products.batch_exports.backend.presentation.views.batch_export.get_destination_test") as mock_get_destination_test:test_step = DatabricksEstablishConnectionTestStep()test_step.result = DestinationTestStepResult(status=Status.PASSED, message=None)diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.pyindex 74afa6a67538..5f43262412c1 100644--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py@@ -27,13 +27,6 @@ from posthog.models.scoping import team_scopefrom posthog.temporal.tests.utils.events import generate_test_eventsfrom products.access_control.backend.models.property_access_control import PropertyAccessControl-from products.batch_exports.backend.api.file_download import (- COUNT_ROWS_TIMEOUT_MESSAGE,- DEFAULT_MAX_SIZE_MB,- _calculate_expiration_for_file_download,- _generate_s3_pre_signed_url,- _get_file_download_for_run,-)from products.batch_exports.backend.models.batch_export import (BatchExportDestination,BatchExportFileDownload,@@ -41,6 +34,13 @@ from products.batch_exports.backend.models.batch_export import (BatchExportRun,BatchExportSource,)+from products.batch_exports.backend.presentation.views.file_download import (+ COUNT_ROWS_TIMEOUT_MESSAGE,+ DEFAULT_MAX_SIZE_MB,+ _calculate_expiration_for_file_download,+ _generate_s3_pre_signed_url,+ _get_file_download_for_run,+)from products.batch_exports.backend.temporal import ACTIVITIES, WORKFLOWSfrom products.batch_exports.backend.tests.temporal.destinations.s3.utils import has_valid_credentials@@ -165,7 +165,7 @@ def override_file_download_settings(aws_role_arn, s3_bucket):def mock_start_file_download_export():"""Mock starting the Temporal workflow so create tests don't reach Temporal."""with unittest.mock.patch(- "products.batch_exports.backend.api.file_download.start_file_download_batch_export"+ "products.batch_exports.backend.presentation.views.file_download.start_file_download_batch_export") as mock_start:yield mock_start@@ -606,7 +606,9 @@ async def test_file_download_cancel_mocked(mocked_handle = unittest.mock.AsyncMock()mocked_client.get_workflow_handle.return_value = mocked_handle- with unittest.mock.patch("products.batch_exports.backend.api.file_download.sync_connect") as mocked_connect:+ with unittest.mock.patch(+ "products.batch_exports.backend.presentation.views.file_download.sync_connect"+ ) as mocked_connect:mocked_connect.return_value = mocked_clientstatus_response = await async_client.post(f"/api/projects/{team.pk}/file_download_batch_exports/{run.id}/cancel",@@ -625,7 +627,7 @@ async def test_file_download_cancel_mocked(class TestFileDownloadHogQL:"""File download batch exports created from a user-defined HogQL query."""- HOGQL_FLAG_PATCH_TARGET = "products.batch_exports.backend.api.utils.posthoganalytics.feature_enabled"+ HOGQL_FLAG_PATCH_TARGET = "products.batch_exports.backend.presentation.views.utils.posthoganalytics.feature_enabled"@pytest.fixturedef enable_hogql_flag(self):@@ -1138,7 +1140,9 @@ class TestFileDownloadHogQL:):await async_client.aforce_login(user)- with unittest.mock.patch("products.batch_exports.backend.api.file_download.execute_hogql_query") as execute:+ with unittest.mock.patch(+ "products.batch_exports.backend.presentation.views.file_download.execute_hogql_query"+ ) as execute:response = await async_client.post(f"/api/projects/{team.pk}/file_download_batch_exports/count_rows",body,@@ -1170,7 +1174,7 @@ class TestFileDownloadHogQL:await async_client.aforce_login(user)with unittest.mock.patch(- "products.batch_exports.backend.api.file_download.execute_hogql_query",+ "products.batch_exports.backend.presentation.views.file_download.execute_hogql_query",side_effect=ClickHouseQueryTimeOut(),):response = await async_client.post(diff --git a/products/batch_exports/backend/tests/test_file_download_interval.py b/products/batch_exports/backend/tests/test_file_download_interval.pyindex c43477761f6e..4ee99abd6dd8 100644--- a/products/batch_exports/backend/tests/test_file_download_interval.py+++ b/products/batch_exports/backend/tests/test_file_download_interval.py@@ -3,7 +3,7 @@ import datetime as dtimport pytestimport time_machine-from products.batch_exports.backend.api.file_download import (+from products.batch_exports.backend.presentation.views.file_download import (FileDownloadBatchExportOnDemandSerializer,FileDownloadCountRowsRequestSerializer,)diff --git a/products/batch_exports/package.json b/products/batch_exports/package.jsonindex fd9acc3b81ad..7e76eded3cc4 100644--- a/products/batch_exports/package.json+++ b/products/batch_exports/package.json@@ -1,6 +1,6 @@{"name": "@posthog/products-batch-exports","scripts": {- "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests backend/api/test -v --tb=short"+ "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests -v --tb=short"}}diff --git a/pyproject.toml b/pyproject.tomlindex 8ec085e77486..42e0903d5ddb 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -743,6 +743,25 @@ ignore_imports = ["products.access_control.backend.presentation.access_control_settings -> products.access_control.backend.models.access_control","products.access_control.backend.presentation.access_control_settings -> products.access_control.backend.models.role","products.access_control.backend.presentation.role -> products.access_control.backend.models.role",+ # TODO: batch_exports presentation wave — the moved viewsets, serializers and destination+ # test helpers still reach in-product internals directly. Thin each one to parse -> facade+ # -> serialize and delete each entry. backend:contract-check stays off until this list is+ # empty. Only delete entries here: a new import from these views goes through the facade.+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.filters",+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.hogql_source",+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.models.batch_export",+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.service",+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.temporal.destinations.constants",+ "products.batch_exports.backend.presentation.views.batch_export -> products.batch_exports.backend.temporal.sql.events",+ "products.batch_exports.backend.presentation.views.destination_tests.bigquery -> products.batch_exports.backend.temporal.destinations.bigquery_batch_export",+ "products.batch_exports.backend.presentation.views.destination_tests.databricks -> products.batch_exports.backend.temporal.destinations.databricks_batch_export",+ "products.batch_exports.backend.presentation.views.destination_tests.s3 -> products.batch_exports.backend.temporal.destinations.s3_batch_export",+ "products.batch_exports.backend.presentation.views.destination_tests.snowflake -> products.batch_exports.backend.temporal.destinations.snowflake_batch_export",+ "products.batch_exports.backend.presentation.views.file_download -> products.batch_exports.backend.hogql_source",+ "products.batch_exports.backend.presentation.views.file_download -> products.batch_exports.backend.models.batch_export",+ "products.batch_exports.backend.presentation.views.file_download -> products.batch_exports.backend.service",+ "products.batch_exports.backend.presentation.views.file_download -> products.batch_exports.backend.temporal.record_batch_model",+ "products.batch_exports.backend.presentation.views.file_download -> products.batch_exports.backend.temporal.sql.common",]# routes.py is the one module core reads to assemble a product's API router, so it is the@@ -766,8 +785,6 @@ ignore_imports = ["products.ai_observability.backend.routes -> products.ai_observability.backend.api","products.annotations.backend.routes -> products.annotations.backend.api.annotation","products.approvals.backend.routes -> products.approvals.backend.api",- "products.batch_exports.backend.routes -> products.batch_exports.backend.api.batch_export",- "products.batch_exports.backend.routes -> products.batch_exports.backend.api.file_download","products.business_knowledge.backend.routes -> products.business_knowledge.backend.api","products.cdp.backend.routes -> products.cdp.backend.api.hog_function","products.cdp.backend.routes -> products.cdp.backend.api.hog_function_template",