-
Notifications
You must be signed in to change notification settings - Fork 0
Performance improvements #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -104,14 +104,16 @@ def download_s3_artifacts( | |||||||||||||||||||||||||||||||||||||||||||||||
| paths = [] | ||||||||||||||||||||||||||||||||||||||||||||||||
| for obj in objs: | ||||||||||||||||||||||||||||||||||||||||||||||||
| object_name = Path(obj.key).name | ||||||||||||||||||||||||||||||||||||||||||||||||
| # target an artifact for a specific job_id if provided, otherwise skip the download. | ||||||||||||||||||||||||||||||||||||||||||||||||
| if job_id is not None and str(job_id) not in object_name: | ||||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||||
| found_one = True | ||||||||||||||||||||||||||||||||||||||||||||||||
| p = Path(Path(obj.key).name) | ||||||||||||||||||||||||||||||||||||||||||||||||
| print(f"Downloading {p}") | ||||||||||||||||||||||||||||||||||||||||||||||||
| s3_resource = get_s3_resource() | ||||||||||||||||||||||||||||||||||||||||||||||||
| bucket_obj = s3_resource.Bucket(GHA_ARTIFACTS_BUCKET) | ||||||||||||||||||||||||||||||||||||||||||||||||
| obj_data = bucket_obj.Object(obj.key).get() | ||||||||||||||||||||||||||||||||||||||||||||||||
| with open(p, "wb") as f: | ||||||||||||||||||||||||||||||||||||||||||||||||
| f.write(obj.get()["Body"].read()) | ||||||||||||||||||||||||||||||||||||||||||||||||
| f.write(obj_data["Body"].read()) | ||||||||||||||||||||||||||||||||||||||||||||||||
| paths.append(p) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if not found_one: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -161,10 +163,8 @@ def upload_to_s3( | |||||||||||||||||||||||||||||||||||||||||||||||
| json.dump(doc, body) | ||||||||||||||||||||||||||||||||||||||||||||||||
| body.write("\n") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| get_s3_resource().Object( | ||||||||||||||||||||||||||||||||||||||||||||||||
| f"{bucket_name}", | ||||||||||||||||||||||||||||||||||||||||||||||||
| f"{key}", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ).put( | ||||||||||||||||||||||||||||||||||||||||||||||||
| s3_obj = get_s3_resource().Object(f"{bucket_name}", f"{key}") | ||||||||||||||||||||||||||||||||||||||||||||||||
| s3_obj.put( | ||||||||||||||||||||||||||||||||||||||||||||||||
| Body=gzip.compress(body.getvalue().encode()), | ||||||||||||||||||||||||||||||||||||||||||||||||
| ContentEncoding="gzip", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ContentType="application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
163
to
170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness: 🟠 [LangGraph v3] Using 📝 Committable Code Suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -186,7 +186,8 @@ def read_from_s3( | |||||||||||||||||||||||||||||||||||||||||||||||
| .get()["Body"] | ||||||||||||||||||||||||||||||||||||||||||||||||
| .read() | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| results = gzip.decompress(body).decode().split("\n") | ||||||||||||||||||||||||||||||||||||||||||||||||
| decompressed = gzip.decompress(body).decode() | ||||||||||||||||||||||||||||||||||||||||||||||||
| results = decompressed.split("\n") | ||||||||||||||||||||||||||||||||||||||||||||||||
| return [json.loads(result) for result in results if result] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
186
to
193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness: 🟠 [LangGraph v3] The variable 📝 Committable Code Suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -170,6 +170,8 @@ def summarize_test_cases(test_cases: list[dict[str, Any]]) -> list[dict[str, Any | |||||||||||||||||||||||||||||||
| manually instead of using the `test-suite` XML tag because xmlrunner does | ||||||||||||||||||||||||||||||||
| not produce reliable output for it. | ||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| test_cases = sorted(test_cases, key=lambda x: (x.get("file", ""), x.get("classname", ""))) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def get_key(test_case: dict[str, Any]) -> Any: | ||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||
|
Comment on lines
170
to
177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correctness: 🟠 [LangGraph v3] The sorting of 📝 Committable Code Suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness: 🟠 [LangGraph v3] The
s3_resourceandbucket_objare re-initialized inside the loop for each object, which is unnecessary and inefficient. Move the initialization outside the loop to improve performance.📝 Committable Code Suggestion