mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-23 17:33:44 +08:00
ci: crosscheck tinygrad ref during tests (#1106)
* Add tinygrad ref testing * BaseDir and give a fake ref id to test * one more before the real thing * Add the correct ref * test * Update test_tinygrad_ref.py * Update tinygrad_ref * Update test_tinygrad_ref.py * Update tinygrad_ref * This SHOULD FAIL * Revert "This SHOULD FAIL" This reverts commit 58862f8a730c34c1407386f729067b0c564e910b. * bit of red * Move ref to models so compiled branches can read it * step one * step 2 * Update build-all-tinygrad-models.yaml * Update build-all-tinygrad-models.yaml * Update build-all-tinygrad-models.yaml * Update build-all-tinygrad-models.yaml * Update build-all-tinygrad-models.yaml * Update build-all-tinygrad-models.yaml * Update tinygrad_ref.py * Update build-all-tinygrad-models.yaml * bump to fail test * Revert "bump to fail test" This reverts commit 4f58991f32036ac55564470f1fdaa50492578f15. * pytest should take care of it * lint --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bcc416c7eb
commit
2f60026c22
@@ -16,7 +16,24 @@ jobs:
|
||||
recompiled_dir: ${{ steps.create-recompiled-dir.outputs.recompiled_dir }}
|
||||
json_file: ${{ steps.get-json.outputs.json_file }}
|
||||
model_matrix: ${{ steps.set-matrix.outputs.model_matrix }}
|
||||
tinygrad_ref: ${{ steps.get-tinygrad-ref.outputs.tinygrad_ref }}
|
||||
steps:
|
||||
- name: Checkout sunnypilot repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: sunnypilot/sunnypilot
|
||||
path: sunnypilot
|
||||
submodules: recursive
|
||||
|
||||
- name: Get tinygrad_repo ref
|
||||
id: get-tinygrad-ref
|
||||
run: |
|
||||
cd sunnypilot
|
||||
export PYTHONPATH=$(pwd)
|
||||
ref=$(python3 sunnypilot/models/tinygrad_ref.py)
|
||||
echo "tinygrad_ref=$ref" >> $GITHUB_OUTPUT
|
||||
echo "tinygrad_ref is $ref"
|
||||
|
||||
- name: Checkout docs repo (sunnypilot-docs, gh-pages)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -269,6 +286,7 @@ jobs:
|
||||
ARGS=""
|
||||
[ -n "${{ inputs.set_min_version }}" ] && ARGS="$ARGS --set-min-version \"${{ inputs.set_min_version }}\""
|
||||
ARGS="$ARGS --sort-by-date"
|
||||
ARGS="$ARGS --tinygrad-ref \"${{ needs.setup.outputs.tinygrad_ref }}\""
|
||||
eval python3 docs/json_parser.py \
|
||||
--json-path "$JSON_FILE" \
|
||||
--recompiled-dir "gitlab_docs/models/$RECOMPILED_DIR" \
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import requests
|
||||
|
||||
from sunnypilot.models.tinygrad_ref import get_tinygrad_ref
|
||||
from sunnypilot.models.fetcher import ModelFetcher
|
||||
|
||||
|
||||
def fetch_tinygrad_ref():
|
||||
response = requests.get(ModelFetcher.MODEL_URL, timeout=10)
|
||||
response.raise_for_status()
|
||||
json_data = response.json()
|
||||
return json_data.get("tinygrad_ref")
|
||||
|
||||
|
||||
def test_tinygrad_ref():
|
||||
current_ref = get_tinygrad_ref()
|
||||
remote_ref = fetch_tinygrad_ref()
|
||||
assert remote_ref == current_ref, (
|
||||
f"""tinygrad_repo ref does not match remote tinygrad_ref of current compiled driving models json.
|
||||
Current: {current_ref}
|
||||
Remote: {remote_ref}
|
||||
Please run build-all workflow to update models."""
|
||||
)
|
||||
print("tinygrad_repo ref matches current compiled driving models json ref.")
|
||||
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
|
||||
|
||||
def get_tinygrad_ref():
|
||||
repo_path = os.path.join(BASEDIR, "tinygrad_repo")
|
||||
git_path = os.path.join(repo_path, ".git")
|
||||
try:
|
||||
if os.path.isdir(git_path):
|
||||
git_dir = git_path
|
||||
else:
|
||||
with open(git_path) as f:
|
||||
line = f.read().strip()
|
||||
git_dir = os.path.join(repo_path, line[8:])
|
||||
with open(os.path.join(git_dir, "HEAD")) as f:
|
||||
ref = f.read().strip()
|
||||
if ref.startswith("ref:"):
|
||||
with open(os.path.join(git_dir, ref.split(" ", 1)[1])) as f:
|
||||
return f.read().strip()
|
||||
return ref
|
||||
except Exception as e:
|
||||
print(f"Error getting tinygrad_repo ref: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
current_ref = get_tinygrad_ref()
|
||||
if current_ref:
|
||||
print(current_ref)
|
||||
else:
|
||||
print("")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user