From 3655f13666ba9f38966de26c12f559cc4761ab4c Mon Sep 17 00:00:00 2001 From: Gabe Joseph Date: Wed, 7 Sep 2022 03:05:09 -0600 Subject: [PATCH] Fix test report after queuing job added (#7012) --- continuous_integration/scripts/test_report.py | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/continuous_integration/scripts/test_report.py b/continuous_integration/scripts/test_report.py index f8afeae2530..6f37d8b630d 100644 --- a/continuous_integration/scripts/test_report.py +++ b/continuous_integration/scripts/test_report.py @@ -136,23 +136,31 @@ def get_jobs(run, session): cache[url] = jobs df_jobs = pandas.DataFrame.from_records(jobs) + # Interpolate the `$TEST_ID` variable from the job name. + # Somehow the job ID is not part of the workflow schema and we have no other way to later join + # this to the JXML results. + name_components = ( df_jobs.name.str.extract(r"test \((.+)\)", expand=False) .dropna() .str.split(", ", expand=True) - .set_axis(["OS", "python_version", "queuing", "partition"], axis="columns") - .assign( - # We later need to join on this. Somehow the job ID is not part of the workflow schema and we have no other way to join - suite_name=lambda df: df["OS"] - + "-" - + df["python_version"] - + "-" - + df["queuing"] - + "-" - + df["partition"].str.replace(" ", "") - ) ) - return pandas.concat([df_jobs, name_components], axis="columns") + if len(name_components.columns) == 4: + name_components.columns = ["OS", "python_version", "queuing", "partition"] + elif len(name_components.columns) == 3: + # Migration: handle older jobs without the `queuing` configuration. + # This branch can be removed after 2022-12-07. + name_components.columns = ["OS", "python_version", "partition"] + else: + raise ValueError(f"Job names must have 3 or 4 components:\n{name_components!r}") + + # See `Set $TEST_ID` step in `tests.yaml` + name_components["partition"] = name_components.partition.str.replace(" ", "") + + df_jobs["suite_name"] = name_components.iloc[:, 0].str.cat( + name_components.iloc[:, 1:], sep="-" + ) + return df_jobs def get_workflow_run_listing( @@ -206,7 +214,12 @@ def suite_from_name(name: str) -> str: can have matrix partitions, pytest marks, etc. Basically, just lop off the front of the name to get the suite. """ - return "-".join(name.split("-")[:4]) + parts = name.split("-") + if len(parts) == 4: # [OS, 'latest', py_version, $PARTITION_LABEL] + # Migration: handle older jobs without the `queuing` configuration. + # This branch can be removed after 2022-12-07. + parts.insert(3, "no_queue") + return "-".join(parts[:4]) def download_and_parse_artifact( @@ -354,7 +367,7 @@ def download_and_parse_artifacts( html_url = jobs_df[jobs_df["suite_name"] == a["name"]].html_url.unique() assert ( len(html_url) == 1 - ), f"Artifact suit name {a['name']} did not match any jobs dataframe {jobs_df['suite_name'].unique()}" + ), f"Artifact suite name {a['name']} did not match any jobs dataframe:\n{jobs_df['suite_name'].unique()}" html_url = html_url[0] assert html_url is not None df2 = df.assign(