Skip to content

Commit 3d87268

Browse files
committed
Just link to the gitlab job artifacts directory
1 parent c2aee42 commit 3d87268

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

benchmarks/lowq2_reconstruction/PRfunctions.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def find_line_number_of_change(original_content, old_value):
154154
# GitHub PR Comment Functions
155155
# =============================================================================
156156

157-
def create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml_file, line_number, suggested_line, head_sha, github_token, before_images=None, after_images=None):
157+
def create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml_file, line_number, suggested_line, head_sha, github_token, artifacts_url=''):
158158
"""Create a PR comment with proposed changes"""
159159
print(f"Creating PR comment with calibration update for #{pr_number}...")
160160

@@ -196,20 +196,12 @@ def create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml
196196
197197
Please update the calibration URL in `{xml_file}` at line {line_number}."""
198198

199-
# Add before images section if provided
200-
if before_images:
201-
comment_body += "\n\n---\n\n### 📊 Before Calibration Update\n\n"
202-
for img_url in before_images:
203-
comment_body += f"![Before Image]({img_url})\n\n"
204-
205-
# Add after images section if provided
206-
if after_images:
207-
comment_body += "\n\n---\n\n### 📈 After Calibration Update\n\n"
208-
for img_url in after_images:
209-
comment_body += f"![After Image]({img_url})\n\n"
199+
# Add artifacts link if provided
200+
if artifacts_url:
201+
comment_body += f"\n\n---\n\n### 📊 Review Results\n\nPlease review the artifacts here: {artifacts_url}"
210202

203+
# Create or update comment via GitHub REST API (no gh CLI)
211204
if existing_comment_id:
212-
# Update existing comment
213205
print(f"Updating existing comment {existing_comment_id}...")
214206
update_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/comments/{existing_comment_id}"
215207
update_data = {'body': comment_body}
@@ -221,7 +213,6 @@ def create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml
221213
print(f"❌ Failed to update existing comment: {response.status_code}\n{response.text}")
222214
return None
223215
else:
224-
# Create new regular PR comment
225216
print("Creating new PR comment...")
226217
comment_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/{pr_number}/comments"
227218
comment_data = {'body': comment_body}

benchmarks/lowq2_reconstruction/config.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,9 @@ upload_onnx:lowq2_reconstruction:
103103
- echo "Updating PR with lowq2 reconstruction results"
104104
- echo "ONNX file will be available at $ONNX_UPLOAD_URL"
105105
- |
106-
# Build GitLab artifact URLs for images from THIS job; links will work once the job finishes
107-
BEFORE_IMG_PATH="results/lowq2_reconstruction/test_local/test_energy_theta_phi_resolution_local.png"
108-
AFTER_IMG_PATH="results/lowq2_reconstruction/retrained_local/retrained_energy_theta_phi_resolution_local.png"
109-
BEFORE_IMG_URL="${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/${BEFORE_IMG_PATH}"
110-
AFTER_IMG_URL="${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/${AFTER_IMG_PATH}"
111-
echo "Before image URL: $BEFORE_IMG_URL"
112-
echo "After image URL: $AFTER_IMG_URL"
106+
# Build artifact folder URL for review
107+
ARTIFACTS_URL="${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/browse/results/lowq2_reconstruction/"
108+
echo "Artifacts URL: $ARTIFACTS_URL"
113109
- |
114110
python benchmarks/lowq2_reconstruction/makePRSuggestion.py \
115111
--pr 213 \
@@ -118,6 +114,5 @@ upload_onnx:lowq2_reconstruction:
118114
--calibrationFile calibrations/onnx/Low-Q2_Steering_Reconstruction.onnx \
119115
--xml benchmarks/lowq2_reconstruction/calibrations.xml \
120116
--repository eic/detector_benchmarks \
121-
--beforeImages "$BEFORE_IMG_URL" \
122-
--afterImages "$AFTER_IMG_URL"
117+
--artifactsURL "$ARTIFACTS_URL"
123118
- echo "Updating GitHub status for lowq2 reconstruction"

benchmarks/lowq2_reconstruction/makePRSuggestion.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
parser.add_argument('--calibrationFile', type=str, default='calibrations/onnx/Low-Q2_Steering_Reconstruction.onnx', help='Path to the local calibration file')
1515
parser.add_argument('--xml', type=str, default='compact/calibrations.xml', help='Path to the XML configuration file')
1616
parser.add_argument('--repository', type=str, default='eic/epic', help='GitHub repository (owner/name)')
17-
parser.add_argument('--beforeImages', type=str, nargs='*', default=[], help='List of before image URLs or paths')
18-
parser.add_argument('--afterImages', type=str, nargs='*', default=[], help='List of after image URLs or paths')
17+
parser.add_argument('--artifactsURL', type=str, default='', help='URL to job artifacts for review')
1918

2019

2120
args = parser.parse_args()
@@ -26,8 +25,7 @@
2625
calibration_file = args.calibrationFile
2726
xml_file = args.xml
2827
repository = args.repository
29-
before_images = args.beforeImages
30-
after_images = args.afterImages
28+
artifacts_url = args.artifactsURL
3129

3230
# =============================================================================
3331

@@ -65,7 +63,7 @@
6563
print(f" Suggested change: {suggested_line.strip()}")
6664

6765
# Create the PR comment with proposed changes
68-
response = create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml_file, line_number, suggested_line, pr_info['head']['sha'], github_token, before_images, after_images)
66+
response = create_pr_suggestion(repo_owner, repo_name, pr_number, calibration_file, xml_file, line_number, suggested_line, pr_info['head']['sha'], github_token, artifacts_url)
6967

7068
if response:
7169
print("🎉 PR comment created successfully!")

0 commit comments

Comments
 (0)