chore: [workflow] 提交工作区代码
This commit is contained in:
1 parent
2ff588a65d
commit
01f3d7aaf7
131 files changed
+24306
-1320
No files matched your search
+50
-16
@@ -11,16 +11,16 @@ from gyxx_flow.catalog import CatalogError, WorkflowCatalog
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_catalog_maps_29_project_scheduled_tasks() -> None:
|
||||
def test_catalog_maps_39_project_scheduled_tasks() -> None:
|
||||
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
|
||||
scheduled = catalog.scheduled_workflows()
|
||||
|
||||
assert len(scheduled) == 29
|
||||
assert len({item.source_task_name for item in scheduled}) == 29
|
||||
assert len(scheduled) == 39
|
||||
assert len({item.source_task_name for item in scheduled}) == 39
|
||||
assert Counter(item.module for item in scheduled) == {
|
||||
"content_marketing": 9,
|
||||
"product_commerce": 12,
|
||||
"shop_intelligence": 4,
|
||||
"content_marketing": 10,
|
||||
"product_commerce": 13,
|
||||
"shop_intelligence": 12,
|
||||
"supply_chain": 4,
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ def test_catalog_schedules_douyin_price_appeal() -> None:
|
||||
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
|
||||
schedule = catalog.schedule_for("shop.douyin_price_appeal")
|
||||
|
||||
assert len(catalog.workflows) == 29
|
||||
assert len(catalog.workflows) == 39
|
||||
assert catalog.manual_workflows() == ()
|
||||
assert "shop.douyin_price_appeal" in {
|
||||
schedule.workflow_id for schedule in catalog.schedules
|
||||
}
|
||||
assert catalog.unavailable_workflows() == ()
|
||||
assert schedule.kind == "daily"
|
||||
assert schedule.effective_times == ("08:00", "16:00", "22:00")
|
||||
assert schedule.effective_times == tuple(f"{hour:02d}:00" for hour in range(24))
|
||||
|
||||
|
||||
def test_tmall_video_upload_is_an_idempotent_store_selected_scheduled_workflow() -> None:
|
||||
@@ -186,13 +186,18 @@ def test_every_scheduled_workflow_has_one_valid_asia_shanghai_schedule() -> None
|
||||
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
|
||||
|
||||
assert catalog.timezone == "Asia/Shanghai"
|
||||
assert len(catalog.schedules) == 29
|
||||
assert len(catalog.schedules) == 39
|
||||
for workflow in catalog.scheduled_workflows():
|
||||
schedule = catalog.schedule_for(workflow.workflow_id)
|
||||
assert schedule.workflow_id == workflow.workflow_id
|
||||
assert schedule.kind in {"daily", "weekly", "monthly", "interval_days"}
|
||||
assert schedule.at.count(":") == 1
|
||||
assert sum(schedule.enabled for schedule in catalog.schedules) == 25
|
||||
assert sum(schedule.enabled for schedule in catalog.schedules) == 27
|
||||
customer_service = catalog.schedule_for("shop.jd_customer_service.daily")
|
||||
assert customer_service.at == "03:00"
|
||||
assert customer_service.enabled is True
|
||||
assert customer_service.kind == "monthly"
|
||||
assert customer_service.day_of_month == 21
|
||||
|
||||
|
||||
def test_scheduled_workflows_use_python_entries_and_content_tasks_are_graphs() -> None:
|
||||
@@ -221,23 +226,49 @@ def test_scheduled_workflows_use_python_entries_and_content_tasks_are_graphs() -
|
||||
)
|
||||
assert [step.step_id for step in daily.steps] == [
|
||||
"collect_collaborators",
|
||||
"refresh_self_mapping",
|
||||
"collect_self_bilibili",
|
||||
"collect_self_douyin",
|
||||
"sync",
|
||||
]
|
||||
assert daily.steps[0].depends_on == ()
|
||||
assert daily.steps[1].depends_on == ("collect_collaborators",)
|
||||
assert daily.steps[2].depends_on == ("refresh_self_mapping",)
|
||||
assert daily.steps[3].depends_on == ("collect_self_bilibili",)
|
||||
assert daily.steps[4].depends_on == ("collect_self_douyin",)
|
||||
assert "--include-self-operated" not in daily.steps[0].args
|
||||
assert daily.steps[1].args == ("--scope", "collaborators")
|
||||
assert all(step.replay_policy == "repeatable" for step in daily.steps)
|
||||
assert catalog.schedule_for(daily.workflow_id).effective_times == (
|
||||
"01:00",
|
||||
"05:00",
|
||||
)
|
||||
|
||||
self_operated = next(
|
||||
workflow
|
||||
for workflow in catalog.workflows
|
||||
if workflow.workflow_id == "content.metrics.self_operated.daily"
|
||||
)
|
||||
assert [step.step_id for step in self_operated.steps] == [
|
||||
"refresh_self_mapping",
|
||||
"collect_self_bilibili",
|
||||
"collect_self_douyin",
|
||||
"collect_self_xiaohongshu",
|
||||
"sync",
|
||||
"sync_self_video_metrics",
|
||||
]
|
||||
assert self_operated.steps[0].depends_on == ()
|
||||
assert self_operated.steps[1].depends_on == ("refresh_self_mapping",)
|
||||
assert self_operated.steps[2].depends_on == ("collect_self_bilibili",)
|
||||
assert self_operated.steps[3].depends_on == ("collect_self_douyin",)
|
||||
assert self_operated.steps[4].depends_on == ("collect_self_douyin",)
|
||||
assert self_operated.steps[4].args == ("--scope", "self-operated")
|
||||
assert self_operated.steps[5].depends_on == (
|
||||
"sync",
|
||||
"collect_self_xiaohongshu",
|
||||
)
|
||||
assert self_operated.steps[5].entry == (
|
||||
"data/tools/sync_self_video_metrics.py"
|
||||
)
|
||||
assert catalog.schedule_for(self_operated.workflow_id).effective_times == (
|
||||
"01:00",
|
||||
"05:00",
|
||||
)
|
||||
|
||||
backfill = next(
|
||||
workflow
|
||||
for workflow in catalog.workflows
|
||||
@@ -250,6 +281,7 @@ def test_scheduled_workflows_use_python_entries_and_content_tasks_are_graphs() -
|
||||
assert backfill.steps[0].entry == "run_all.py"
|
||||
assert backfill.steps[0].args == ("--daily-scope",)
|
||||
assert backfill.steps[1].entry == "data/tools/sync_metrics_to_cmt_notes.py"
|
||||
assert backfill.steps[1].args == ("--scope", "collaborators")
|
||||
assert backfill.steps[1].depends_on == ("collect_collaborators",)
|
||||
assert backfill.steps[1].run_after_failure is True
|
||||
backfill_schedule = catalog.schedule_for(backfill.workflow_id)
|
||||
@@ -341,6 +373,8 @@ def test_shop_steps_preserve_declared_replay_policy_at_module_boundary() -> None
|
||||
assert policies["shop.metrics.weekly"] == {"idempotent"}
|
||||
assert policies["shop.competitor.weekly"] == {"idempotent"}
|
||||
assert policies["shop.jd_self_operated.daily"] == {"idempotent"}
|
||||
assert policies["shop.jd_customer_service.daily"] == {"idempotent"}
|
||||
assert policies["shop.jd_after_sales_issues.daily"] == {"idempotent"}
|
||||
assert policies["shop.douyin_price_appeal"] == {"idempotent"}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user