Spaces:
Running
Running
File size: 1,938 Bytes
a798829 | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | """Sube los artefactos de EJES a Azure (report_artifacts root) para que el Space los consuma.
Recorre data/analysis/next_goal/artifacts/ejes/<slug>/<season>/* del repo Racing y sube cada
archivo a ``{azure_report_artifacts_root}/ejes/...``. Chicos (~11MB total).
Uso: python scripts/upload_ejes_artifacts.py [--source ../data/analysis/next_goal/artifacts/ejes] [--overwrite]
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from racing_reports.config import DEFAULT_SETTINGS
from racing_reports.datastore import DataStore, _azure_credential # noqa: F401
from azure.storage.filedatalake import DataLakeServiceClient
DEFAULT_SOURCE = Path(__file__).resolve().parents[2] / "data" / "analysis" / "next_goal" / "artifacts" / "ejes"
def main() -> None:
ap = argparse.ArgumentParser()
ap.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
ap.add_argument("--overwrite", action="store_true")
args = ap.parse_args()
src: Path = args.source
if not src.is_dir():
raise SystemExit(f"No existe {src}")
fs = DataStore()._filesystem_client()
root = DEFAULT_SETTINGS.azure_report_artifacts_root.strip("/")
files = [p for p in src.rglob("*") if p.is_file() and not p.name.startswith("_")]
print(f"{len(files)} archivos → {root}/ejes/")
subidos = saltados = 0
for p in files:
rel = p.relative_to(src).as_posix()
remote = f"{root}/ejes/{rel}"
fc = fs.get_file_client(remote)
if not args.overwrite:
try:
fc.get_file_properties()
saltados += 1
continue
except Exception:
pass
fc.upload_data(p.read_bytes(), overwrite=True)
subidos += 1
print(f"subidos: {subidos} | ya estaban: {saltados}")
if __name__ == "__main__":
main()
|