From c92cf92e78bfdaec5246542cd54766f458df4892 Mon Sep 17 00:00:00 2001 From: Dale Roberts Date: Wed, 11 Jun 2025 12:35:55 +1000 Subject: [PATCH 1/2] Add ability to filter on branches --- memprof_plotter/plotter.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/memprof_plotter/plotter.py b/memprof_plotter/plotter.py index 873cd3b..e8bac4a 100644 --- a/memprof_plotter/plotter.py +++ b/memprof_plotter/plotter.py @@ -62,14 +62,16 @@ def download_artefact(url: str) -> bytes | None: else: print("Artefact does not contain required TSP database") return None - -def get_artefacts(nruns: int, workflow: github.Workflow.Workflow, artefact: str) -> dict[int, bytes]: +def get_artefacts(nruns: int, workflow: github.Workflow.Workflow, artefact: str, filter: list[str]) -> dict[int, bytes]: irun = 0 runs = {} for run in workflow.get_runs(status="success"): - k = run.run_number + if filter: + if run.head_branch not in filter: + continue + k = f"{run.run_number} - {run.head_branch}" for gha in run.get_artifacts(): if gha.name == artefact: artefact_data = download_artefact(gha.archive_download_url) @@ -83,7 +85,6 @@ def get_artefacts(nruns: int, workflow: github.Workflow.Workflow, artefact: str) def main(): - if gh_token == "BAD_KEY": raise KeyError("GH_TOKEN must be set in environment") @@ -110,6 +111,14 @@ def main(): parser.add_argument( "-a", "--artefact", required=False, type=str, default="run-log", help="Name of artefact containing memprof data" ) + parser.add_argument( + "-f", + "--filter", + required=False, + type=str, + default="", + help="Comma separated list of branch names to filter runs on", + ) ns = parser.parse_args(sys.argv[1:]) @@ -118,7 +127,9 @@ def main(): gh = github.Github(auth=auth) repo = gh.get_repo(ns.repo) - runs = get_artefacts(ns.nruns, repo.get_workflow(ns.workflow), ns.artefact) + filter = ns.filter.split(",") if ns.filter else [] + + runs = get_artefacts(ns.nruns, repo.get_workflow(ns.workflow), ns.artefact, filter) d_times = defaultdict(dict) d_rss = defaultdict(dict) From 023cf97d1a53fcf00e765418c114dd2e763d909c Mon Sep 17 00:00:00 2001 From: Dale Roberts Date: Wed, 11 Jun 2025 12:50:21 +1000 Subject: [PATCH 2/2] Remove get script --- get.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100755 get.sh diff --git a/get.sh b/get.sh deleted file mode 100755 index b89fc8c..0000000 --- a/get.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -export NRUNS=10 -export JSON=$( gh run list -R g-adopt/g-adopt -w test.yml -s success -L "${NRUNS}" --json databaseId,number ) -declare -a RUNIDS=( $( jq --jsonargs '.[].databaseId' <<<"${JSON}" ) ) -declare -a RUNNOS=( $( jq --jsonargs '.[].number' <<<"${JSON}") ) - -for (( i=0; i<${NRUNS}; i++ )); do - gh run download -R g-adopt/g-adopt -D "${RUNNOS[$i]}" -n run-log "${RUNIDS[$i]}" -done - -memprof_plotter "${RUNNOS[@]}"