forked from ChelseaKR/gtfs-scorecard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterialize_current_artifacts.py
More file actions
42 lines (35 loc) · 1.21 KB
/
Copy pathmaterialize_current_artifacts.py
File metadata and controls
42 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""Restore validated current dated artifacts in a bounded local corpus."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from scorecard_pipeline.activation import (
ActivationHydrationError,
materialize_local_current_artifacts,
)
def main() -> int:
parser = argparse.ArgumentParser(
description=(
"Validate index/latest parity and materialize any missing or stale current "
"dated record as a byte-identical local copy of latest.json."
)
)
parser.add_argument(
"--artifacts-root",
type=Path,
default=Path("data/artifacts"),
help="local artifact root containing index.json (default: data/artifacts)",
)
args = parser.parse_args()
try:
materialized = materialize_local_current_artifacts(
artifacts_root=args.artifacts_root.resolve()
)
except ActivationHydrationError as exc:
print(f"Current artifact materialization failed: {exc}", file=sys.stderr)
return 2
print(f"Current artifact corpus is valid ({materialized} dated records materialized).")
return 0
if __name__ == "__main__":
raise SystemExit(main())