From ecb648a68ab86e053faff450f5bf0d2bfc221333 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 11 Apr 2024 09:46:27 -0700 Subject: [PATCH] agnos casync script improvements (#32156) * build agnos * include path * cleanup * rm this * test it * all agnos partitions are AB * fix that * correct * build agnos first * better temp dir * revert the order * try it on pc * test it * upload and fix * build * pass in environemnt variable * not in jenkins --- release/create_casync_agnos_release.py | 10 ++++++++-- release/create_release_manifest.py | 19 ++++++++----------- system/version.py | 7 ++++++- 3 files changed, 22 insertions(+), 14 deletions(-) mode change 100644 => 100755 release/create_casync_agnos_release.py diff --git a/release/create_casync_agnos_release.py b/release/create_casync_agnos_release.py old mode 100644 new mode 100755 index 7f46f10129a48a..60934b8c18810a --- a/release/create_casync_agnos_release.py +++ b/release/create_casync_agnos_release.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import argparse import json import pathlib @@ -5,13 +6,15 @@ from openpilot.common.basedir import BASEDIR from openpilot.system.hardware.tici.agnos import StreamingDecompressor, unsparsify, noop, AGNOS_MANIFEST_FILE from openpilot.system.updated.casync.common import create_casync_from_file +from openpilot.system.version import get_agnos_version if __name__ == "__main__": parser = argparse.ArgumentParser(description="creates a casync release") parser.add_argument("output_dir", type=str, help="output directory for the channel") - parser.add_argument("version", type=str, help="version of agnos this is") + parser.add_argument("working_dir", type=str, help="working directory") + parser.add_argument("--version", type=str, help="version of agnos this is", default=get_agnos_version()) parser.add_argument("--manifest", type=str, help="json manifest to create agnos release from", \ default=str(pathlib.Path(BASEDIR) / AGNOS_MANIFEST_FILE)) args = parser.parse_args() @@ -19,9 +22,12 @@ output_dir = pathlib.Path(args.output_dir) output_dir.mkdir(parents=True, exist_ok=True) + working_dir = pathlib.Path(args.working_dir) + working_dir.mkdir(parents=True, exist_ok=True) + manifest_file = pathlib.Path(args.manifest) - with tempfile.NamedTemporaryFile() as entry_file: + with tempfile.NamedTemporaryFile(dir=str(working_dir)) as entry_file: entry_path = pathlib.Path(entry_file.name) with open(manifest_file) as f: diff --git a/release/create_release_manifest.py b/release/create_release_manifest.py index 8e39f2b31c7c5a..065cf03e9b2c2c 100755 --- a/release/create_release_manifest.py +++ b/release/create_release_manifest.py @@ -4,17 +4,16 @@ import json import pathlib -from openpilot.common.run import run_cmd -from openpilot.system.hardware.tici.agnos import AGNOS_MANIFEST_FILE -from openpilot.system.version import get_build_metadata +from openpilot.system.hardware.tici.agnos import AGNOS_MANIFEST_FILE, get_partition_path +from openpilot.system.version import get_build_metadata, get_agnos_version BASE_URL = "https://commadist.blob.core.windows.net" CHANNEL_DATA = pathlib.Path(__file__).parent / "channel_data" / "agnos" -OPENPILOT_RELEASES = f"{BASE_URL}/openpilot-releases" -AGNOS_RELEASES = f"{BASE_URL}/agnos-releases" +OPENPILOT_RELEASES = f"{BASE_URL}/openpilot-releases/openpilot" +AGNOS_RELEASES = f"{BASE_URL}/openpilot-releases/agnos" def create_partition_manifest(agnos_version, partition): @@ -23,10 +22,11 @@ def create_partition_manifest(agnos_version, partition): "casync": { "caibx": f"{AGNOS_RELEASES}/agnos-{agnos_version}-{partition['name']}.caibx" }, - "name": partition["name"], + "path": get_partition_path(0, partition), + "ab": True, "size": partition["size"], "full_check": partition["full_check"], - "hash_raw": partition["hash_raw"] + "hash_raw": partition["hash_raw"], } @@ -49,15 +49,12 @@ def create_openpilot_manifest(build_metadata): with open(pathlib.Path(args.target_dir) / AGNOS_MANIFEST_FILE) as f: agnos_manifest = json.load(f) - agnos_version = run_cmd(["bash", "-c", r"unset AGNOS_VERSION && source launch_env.sh && \ - echo -n $AGNOS_VERSION"], args.target_dir).strip() - build_metadata = get_build_metadata(args.target_dir) ret = { "build_metadata": dataclasses.asdict(build_metadata), "manifest": [ - *[create_partition_manifest(agnos_version, entry) for entry in agnos_manifest], + *[create_partition_manifest(get_agnos_version(args.target_dir), entry) for entry in agnos_manifest], create_openpilot_manifest(build_metadata) ] } diff --git a/system/version.py b/system/version.py index 3aa35455e5b498..6c3609c45a99fb 100755 --- a/system/version.py +++ b/system/version.py @@ -10,7 +10,7 @@ from openpilot.common.swaglog import cloudlog from openpilot.common.utils import cache from openpilot.common.git import get_commit, get_origin, get_branch, get_short_branch, get_commit_date - +from openpilot.common.run import run_cmd RELEASE_BRANCHES = ['release3-staging', 'release3', 'nightly'] TESTED_BRANCHES = RELEASE_BRANCHES + ['devel', 'devel-staging'] @@ -157,6 +157,11 @@ def get_build_metadata(path: str = BASEDIR) -> BuildMetadata: raise Exception("invalid build metadata") +def get_agnos_version(directory: str = BASEDIR) -> str: + return run_cmd(["bash", "-c", r"unset AGNOS_VERSION && source launch_env.sh && \ + echo -n $AGNOS_VERSION"], cwd=directory).strip() + + if __name__ == "__main__": from openpilot.common.params import Params