-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from TaekyungHeo/jax-report
Enhance JaxToolbox report generation and update stats collection
- Loading branch information
Showing
2 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
34 changes: 34 additions & 0 deletions
34
tests/schema/test_template/jax_toolbox/test_report_generation_strategy.py
This file contains 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,34 @@ | ||
from pathlib import Path | ||
|
||
from cloudai.schema.test_template.jax_toolbox.report_generation_strategy import ( | ||
JaxToolboxReportGenerationStrategy, | ||
) | ||
|
||
|
||
class TestJaxExtractTime: | ||
"""Tests for the JaxToolboxReportGenerationStrategy class.""" | ||
|
||
def setup_method(self) -> None: | ||
"""Setup method for initializing JaxToolboxReportGenerationStrategy.""" | ||
self.js = JaxToolboxReportGenerationStrategy() | ||
|
||
def test_no_files(self, tmp_path: Path) -> None: | ||
"""Test that no times are extracted when no files are present.""" | ||
assert self.js._extract_times(str(tmp_path)) == [] | ||
|
||
def test_no_matches(self, tmp_path: Path) -> None: | ||
"""Test that no times are extracted when no matching lines are present.""" | ||
(tmp_path / "error-1.txt").write_text("fake line") | ||
assert self.js._extract_times(str(tmp_path)) == [] | ||
|
||
def test_one_match(self, tmp_path: Path) -> None: | ||
"""Test that the correct time is extracted when one matching line is present.""" | ||
err_file = tmp_path / "error-1.txt" | ||
sample_line = ( | ||
"I0508 15:25:28.482553 140737334253888 programs.py:379] " | ||
"[PAX STATUS]: train_step() took 38.727223 seconds.\n" | ||
) | ||
with err_file.open("w") as f: | ||
for _ in range(11): | ||
f.write(sample_line) | ||
assert self.js._extract_times(str(err_file.parent)) == [38.727223] |