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.

fix(growth): label the newest enrichment fetches first (#108508)

Matt Brooker22ca436b0e14
diff --git a/products/growth/backend/enrichment/labels.py b/products/growth/backend/enrichment/labels.py
index 255896ff73f0..c700842f4eb0 100644
--- a/products/growth/backend/enrichment/labels.py
+++ b/products/growth/backend/enrichment/labels.py
@@ -9,10 +9,12 @@ import re
import json
import math
from collections.abc import Callable
+from datetime import timedelta
from typing import Any, Literal, TypeIs, cast
from urllib.parse import urlsplit, urlunsplit
from django.db.models import QuerySet
+from django.utils import timezone
from openai import APIConnectionError, InternalServerError, OpenAI, RateLimitError
from openai.types.chat import ChatCompletion, ChatCompletionMessageParam
@@ -723,10 +725,15 @@ def latest_fetches_qs() -> QuerySet[OrganizationEnrichmentFetch]:
)
-def recent_latest_fetches_qs() -> QuerySet[OrganizationEnrichmentFetch]:
+def recent_latest_fetches_qs(lookback_days: int | None = None) -> QuerySet[OrganizationEnrichmentFetch]:
"""latest_fetches_qs, but orderable and sliceable: DISTINCT ON pins the inner
ORDER BY to organization_id, so callers wanting `-fetched_at` need this subquery wrapper."""
- return OrganizationEnrichmentFetch.objects.filter(id__in=latest_fetches_qs().values("id")).order_by("-fetched_at")
+ fetches = OrganizationEnrichmentFetch.objects.filter(id__in=latest_fetches_qs().values("id")).order_by(
+ "-fetched_at"
+ )
+ if lookback_days is None:
+ return fetches
+ return fetches.filter(fetched_at__gte=timezone.now() - timedelta(days=lookback_days))
def get_active_config(label: str) -> EnrichmentPromptConfig | None:
diff --git a/products/growth/backend/management/commands/enrichment_label_batch.py b/products/growth/backend/management/commands/enrichment_label_batch.py
index 536d74b1a93f..c4d788956e5c 100644
--- a/products/growth/backend/management/commands/enrichment_label_batch.py
+++ b/products/growth/backend/management/commands/enrichment_label_batch.py
@@ -12,11 +12,13 @@ import threading
from collections import deque
from collections.abc import Iterator
from concurrent.futures import Future, ThreadPoolExecutor
+from datetime import datetime
from typing import Any
from uuid import UUID
from django.core.management.base import BaseCommand, CommandError, CommandParser
from django.db import close_old_connections, connection, transaction
+from django.db.models import Q
import structlog
@@ -35,7 +37,7 @@ from products.growth.backend.enrichment.labels import (
classify_payload,
get_active_config,
is_unknown_output,
- latest_fetches_qs,
+ recent_latest_fetches_qs,
signup_domain_for_organization,
validate_input_fields,
validate_output_fields,
@@ -99,6 +101,15 @@ class Command(BaseCommand):
default=None,
help="Classify at most this many new orgs and repair at most this many stored scores",
)
+ parser.add_argument(
+ "--lookback-days",
+ type=int,
+ default=None,
+ help=(
+ "Consider only orgs whose latest fetch is at most this many days old, for new labels and "
+ "score repairs alike. Omit to walk the full archive."
+ ),
+ )
parser.add_argument("--workers", type=int, default=5, help="Bounded concurrency for LLM calls")
parser.add_argument(
"--max-failures",
@@ -125,6 +136,7 @@ class Command(BaseCommand):
def handle(self, *args: Any, **options: Any) -> None:
label: str = options["label"]
limit: int | None = options["limit"]
+ lookback_days: int | None = options["lookback_days"]
workers: int = options["workers"]
max_failures: int = options["max_failures"]
min_success_rate: float = options["min_success_rate"]
@@ -133,6 +145,8 @@ class Command(BaseCommand):
raise CommandError("--workers must be at least 1")
if limit is not None and limit < 1:
raise CommandError("--limit must be at least 1")
+ if lookback_days is not None and lookback_days < 1:
+ raise CommandError("--lookback-days must be at least 1")
if max_failures < 1:
raise CommandError("--max-failures must be at least 1")
@@ -158,7 +172,7 @@ class Command(BaseCommand):
raise CommandError(f"Another enrichment_label_batch run already holds the lock for label {label!r}")
try:
- self._run(label, config, limit, workers, max_failures, min_success_rate)
+ self._run(label, config, limit, lookback_days, workers, max_failures, min_success_rate)
finally:
with connection.cursor() as cursor:
cursor.execute("SELECT pg_advisory_unlock(%s)", [lock_key])
@@ -168,6 +182,7 @@ class Command(BaseCommand):
label: str,
config: EnrichmentPromptConfig,
limit: int | None,
+ lookback_days: int | None,
workers: int,
max_failures: int,
min_success_rate: float,
@@ -343,8 +358,8 @@ class Command(BaseCommand):
if is_unknown_output(output):
counts["unknown"] += 1
- def _id_batches() -> Iterator[list[tuple[UUID, UUID]]]:
- """Keyset-paginate latest_fetches_qs() over the full archive by organization_id in
+ def _id_batches() -> Iterator[list[tuple[UUID, datetime]]]:
+ """Keyset-paginate recent_latest_fetches_qs() newest first by (fetched_at, id) in
bounded chunks, so a multi-hour run never holds more than one page of full (payload +
joined Organization) rows in memory. .iterator() alone doesn't guarantee that:
DISABLE_SERVER_SIDE_CURSORS is true under pgbouncer, which silently degrades
@@ -354,26 +369,30 @@ class Command(BaseCommand):
--limit is deliberately NOT enforced here: it bounds attempted (non-skipped) orgs, not
enumerated ones, so it's applied in _attempt_targets instead. Capping the page query
itself would make a resumed run re-enumerate the same already-processed prefix and
- attempt 0 forever whenever the first --limit orgs by organization_id already have a
- result."""
- last_org_id: UUID | None = None
+ attempt 0 forever whenever the newest --limit candidates already have a result."""
+ candidates = (
+ recent_latest_fetches_qs(lookback_days).order_by("-fetched_at", "-id").values_list("id", "fetched_at")
+ )
+ id_qs = candidates
while True:
- id_qs = latest_fetches_qs().values_list("id", "organization_id")
- if last_org_id is not None:
- id_qs = id_qs.filter(organization_id__gt=last_org_id)
page = list(id_qs[:_ID_BATCH_SIZE])
if not page:
return
yield page
- last_org_id = page[-1][1]
+ last_id, last_fetched_at = page[-1]
+ id_qs = candidates.filter(
+ Q(fetched_at__lt=last_fetched_at) | Q(fetched_at=last_fetched_at, id__lt=last_id)
+ )
def _attempt_targets() -> Iterator[OrganizationEnrichmentFetch]:
for page in _id_batches():
if circuit_open.is_set():
return
- fetches = OrganizationEnrichmentFetch.objects.filter(
- id__in=[fetch_id for fetch_id, _ in page]
- ).select_related("organization")
+ fetches = (
+ OrganizationEnrichmentFetch.objects.filter(id__in=[fetch_id for fetch_id, _ in page])
+ .select_related("organization")
+ .order_by("-fetched_at", "-id")
+ )
for fetch in fetches:
if circuit_open.is_set():
return
diff --git a/products/growth/backend/models.py b/products/growth/backend/models.py
index 07c336a1e0e2..3c4fedac7f3c 100644
--- a/products/growth/backend/models.py
+++ b/products/growth/backend/models.py
@@ -143,8 +143,9 @@ class OrganizationEnrichmentFetch(UUIDModel):
class Meta:
indexes = [
models.Index(fields=["organization", "fetched_at"], name="growth_enrich_fetch_org_time"),
- # Matches latest_fetches_qs' DISTINCT ON ordering (enrichment/labels.py) so the batch
- # runner's driving query is an index scan instead of a sort of the whole archive.
+ # Matches latest_fetches_qs' DISTINCT ON ordering (enrichment/labels.py) so the latest-fetch
+ # subquery in the batch runner's driving query is an index scan instead of a sort of the
+ # whole archive.
models.Index(fields=["organization", "-fetched_at", "-id"], name="growth_enrich_fetch_org_ts_id"),
]
diff --git a/products/growth/backend/tests/test_ai_pilled.py b/products/growth/backend/tests/test_ai_pilled.py
index 966aede69285..db48c434de37 100644
--- a/products/growth/backend/tests/test_ai_pilled.py
+++ b/products/growth/backend/tests/test_ai_pilled.py
@@ -511,7 +511,10 @@ class TestEnrichmentScoreApplication(BaseTest):
@parameterized.expand([("delivered", False), ("failed", True)])
def test_score_repairs_do_not_consume_the_classification_limit(self, _name, fail_repair):
- repair, new_label = sorted([self.label, self._additional_label()], key=lambda label: label.organization_id)
+ repair, new_label = self.label, self._additional_label()
+ OrganizationEnrichmentFetch.objects.filter(pk=new_label.fetch_id).update(
+ fetched_at=self.fetch.fetched_at - dt.timedelta(days=1)
+ )
new_fetch = new_label.fetch
output = new_label.output
new_label.delete()
@@ -568,6 +571,9 @@ class TestEnrichmentScoreApplication(BaseTest):
@parameterized.expand([("consent",), ("signup_user_left",), ("domain",)])
def test_ineligible_stored_result_does_not_exhaust_repair_limit(self, reason):
eligible = self._additional_label()
+ OrganizationEnrichmentFetch.objects.filter(pk=eligible.fetch_id).update(
+ fetched_at=self.fetch.fetched_at - dt.timedelta(days=1)
+ )
if reason == "consent":
Organization.objects.filter(pk=self.organization.pk).update(is_ai_data_processing_approved=False)
elif reason == "signup_user_left":
diff --git a/products/growth/backend/tests/test_enrichment_label_commands.py b/products/growth/backend/tests/test_enrichment_label_commands.py
index f9a14321a087..f47de0932228 100644
--- a/products/growth/backend/tests/test_enrichment_label_commands.py
+++ b/products/growth/backend/tests/test_enrichment_label_commands.py
@@ -1,5 +1,6 @@
import json
import threading
+from datetime import datetime, timedelta
from io import StringIO
from typing import Any
@@ -9,6 +10,7 @@ from unittest.mock import MagicMock, patch
from django.core.management import call_command
from django.core.management.base import CommandError
from django.db import connection
+from django.utils import timezone
from parameterized import parameterized
@@ -72,13 +74,19 @@ class _BatchCommandTestCase(BaseTest):
return EnrichmentPromptConfig.objects.create(**params)
def _fetch(
- self, organization: Organization | None = None, payload: dict[str, Any] | list[Any] | None = None
+ self,
+ organization: Organization | None = None,
+ payload: dict[str, Any] | list[Any] | None = None,
+ fetched_at: datetime | None = None,
) -> OrganizationEnrichmentFetch:
- return OrganizationEnrichmentFetch.objects.create(
+ fetch = OrganizationEnrichmentFetch.objects.create(
organization=organization or self.organization,
provider="harmonic",
payload=payload if payload is not None else {"name": "Acme"},
)
+ if fetched_at is not None:
+ OrganizationEnrichmentFetch.objects.filter(id=fetch.id).update(fetched_at=fetched_at)
+ return fetch
class TestGatewayRetryBudget(_BatchCommandTestCase):
@@ -198,7 +206,7 @@ class TestKeysetPagination(_BatchCommandTestCase):
output={"is_ai": True},
)
fresh_org = Organization.objects.create(name="fresh")
- self._fetch(organization=fresh_org)
+ self._fetch(organization=fresh_org, fetched_at=timezone.now() - timedelta(days=1))
client = _mock_llm_client()
out = StringIO()
@@ -212,6 +220,32 @@ class TestKeysetPagination(_BatchCommandTestCase):
assert "attempted 1" in out.getvalue()
assert EnrichmentLabelResult.objects.filter(organization=fresh_org).exists()
+ @parameterized.expand(
+ [
+ ("newest_first_under_a_limit", [5, 4, 3, 2, 1], {"limit": 3}, [2, 3, 4]),
+ ("ties_across_a_page_boundary", [1, 1, 1, 1, 1], {}, [0, 1, 2, 3, 4]),
+ ("older_than_the_lookback", [1, 15], {"lookback_days": 14}, [0]),
+ ]
+ )
+ def test_walks_candidates_newest_first_within_the_lookback(
+ self, _name: str, ages_in_days: list[int], options: dict[str, int], labeled_indexes: list[int]
+ ) -> None:
+ self._config()
+ now = timezone.now()
+ orgs = [Organization.objects.create(name=f"org-{i}") for i in range(len(ages_in_days))]
+ for org, age_days in zip(orgs, ages_in_days):
+ self._fetch(organization=org, fetched_at=now - timedelta(days=age_days))
+ client = _mock_llm_client()
+
+ with (
+ patch(f"{_BATCH_COMMAND_MODULE}.get_llm_client", return_value=client),
+ patch(f"{_BATCH_COMMAND_MODULE}._ID_BATCH_SIZE", 2),
+ ):
+ call_command("enrichment_label_batch", label="test_label", workers=1, **options)
+
+ labeled = set(EnrichmentLabelResult.objects.values_list("organization_id", flat=True))
+ assert labeled == {orgs[i].id for i in labeled_indexes}
+
class TestAdvisoryLock(_BatchCommandTestCase):
def test_a_concurrent_run_is_rejected_before_any_spend(self):
@@ -707,7 +741,7 @@ class TestAiProcessingConsent(_BatchCommandTestCase):
first_org = self.organization
second_org = Organization.objects.create(name="Second")
self._fetch(organization=first_org)
- self._fetch(organization=second_org)
+ self._fetch(organization=second_org, fetched_at=timezone.now() - timedelta(days=1))
client = _mock_llm_client()
def _revoke_after_first(*args: Any, **kwargs: Any):
@@ -751,18 +785,17 @@ class TestAiProcessingConsent(_BatchCommandTestCase):
# Regression: --limit used to count a declined org as "attempted" the moment it was
# enumerated, before the consent check (which only ran later, at spend-time inside
# _process). A declined org costs nothing, so with --limit 1 and a declined org sorting
- # first by organization_id, the run used to exhaust its whole budget on that one free
+ # first, the run used to exhaust its whole budget on that one free
# skip and never even enumerate the approved org behind it - zero verdicts, yet the
# command still exited 0 (tried == 0 skips the "every attempted org failed" check). A
# consent-filtered candidate count downstream can't tell that apart from a real failure.
self._config()
- org_x = Organization.objects.create(name="x")
- org_y = Organization.objects.create(name="y")
- declined_org, approved_org = sorted([org_x, org_y], key=lambda org: str(org.id))
+ declined_org = Organization.objects.create(name="declined")
+ approved_org = Organization.objects.create(name="approved")
declined_org.is_ai_data_processing_approved = False
declined_org.save(update_fields=["is_ai_data_processing_approved"])
self._fetch(organization=declined_org)
- self._fetch(organization=approved_org)
+ self._fetch(organization=approved_org, fetched_at=timezone.now() - timedelta(days=1))
client = _mock_llm_client()
out = StringIO()
diff --git a/products/growth/dags/ai_enrichment.py b/products/growth/dags/ai_enrichment.py
index ec5dfe1db46f..d10a491cd98c 100644
--- a/products/growth/dags/ai_enrichment.py
+++ b/products/growth/dags/ai_enrichment.py
@@ -53,7 +53,7 @@ import pydantic
from posthog.dags.common import JobOwners, skip_if_already_running
from posthog.exceptions_capture import capture_exception
-from products.growth.backend.enrichment.labels import get_active_config, latest_fetches_qs
+from products.growth.backend.enrichment.labels import get_active_config, recent_latest_fetches_qs
from products.growth.backend.models import EnrichmentLabelResult, EnrichmentPromptConfig, OrganizationEnrichment
# Roughly a day of signups plus headroom. This is the run's spend cap: see the PR description
@@ -78,6 +78,14 @@ class AiEnrichmentConfig(dagster.Config):
gt=0,
description="Max orgs attempted per label per run — passed straight through to enrichment_label_batch --limit.",
)
+ lookback_days: int = pydantic.Field(
+ default=14,
+ gt=0,
+ description=(
+ "Only orgs whose latest fetch is at most this many days old get a new label or a score repair; "
+ "passed through to --lookback-days."
+ ),
+ )
workers: int = pydantic.Field(
default=5,
gt=0,
@@ -98,27 +106,22 @@ class LabelRunResult:
error: str | None
-def count_pending_candidates(label: str, prompt_version: str) -> int:
+def count_pending_candidates(label: str, prompt_version: str, lookback_days: int | None) -> int:
"""How many orgs the batch command would actually attempt for this label right now.
- Mirrors enrichment_label_batch's own targeting (latest fetch per org, minus one already
- holding a verdict under this exact label + prompt version) rather than importing its
- private `_attempt_targets` — that generator is a closure over the command's run-scoped
- counters and circuit breaker, not a reusable query. Also filters to AI-processing-approved
- orgs: the command enumerates a consent-declined org as "attempted" too, but never spends on
- it (see `ai_processing_approved` in enrichment/labels.py), so counting it here would make a
- day of nothing-but-declined-orgs look like a silent failure downstream.
+ Mirrors enrichment_label_batch's own targeting (latest fetch per org within the lookback,
+ minus one already holding a verdict under this exact label + prompt version) rather than
+ importing its private `_attempt_targets`, because that generator is a closure over the
+ command's run-scoped counters and circuit breaker, not a reusable query. Also filters to
+ AI-processing-approved orgs: the command skips a consent-declined org and never counts it as
+ attempted (see `ai_processing_approved` in enrichment/labels.py), so counting it here would
+ make a day of nothing-but-declined-orgs look like a silent failure downstream.
"""
- latest_fetch_ids = latest_fetches_qs().values_list("id", flat=True)
+ candidates = recent_latest_fetches_qs(lookback_days)
already_labeled = EnrichmentLabelResult.objects.filter(
- label_name=label, prompt_version=prompt_version, fetch_id__in=latest_fetch_ids
+ label_name=label, prompt_version=prompt_version, fetch_id__in=candidates.values_list("id", flat=True)
).values_list("fetch_id", flat=True)
- return (
- latest_fetches_qs()
- .exclude(id__in=already_labeled)
- .filter(organization__is_ai_data_processing_approved=True)
- .count()
- )
+ return candidates.exclude(id__in=already_labeled).filter(organization__is_ai_data_processing_approved=True).count()
def count_projected_scores(label: str, prompt_version: str, started_at: datetime) -> int:
@@ -158,13 +161,15 @@ def count_projected_scores(label: str, prompt_version: str, started_at: datetime
)
-def _run_one_label(context: dagster.OpExecutionContext, *, label: str, limit: int, workers: int) -> LabelRunResult:
+def _run_one_label(
+ context: dagster.OpExecutionContext, *, label: str, limit: int, lookback_days: int, workers: int
+) -> LabelRunResult:
"""Resolves the label's active version itself, right here — not from a snapshot taken once
for every label at op start. See the module docstring for why that distinction matters."""
config = get_active_config(label)
prompt_version = config.version if config is not None else None
- candidates = count_pending_candidates(label, prompt_version) if prompt_version is not None else 0
+ candidates = count_pending_candidates(label, prompt_version, lookback_days) if prompt_version is not None else 0
before = (
EnrichmentLabelResult.objects.filter(label_name=label, prompt_version=prompt_version).count()
if prompt_version is not None
@@ -177,7 +182,12 @@ def _run_one_label(context: dagster.OpExecutionContext, *, label: str, limit: in
# expected_version=None when we couldn't resolve one either — the command's own
# "No active EnrichmentPromptConfig" error already covers that case.
call_command(
- "enrichment_label_batch", label=label, limit=limit, workers=workers, expected_version=prompt_version
+ "enrichment_label_batch",
+ label=label,
+ limit=limit,
+ lookback_days=lookback_days,
+ workers=workers,
+ expected_version=prompt_version,
)
except Exception as e:
error = str(e)
@@ -215,7 +225,10 @@ def classify_pending_organizations_op(
return []
results = [
- _run_one_label(context, label=label, limit=config.limit, workers=config.workers) for label in active_label_names
+ _run_one_label(
+ context, label=label, limit=config.limit, lookback_days=config.lookback_days, workers=config.workers
+ )
+ for label in active_label_names
]
context.add_output_metadata(
diff --git a/products/growth/dags/tests/test_ai_enrichment.py b/products/growth/dags/tests/test_ai_enrichment.py
index f306d9af3536..6c87891d4e40 100644
--- a/products/growth/dags/tests/test_ai_enrichment.py
+++ b/products/growth/dags/tests/test_ai_enrichment.py
@@ -1,4 +1,4 @@
-from datetime import timedelta
+from datetime import datetime, timedelta
from typing import Any
import pytest
@@ -46,10 +46,15 @@ class _EnrichmentDagTestCase(BaseTest):
params.update(overrides)
return EnrichmentPromptConfig.objects.create(**params)
- def _fetch(self, organization: Organization | None = None) -> OrganizationEnrichmentFetch:
- return OrganizationEnrichmentFetch.objects.create(
+ def _fetch(
+ self, organization: Organization | None = None, fetched_at: datetime | None = None
+ ) -> OrganizationEnrichmentFetch:
+ fetch = OrganizationEnrichmentFetch.objects.create(
organization=organization or self.organization, provider="harmonic", payload={"name": "Acme"}
)
+ if fetched_at is not None:
+ OrganizationEnrichmentFetch.objects.filter(id=fetch.id).update(fetched_at=fetched_at)
+ return fetch
class TestCountPendingCandidates(_EnrichmentDagTestCase):
@@ -57,10 +62,22 @@ class TestCountPendingCandidates(_EnrichmentDagTestCase):
self._config()
self._fetch()
- assert count_pending_candidates("test_label", "v1") == 1
+ assert count_pending_candidates("test_label", "v1", lookback_days=None) == 1
- def test_excludes_a_fetch_already_labeled_under_this_exact_version(self):
+ def test_excludes_an_org_whose_latest_fetch_is_older_than_the_lookback(self):
+ self._config()
+ self._fetch()
+ self._fetch(
+ organization=Organization.objects.create(name="stale"), fetched_at=timezone.now() - timedelta(days=15)
+ )
+
+ assert count_pending_candidates("test_label", "v1", lookback_days=14) == 1
+
+ @parameterized.expand([("single_fetch", False), ("re_enriched_org", True)])
+ def test_excludes_a_fetch_already_labeled_under_this_exact_version(self, _name: str, re_enriched: bool) -> None:
config = self._config()
+ if re_enriched:
+ self._fetch(fetched_at=timezone.now() - timedelta(days=1))
fetch = self._fetch()
EnrichmentLabelResult.objects.create(
organization=self.organization,
@@ -71,7 +88,7 @@ class TestCountPendingCandidates(_EnrichmentDagTestCase):
model="gpt-5-mini",
)
- assert count_pending_candidates("test_label", config.version) == 0
+ assert count_pending_candidates("test_label", config.version, lookback_days=None) == 0
def test_a_verdict_under_a_retired_version_does_not_hide_the_candidate(self):
# A rename or re-version leaves prior verdicts stamped with the old version - see
@@ -87,29 +104,34 @@ class TestCountPendingCandidates(_EnrichmentDagTestCase):
model="gpt-5-mini",
)
- assert count_pending_candidates("test_label", "v1") == 1
+ assert count_pending_candidates("test_label", "v1", lookback_days=None) == 1
def test_excludes_an_org_that_declined_ai_processing(self):
self._config()
self._fetch()
Organization.objects.filter(id=self.organization.id).update(is_ai_data_processing_approved=False)
- assert count_pending_candidates("test_label", "v1") == 0
+ assert count_pending_candidates("test_label", "v1", lookback_days=None) == 0
def test_zero_when_there_is_nothing_pending(self):
- assert count_pending_candidates("test_label", "v1") == 0
+ assert count_pending_candidates("test_label", "v1", lookback_days=None) == 0
class TestAiEnrichmentJob(_EnrichmentDagTestCase):
def test_calls_batch_command_once_per_active_label_with_the_configured_limit_and_workers(self):
config_a = self._config(name="label_a")
config_b = self._config(name="label_b")
- # No pending fetches for either label, so the absence-of-output check can't fire and
- # mask what this test is actually asserting.
+ self._fetch(fetched_at=timezone.now() - timedelta(days=8))
+ # The only pending fetch is older than the 7-day lookback, so the absence-of-output check
+ # fires only if the pending count ignores the configured window.
with patch(f"{_MODULE}.call_command") as mock_call_command:
result = ai_enrichment_job.execute_in_process(
- run_config={"ops": {"classify_pending_organizations_op": {"config": {"limit": 42, "workers": 3}}}}
+ run_config={
+ "ops": {
+ "classify_pending_organizations_op": {"config": {"limit": 42, "workers": 3, "lookback_days": 7}}
+ }
+ }
)
assert result.success
@@ -119,6 +141,7 @@ class TestAiEnrichmentJob(_EnrichmentDagTestCase):
assert call.args == ("enrichment_label_batch",)
assert call.kwargs["limit"] == 42
assert call.kwargs["workers"] == 3
+ assert call.kwargs["lookback_days"] == 7
# expected_version is each label's own currently-resolved version, passed through so the
# command can abort if it disagrees - see test_a_version_bump_between_labels below.
assert calls_by_label["label_a"].kwargs["expected_version"] == config_a.version