-
Notifications
You must be signed in to change notification settings - Fork 5k
[diffusion] CI: send diffusion nightly-test outputs to slack for correctness monitoring #13784
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9daa399
upd
yhyang201 d40b172
upd
yhyang201 8554c01
upd
yhyang201 17a296b
upd nightly test
yhyang201 9b0af25
upd ci dependency
yhyang201 da417a9
test
yhyang201 1cc2500
upd
yhyang201 7042524
upd
yhyang201 3f5d0ad
tiny fix
yhyang201 8150f3a
tiny fix
yhyang201 a245a5f
tiny fix
yhyang201 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import logging | ||
| import os | ||
| import tempfile | ||
| from urllib.parse import urlparse | ||
| from urllib.request import urlopen | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def upload_file_to_slack( | ||
| case_id: str = None, | ||
| model: str = None, | ||
| prompt: str = None, | ||
| file_path: str = None, | ||
| origin_file_path: str = None, | ||
| ) -> bool: | ||
| temp_path = None | ||
| try: | ||
| from slack_sdk import WebClient | ||
|
|
||
| run_id = os.getenv("GITHUB_RUN_ID", "local") | ||
|
|
||
| token = os.environ.get("SGLANG_DIFFUSION_SLACK_TOKEN") | ||
| if not token: | ||
| logger.info(f"Slack upload failed: no token") | ||
| return False | ||
|
|
||
| if not file_path or not os.path.exists(file_path): | ||
| logger.info(f"Slack upload failed: no file path") | ||
| return False | ||
|
|
||
| if origin_file_path and origin_file_path.startswith(("http", "https")): | ||
| suffix = os.path.splitext(urlparse(origin_file_path).path)[1] or ".tmp" | ||
| with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as tf: | ||
| with urlopen(origin_file_path) as response: | ||
| tf.write(response.read()) | ||
| temp_path = tf.name | ||
| origin_file_path = temp_path | ||
|
|
||
| uploads = [{"file": file_path, "title": "Generated Image"}] | ||
| if origin_file_path and os.path.exists(origin_file_path): | ||
| uploads.insert(0, {"file": origin_file_path, "title": "Original Image"}) | ||
|
|
||
| message = ( | ||
| f"*GitHub Run ID:* {run_id}\n" | ||
| f"*Case ID:* `{case_id}`\n" | ||
| f"*Model:* `{model}`\n" | ||
| f"*Prompt:* {prompt}" | ||
| ) | ||
|
|
||
| WebClient(token=token).files_upload_v2( | ||
| channel="C0A02NDF7UY", | ||
| file_uploads=uploads, | ||
| initial_comment=message, | ||
| ) | ||
|
|
||
| logger.info(f"File uploaded successfully: {os.path.basename(file_path)}") | ||
| return True | ||
|
|
||
| except Exception as e: | ||
| logger.info(f"Slack upload failed: {e}") | ||
| return False | ||
| finally: | ||
| if temp_path and os.path.exists(temp_path): | ||
| os.remove(temp_path) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.