Skip to content

Commit 738b223

Browse files
authored
Add captured actual outputs to CI artifacts (#40965)
* fix * fix * Remove `# TODO: ???` as it make me `???` * fix * fix * fix --------- Co-authored-by: ydshieh <[email protected]>
1 parent dd7ac4c commit 738b223

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

.github/workflows/model_jobs.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,35 @@ jobs:
128128
echo "machine_type=$machine_type" >> $GITHUB_ENV
129129
echo "machine_type=$machine_type" >> $GITHUB_OUTPUT
130130
131+
- name: Create report directory if it doesn't exist
132+
shell: bash
133+
run: |
134+
mkdir -p /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
135+
echo "dummy" > /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/dummy.txt
136+
ls -la /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
137+
131138
- name: Run all tests on GPU
132139
working-directory: /transformers
133-
run: python3 -m pytest -rsfE -v --make-reports=${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports tests/${{ matrix.folders }}
140+
run: |
141+
PATCH_TESTING_METHODS_TO_COLLECT_OUTPUTS=yes _PATCHED_TESTING_METHODS_OUTPUT_DIR=/transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports python3 -m pytest -rsfE -v --make-reports=${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports tests/${{ matrix.folders }}
134142
135143
- name: Failure short reports
136144
if: ${{ failure() }}
137145
continue-on-error: true
138-
run: cat /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports/failures_short.txt
146+
run: cat /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/failures_short.txt
139147

140-
- name: Run test
141-
shell: bash
148+
- name: Captured information
149+
if: ${{ failure() }}
150+
continue-on-error: true
142151
run: |
143-
mkdir -p /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports
144-
echo "hello" > /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports/hello.txt
145-
echo "${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports"
152+
cat /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/captured_info.txt
146153
147154
- name: "Test suite reports artifacts: ${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports"
148155
if: ${{ always() }}
149156
uses: actions/upload-artifact@v4
150157
with:
151158
name: ${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
152-
path: /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ matrix.folders }}_test_reports
159+
path: /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
153160

154161
collated_reports:
155162
name: Collated Reports

utils/notification_service.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,15 @@ def pop_default(l: list[Any], i: int, default: Any) -> Any:
11961196
"time_spent": [],
11971197
"failures": {},
11981198
"job_link": {},
1199+
"captured_info": {},
1200+
}
1201+
for matrix_name in job_matrix
1202+
if f"{report_name_prefix}_{matrix_name}_test_reports" in available_artifacts
1203+
}
1204+
1205+
matrix_job_results_extra = {
1206+
matrix_name: {
1207+
"captured_info": {},
11991208
}
12001209
for matrix_name in job_matrix
12011210
if f"{report_name_prefix}_{matrix_name}_test_reports" in available_artifacts
@@ -1225,7 +1234,21 @@ def pop_default(l: list[Any], i: int, default: Any) -> Any:
12251234

12261235
stacktraces = handle_stacktraces(artifact["failures_line"])
12271236

1228-
# TODO: ???
1237+
# Add the captured actual outputs for patched methods (`torch.testing.assert_close`, `assertEqual` etc.)
1238+
if "captured_info" in artifact:
1239+
step_number = None
1240+
for step in job.get("steps", []):
1241+
if step["name"] == "Captured information":
1242+
step_number = step["number"]
1243+
break
1244+
if step_number is not None:
1245+
step_link = f"{job['html_url']}#step:{step_number}:1"
1246+
matrix_job_results[matrix_name]["captured_info"][artifact_gpu] = step_link
1247+
matrix_job_results_extra[matrix_name]["captured_info"][artifact_gpu] = {
1248+
"link": step_link,
1249+
"captured_info": artifact["captured_info"],
1250+
}
1251+
12291252
for line in artifact["summary_short"].split("\n"):
12301253
if line.startswith("FAILED "):
12311254
# Avoid the extra `FAILED` entry given by `run_test_using_subprocess` causing issue when calling
@@ -1432,6 +1455,20 @@ def pop_default(l: list[Any], i: int, default: Any) -> Any:
14321455
token=os.environ.get("TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN", None),
14331456
)
14341457

1458+
if len(matrix_job_results_extra) > 0:
1459+
with open(
1460+
f"ci_results_{job_name}/{test_to_result_name[test_name]}_results_extra.json", "w", encoding="UTF-8"
1461+
) as fp:
1462+
json.dump(matrix_job_results_extra, fp, indent=4, ensure_ascii=False)
1463+
1464+
api.upload_file(
1465+
path_or_fileobj=f"ci_results_{job_name}/{test_to_result_name[test_name]}_results_extra.json",
1466+
path_in_repo=f"{report_repo_folder}/ci_results_{job_name}/{test_to_result_name[test_name]}_results_extra.json",
1467+
repo_id=report_repo_id,
1468+
repo_type="dataset",
1469+
token=os.environ.get("TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN", None),
1470+
)
1471+
14351472
# Let's create a file contain job --> job link
14361473
if len(matrix_job_results) > 0:
14371474
target_results = matrix_job_results

0 commit comments

Comments
 (0)