feat: complete production workflow migration
This commit is contained in:
@@ -7,20 +7,19 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
RUNTIME_ROOT = (
|
||||
MODULE_ROOT = (
|
||||
PROJECT_ROOT
|
||||
/ "src"
|
||||
/ "gyxx_flow"
|
||||
/ "modules"
|
||||
/ "product_commerce"
|
||||
/ "runtime"
|
||||
)
|
||||
|
||||
|
||||
def _load_runtime_paths(monkeypatch: pytest.MonkeyPatch, data_root: Path):
|
||||
monkeypatch.setenv("GYXX_DATA_ROOT", str(data_root))
|
||||
monkeypatch.setenv("GYXX_MODULE_ROOT", str(RUNTIME_ROOT))
|
||||
module_path = RUNTIME_ROOT / "runtime_paths.py"
|
||||
monkeypatch.setenv("GYXX_MODULE_ROOT", str(MODULE_ROOT))
|
||||
module_path = MODULE_ROOT / "runtime_paths.py"
|
||||
name = "_gyxx_product_runtime_paths_boundaries"
|
||||
spec = importlib.util.spec_from_file_location(name, module_path)
|
||||
assert spec and spec.loader
|
||||
@@ -60,7 +59,7 @@ def test_artifact_relative_path_is_relative_to_data_home(
|
||||
"data/raw/product_commerce/jd/record.json"
|
||||
)
|
||||
with pytest.raises(ValueError, match="outside GYXX_DATA_ROOT"):
|
||||
paths.artifact_relative_path(RUNTIME_ROOT / "record.json")
|
||||
paths.artifact_relative_path(MODULE_ROOT / "record.json")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -80,7 +79,7 @@ def test_artifact_relative_path_is_relative_to_data_home(
|
||||
def test_runtime_writers_do_not_fall_back_to_cwd_or_source_tree(
|
||||
relative: str, forbidden: str
|
||||
) -> None:
|
||||
text = (RUNTIME_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
text = (MODULE_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
assert forbidden not in text
|
||||
|
||||
|
||||
@@ -97,12 +96,12 @@ def test_runtime_writers_do_not_fall_back_to_cwd_or_source_tree(
|
||||
def test_runtime_artifact_references_do_not_assume_source_tree_parent(
|
||||
relative: str,
|
||||
) -> None:
|
||||
text = (RUNTIME_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
text = (MODULE_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
assert ".relative_to(PROJECT_ROOT)" not in text
|
||||
|
||||
|
||||
def test_checkpoints_and_operational_json_use_state_and_log_roots() -> None:
|
||||
retry_text = (RUNTIME_ROOT / "collect_retry_utils.py").read_text(
|
||||
retry_text = (MODULE_ROOT / "collect_retry_utils.py").read_text(
|
||||
encoding="utf-8-sig"
|
||||
)
|
||||
assert "LOG_ROOT / \"failures\"" in retry_text
|
||||
@@ -112,14 +111,14 @@ def test_checkpoints_and_operational_json_use_state_and_log_roots() -> None:
|
||||
"collect_jd_market_rank.py",
|
||||
"collect_sycm_market_rank.py",
|
||||
):
|
||||
text = (RUNTIME_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
text = (MODULE_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
assert "STATE_ROOT" in text
|
||||
assert "CHECKPOINT_PATH = STATE_ROOT" in text
|
||||
|
||||
decline = (RUNTIME_ROOT / "check_nine_day_decline.py").read_text(
|
||||
decline = (MODULE_ROOT / "check_nine_day_decline.py").read_text(
|
||||
encoding="utf-8-sig"
|
||||
)
|
||||
insert = (RUNTIME_ROOT / "insert_bitable_records.py").read_text(
|
||||
insert = (MODULE_ROOT / "insert_bitable_records.py").read_text(
|
||||
encoding="utf-8-sig"
|
||||
)
|
||||
assert "LOG_PATH = LOG_ROOT" in decline
|
||||
@@ -144,5 +143,5 @@ def test_checkpoints_and_operational_json_use_state_and_log_roots() -> None:
|
||||
],
|
||||
)
|
||||
def test_cli_output_overrides_use_the_data_home_guard(relative: str) -> None:
|
||||
text = (RUNTIME_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
text = (MODULE_ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
assert "managed_data_path" in text
|
||||
|
||||
Reference in New Issue
Block a user