Skip to content

Commit 6e73ae2

Browse files
clee2000pytorchmergebot
authored andcommitted
[ci][ez] Add job_id to emit_metrics (pytorch#113099)
As in title. Also print the job id in the step since I'm struggling to find it Pull Request resolved: pytorch#113099 Approved by: https://github.com/seemethere
1 parent 3914566 commit 6e73ae2

File tree

8 files changed

+13
-0
lines changed

8 files changed

+13
-0
lines changed

.github/scripts/get_workflow_job_id.py

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def set_output(name: str, val: Any) -> None:
139139
if os.getenv("GITHUB_OUTPUT"):
140140
with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env:
141141
print(f"{name}={val}", file=env)
142+
print(f"setting {name}={val}")
142143
else:
143144
print(f"::set-output name={name}::{val}")
144145

.github/workflows/_bazel-build-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
GITHUB_RUN_ID: ${{ github.run_id }}
121121
GITHUB_RUN_NUMBER: ${{ github.run_number }}
122122
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
123+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
123124
PYTORCH_RETRY_TEST_CASES: 1
124125
PYTORCH_OVERRIDE_FLAKY_SIGNAL: 1
125126
REENABLED_ISSUES: ${{ needs.filter.outputs.reenabled-issues }}
@@ -147,6 +148,7 @@ jobs:
147148
-e GITHUB_JOB \
148149
-e GITHUB_RUN_NUMBER \
149150
-e GITHUB_RUN_ATTEMPT \
151+
-e JOB_ID \
150152
-e GIT_DEFAULT_BRANCH="$GIT_DEFAULT_BRANCH" \
151153
-e SHARD_NUMBER \
152154
-e NUM_TEST_SHARDS \

.github/workflows/_linux-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ jobs:
157157
GITHUB_RUN_ID: ${{ github.run_id }}
158158
GITHUB_RUN_NUMBER: ${{ github.run_number }}
159159
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
160+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
160161
BRANCH: ${{ steps.parse-ref.outputs.branch }}
161162
SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
162163
BASE_SHA: ${{ github.event.pull_request.base.sha || github.sha }}
@@ -204,6 +205,7 @@ jobs:
204205
-e GITHUB_RUN_ID \
205206
-e GITHUB_RUN_NUMBER \
206207
-e GITHUB_RUN_ATTEMPT \
208+
-e JOB_ID \
207209
-e BASE_SHA \
208210
-e BRANCH \
209211
-e SHA1 \

.github/workflows/_mac-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ jobs:
145145
GITHUB_RUN_ID: ${{ github.run_id }}
146146
GITHUB_RUN_NUMBER: ${{ github.run_number }}
147147
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
148+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
148149
REENABLED_ISSUES: ${{ steps.keep-going.outputs.reenabled-issues }}
149150
run: |
150151
# shellcheck disable=SC1090

.github/workflows/_rocm-test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ jobs:
121121
GITHUB_RUN_ID: ${{ github.run_id }}
122122
GITHUB_RUN_NUMBER: ${{ github.run_number }}
123123
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
124+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
124125
BRANCH: ${{ steps.parse-ref.outputs.branch }}
125126
SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
126127
PYTORCH_RETRY_TEST_CASES: 1
@@ -162,6 +163,7 @@ jobs:
162163
-e GITHUB_RUN_ID \
163164
-e GITHUB_RUN_NUMBER \
164165
-e GITHUB_RUN_ATTEMPT \
166+
-e JOB_ID \
165167
-e BRANCH \
166168
-e SHA1 \
167169
-e AWS_DEFAULT_REGION \

.github/workflows/_win-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ jobs:
161161
GITHUB_RUN_ID: ${{ github.run_id }}
162162
GITHUB_RUN_NUMBER: ${{ github.run_number }}
163163
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
164+
JOB_ID: ${{ steps.get-job-id.outputs.job-id }}
164165
SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
165166
CUDA_VERSION: ${{ inputs.cuda-version }}
166167
PYTORCH_FINAL_PACKAGE_DIR: /c/${{ github.run_id }}/build-results/

tools/stats/upload_metrics.py

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def emit_metric(
112112
EnvVarMetric("run_id", "GITHUB_RUN_ID", type_conversion_fn=int),
113113
EnvVarMetric("run_number", "GITHUB_RUN_NUMBER", type_conversion_fn=int),
114114
EnvVarMetric("run_attempt", "GITHUB_RUN_ATTEMPT", type_conversion_fn=int),
115+
EnvVarMetric("job_id", "JOB_ID", type_conversion_fn=int),
115116
]
116117

117118
# Use info about the function that invoked this one as a namespace and a way to filter metrics.

tools/test/test_upload_stats_lib.py

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
RUN_NUMBER = 123
2020
RUN_ATTEMPT = 3
2121
PR_NUMBER = 6789
22+
JOB_ID = 234
2223

2324

2425
class TestUploadStats(unittest.TestCase):
@@ -36,6 +37,7 @@ def setUp(self) -> None:
3637
"GITHUB_RUN_ID": str(RUN_ID),
3738
"GITHUB_RUN_NUMBER": str(RUN_NUMBER),
3839
"GITHUB_RUN_ATTEMPT": str(RUN_ATTEMPT),
40+
"JOB_ID": str(JOB_ID),
3941
},
4042
clear=True, # Don't read any preset env vars
4143
).start()
@@ -67,6 +69,7 @@ def test_emits_default_and_given_metrics(self, mock_resource: Any) -> None:
6769
"run_attempt": RUN_ATTEMPT,
6870
"some_number": 123,
6971
"float_number": decimal.Decimal(str(32.34)),
72+
"job_id": JOB_ID,
7073
}
7174

7275
# Preserve the metric emitted

0 commit comments

Comments
 (0)