Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/ci/model_compression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ def test_model_compression():
compression_ratio = original_size / compressed_size
logger.info("Compression ratio: {compression_ratio:.2f}x")

assert compressed_size < original_size, "Model should be smaller after compression"
assert compression_ratio > 1.0, "Compression ratio should be greater than 1"
if compressed_size >= original_size:
raise AssertionError("Model should be smaller after compression")
if compression_ratio <= 1.0:
raise AssertionError("Compression ratio should be greater than 1")

with tempfile.NamedTemporaryFile(suffix=".pt", delete=True) as temp_file:
torch.save(quantized_model.state_dict(), temp_file.name)
Expand Down
30 changes: 20 additions & 10 deletions scripts/ci/model_monitoring_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ def test_model_performance_monitoring():
logger.info("Recall: {metrics['recall']:.4f}")
logger.info("F1 Score: {metrics['f1_score']:.4f}")

assert 0 <= metrics['accuracy'] <= 1, "Accuracy should be between 0 and 1"
assert 0 <= metrics['precision'] <= 1, "Precision should be between 0 and 1"
assert 0 <= metrics['recall'] <= 1, "Recall should be between 0 and 1"
assert 0 <= metrics['f1_score'] <= 1, "F1 score should be between 0 and 1"
if not 0 <= metrics['accuracy'] <= 1:
raise AssertionError("Accuracy should be between 0 and 1")
if not 0 <= metrics['precision'] <= 1:
raise AssertionError("Precision should be between 0 and 1")
if not 0 <= metrics['recall'] <= 1:
raise AssertionError("Recall should be between 0 and 1")
if not 0 <= metrics['f1_score'] <= 1:
raise AssertionError("F1 score should be between 0 and 1")

logger.info("✅ Model performance monitoring test passed")
return True
Expand Down Expand Up @@ -162,8 +166,10 @@ def test_model_drift_detection():
logger.info("Accuracy drift: {accuracy_drift:.4f}")
logger.info("F1 score drift: {f1_drift:.4f}")

assert accuracy_drift >= 0, "Drift should be non-negative"
assert f1_drift >= 0, "Drift should be non-negative"
if accuracy_drift < 0:
raise AssertionError("Drift should be non-negative")
if f1_drift < 0:
raise AssertionError("Drift should be non-negative")

logger.info("✅ Model drift detection test passed")
return True
Expand Down Expand Up @@ -196,10 +202,14 @@ def test_monitoring_logging():

logger.info("Monitoring log entry: {log_entry}")

assert 'timestamp' in log_entry, "Log entry should have timestamp"
assert 'model_version' in log_entry, "Log entry should have model version"
assert 'metrics' in log_entry, "Log entry should have metrics"
assert 'status' in log_entry, "Log entry should have status"
if 'timestamp' not in log_entry:
raise AssertionError("Log entry should have timestamp")
if 'model_version' not in log_entry:
raise AssertionError("Log entry should have model version")
if 'metrics' not in log_entry:
raise AssertionError("Log entry should have metrics")
if 'status' not in log_entry:
raise AssertionError("Log entry should have status")

logger.info("✅ Monitoring logging test passed")
return True
Expand Down
12 changes: 8 additions & 4 deletions scripts/ci/t5_summarization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ def test_t5_model_loading():
logger.info("✅ T5 model initialized successfully")

# Test basic model properties
assert hasattr(model, "model"), "Model should have 'model' attribute"
assert hasattr(model, "tokenizer"), "Model should have 'tokenizer' attribute"
assert hasattr(model, "device"), "Model should have 'device' attribute"
if not hasattr(model, "model"):
raise AssertionError("Model should have 'model' attribute")
if not hasattr(model, "tokenizer"):
raise AssertionError("Model should have 'tokenizer' attribute")
if not hasattr(model, "device"):
raise AssertionError("Model should have 'device' attribute")

logger.info("✅ Model attributes validation passed")

Expand Down Expand Up @@ -83,7 +86,8 @@ def test_t5_summarization():

# Validate summary
assert isinstance(summary, str), "Summary should be a string"

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assert statement should also be converted to an explicit if-check with AssertionError for consistency with the PR's refactoring goal.

Suggested change
assert isinstance(summary, str), "Summary should be a string"
if not isinstance(summary, str):
raise AssertionError("Summary should be a string")

Copilot uses AI. Check for mistakes.
assert len(summary) > 0, "Summary should not be empty"
if len(summary) <= 0:
raise AssertionError("Summary should not be empty")
assert len(summary) < len(test_text), "Summary should be shorter than input"

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assert statement should also be converted to an explicit if-check with AssertionError for consistency with the PR's refactoring goal.

Suggested change
assert len(summary) < len(test_text), "Summary should be shorter than input"
if len(summary) >= len(test_text):
raise AssertionError("Summary should be shorter than input")

Copilot uses AI. Check for mistakes.

logger.info("✅ Summary validation passed")
Expand Down