-
Notifications
You must be signed in to change notification settings - Fork 245
Add log upload support for build target failed using teatime.py script #648
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
erman-gurses
wants to merge
1
commit into
main
from
users/erman-gurses/upload-failed-logs-using-teatime
Closed
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -21,22 +21,41 @@ def normalize_path(p: Path) -> str: | |
| return str(p).replace("\\", "/") if is_windows() else str(p) | ||
|
|
||
|
|
||
| def index_log_files(build_dir: Path, amdgpu_family: str): | ||
| log_dir = build_dir / "logs" | ||
| def get_indexer_path() -> Path: | ||
| """ | ||
| Resolve to the local third-party/indexer/indexer.py copy. | ||
| """ | ||
| indexer_path = ( | ||
| Path(__file__).resolve().parent.parent / "third-party/indexer/indexer.py" | ||
| ) | ||
| if indexer_path.is_file(): | ||
| log(f"[INFO] Using bundled indexer.py: {indexer_path}") | ||
| return indexer_path | ||
| else: | ||
| log(f"[ERROR] Bundled indexer.py not found at: {indexer_path}") | ||
| sys.exit(2) | ||
|
Comment on lines
+24
to
+36
Member
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. The else clause should never be hit. I would drop the error handling here. |
||
|
|
||
|
|
||
| def index_log_files(log_dir: Path, amdgpu_family: str): | ||
| index_file = log_dir / "index.html" | ||
|
|
||
| # TODO: Fork indexer.py locally to avoid relying on an external GitHub source at runtime. | ||
| indexer_path = build_dir / "indexer.py" | ||
| if not log_dir.is_dir(): | ||
| log(f"[WARN] Log directory '{log_dir}' not found. Skipping indexing.") | ||
| return | ||
|
|
||
| indexer_path = get_indexer_path() | ||
| log( | ||
| f"[INFO] Found '{log_dir}' directory. Indexing '*.log' files using indexer: {indexer_path}" | ||
| ) | ||
|
|
||
| if log_dir.is_dir(): | ||
| log(f"[INFO] Found '{log_dir}' directory. Indexing '*.log' files...") | ||
| try: | ||
| subprocess.run( | ||
| ["python", str(indexer_path), "-f", "*.log", normalize_path(log_dir)], | ||
| [sys.executable, str(indexer_path), "-f", "*.log", normalize_path(log_dir)], | ||
| check=True, | ||
| ) | ||
| else: | ||
| log(f"[WARN] Log directory '{log_dir}' not found. Skipping indexing.") | ||
| return | ||
| except subprocess.CalledProcessError as e: | ||
| log(f"[ERROR] Failed to run indexer.py: {e}") | ||
| sys.exit(2) | ||
|
|
||
| if index_file.exists(): | ||
| log( | ||
|
|
@@ -46,19 +65,23 @@ def index_log_files(build_dir: Path, amdgpu_family: str): | |
| updated = content.replace( | ||
| 'a href=".."', f'a href="../../index-{amdgpu_family}.html"' | ||
| ) | ||
| index_file.write_text(updated) | ||
|
|
||
| # Ensure full write and flush to disk | ||
| with open(index_file, "w", encoding="utf-8") as f: | ||
| f.write(updated) | ||
| f.flush() | ||
| os.fsync(f.fileno()) | ||
|
|
||
| log("[INFO] Log index links updated.") | ||
| else: | ||
| log(f"[WARN] '{index_file}' not found. Skipping link rewrite.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description="Create HTML index for log files.") | ||
| parser.add_argument( | ||
| "--build-dir", | ||
| "--log-dir", | ||
| type=Path, | ||
| default=Path(os.getenv("BUILD_DIR", "build")), | ||
| help="Build directory containing logs (default: 'build' or $BUILD_DIR)", | ||
| default=Path(os.getenv("LOG_DIR", "build/logs")), | ||
| help="Directory containing log files (default: 'build/logs' or $LOG_DIR)", | ||
| ) | ||
| parser.add_argument( | ||
| "--amdgpu-family", | ||
|
|
@@ -72,4 +95,4 @@ def index_log_files(build_dir: Path, amdgpu_family: str): | |
| log("[ERROR] --amdgpu-family not provided and AMDGPU_FAMILIES env var not set") | ||
| sys.exit(1) | ||
|
|
||
| index_log_files(args.build_dir, args.amdgpu_family) | ||
| index_log_files(args.log_dir, args.amdgpu_family) | ||
Oops, something went wrong.
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.
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.
@geomin12 we're getting a lot of these
if: always()andif: ${{ !cancelled() }}conditions in these workflows. Let's see if we can restructure the flow a bit through migrating to more scripts such that the flow is easier to understand.Here in particular, if fetching sources fails, we'd still configure AWS credentials and try to upload logs, but we wouldn't try to build. In that case I would prefer for the workflow to fail fast and not continue to try cleanup steps that will fail.