Skip to content

Commit

Permalink
agnos casync script improvements (#32156)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jnewb1 authored Apr 11, 2024
1 parent 70b8e27 commit ecb648a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
10 changes: 8 additions & 2 deletions release/create_casync_agnos_release.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
#!/usr/bin/env python3
import argparse
import json
import pathlib
import tempfile
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()

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:
Expand Down
19 changes: 8 additions & 11 deletions release/create_release_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"],
}


Expand All @@ -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)
]
}
Expand Down
7 changes: 6 additions & 1 deletion system/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ecb648a

Please sign in to comment.