feat: complete production workflow migration

This commit is contained in:
2026-08-06 14:29:57 +08:00
parent 7f215e79c4
commit 8df5266abb
448 changed files with 56937 additions and 14619 deletions
+73 -8
View File
@@ -14,7 +14,7 @@ from gyxx_flow.modules.shop_intelligence import (
PROJECT_ROOT = Path(__file__).resolve().parents[1]
def test_shop_module_registers_both_weekly_workflows() -> None:
def test_shop_module_registers_all_catalog_workflows() -> None:
module = ShopIntelligenceModule.from_catalog(
WorkflowCatalog.load(PROJECT_ROOT / "config")
)
@@ -28,11 +28,76 @@ def test_shop_workflows_use_project_owned_module_commands() -> None:
)
for definition in module.workflow_definitions():
step = definition.steps[0]
assert step.step_id == "module_collect"
assert isinstance(step.action, DeferredModuleCommandStep)
assert step.timeout_seconds == COLLECTION_TIMEOUT_SECONDS == 4 * 60 * 60
assert step.max_attempts == 1
assert step.resources == (SHOP_RESOURCE,) == ("module:shop_intelligence",)
assert step.production_sink is True
assert definition.steps
for step in definition.steps:
assert isinstance(step.action, DeferredModuleCommandStep)
if definition.workflow_id == "shop.jd_self_operated.daily":
expected_timeout = {"brand": 600, "product": 1_800}[step.step_id]
elif definition.workflow_id == "shop.douyin_price_appeal":
expected_timeout = 1_800
else:
expected_timeout = COLLECTION_TIMEOUT_SECONDS
assert step.timeout_seconds == expected_timeout
assert step.max_attempts == 1
assert step.resources == (f"{SHOP_RESOURCE}:{step.step_id}",)
assert step.production_sink is True
def test_shop_metrics_platforms_are_independent_graph_steps() -> None:
module = ShopIntelligenceModule.from_catalog(
WorkflowCatalog.load(PROJECT_ROOT / "config")
)
metrics = next(
item
for item in module.workflow_definitions()
if item.workflow_id == "shop.metrics.weekly"
)
assert tuple(step.step_id for step in metrics.steps) == ("jd", "dy", "tm")
assert all(not step.depends_on for step in metrics.steps)
def test_douyin_price_appeal_reuses_weekly_browser_resource() -> None:
module = ShopIntelligenceModule.from_catalog(
WorkflowCatalog.load(PROJECT_ROOT / "config")
)
definitions = {item.workflow_id: item for item in module.workflow_definitions()}
metrics_douyin = next(
step for step in definitions["shop.metrics.weekly"].steps if step.step_id == "dy"
)
appeal = definitions["shop.douyin_price_appeal"].steps[0]
assert appeal.step_id == "dy"
assert appeal.action.command_entry == (
"collectors/dy_store_competitor_store_scraping.py"
)
assert appeal.action.command_args == ("--price-appeal", "--execute")
assert appeal.resources == metrics_douyin.resources == (
f"{SHOP_RESOURCE}:dy",
)
assert appeal.replay_policy == "idempotent"
def test_jd_self_operated_preserves_source_runner_graph_contract() -> None:
module = ShopIntelligenceModule.from_catalog(
WorkflowCatalog.load(PROJECT_ROOT / "config")
)
workflow = next(
item
for item in module.workflow_definitions()
if item.workflow_id == "shop.jd_self_operated.daily"
)
brand, product = workflow.steps
assert (brand.step_id, product.step_id) == ("brand", "product")
assert brand.action.command_entry == (
"collectors/jd_self_operated_brand_daily.py"
)
assert product.action.command_entry == (
"collectors/jd_self_operated_product_daily.py"
)
assert brand.timeout_seconds == 600
assert product.timeout_seconds == 1_800
assert brand.depends_on == ()
assert product.depends_on == ("brand",)
assert product.run_after_failure is True