Skip to content

test: add integ tests for show_metrics and model reuse (reuse_resourc… - #6158

Merged
mujtaba1747 merged 1 commit into
aws:master-nova-follow-upsfrom
amazeAmazing:integ-tests-metrics-notifications-reuse
Aug 5, 2026
Merged

test: add integ tests for show_metrics and model reuse (reuse_resourc…#6158
mujtaba1747 merged 1 commit into
aws:master-nova-follow-upsfrom
amazeAmazing:integ-tests-metrics-notifications-reuse

Conversation

@amazeAmazing

Copy link
Copy Markdown
Contributor

…es=True)

  • Add show_metrics() assertions to existing Nova SFT tests (serverless + serverful)
  • Add show_metrics() via MLflow to OSS Llama SFT test
  • Add show_metrics() to MTRL trainer integration test
  • Add reuse round-trip tests to test_model_customization_deployment.py (OSS, us-west-2)
  • Add reuse round-trip tests to test_nova_model_customization_deployment.py (Nova, us-east-1)
  • Add build(reuse_resources=True) tests to both deployment test files

Issue #, if available:

Description of changes:

Adds integration test coverage for:

show_metrics()

  • Nova (CloudWatch path): asserts DataFrame returned with global_step, metric filter, and step range filter — added to test_sft_trainer_integration.py (serverless) and test_sft_trainer_serverful_smtj.py (serverful)
  • OSS (MLflow path): asserts show_metrics() executes without error after training completes — added to test_sft_trainer_integration.py
  • MTRL (MLflow path): asserts show_metrics() on completed MTRL job — added to test_mtrl_trainer_integration.py

reuse_resources=True

  • SageMaker endpoint reuse: after deploying, a new ModelBuilder with reuse_resources=True returns the same endpoint ARN — added to test_nova_model_customization_deployment.py and test_model_customization_deployment.py
  • Model build reuse: build(reuse_resources=True) doesn't create a duplicate Model resource — validated inline with the deploy test
  • Bedrock reuse: deploy(reuse_resources=True) finds existing tagged custom model — added to test_nova_model_customization_deployment.py

Cleanup:

  • Moved nested imports to top-level in both deployment test files
  • Removed duplicate import time statements
  • Added model cleanup after build reuse tests

Tested in: a different account (us-east-1) via equivalent tests for OSS and Nova models.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@amazeAmazing
amazeAmazing marked this pull request as ready for review August 5, 2026 19:44
endpoint2 = builder2.deploy(reuse_resources=True)

assert endpoint2 is not None
assert endpoint2.endpoint_arn == endpoint.endpoint_arn, (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice

role=config["role"],
accept_eula=True,
)
trainer._latest_job = job

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we also call stream_logs() here. Not sure how we can validation stream_logs() output. But at least calling it in the test will ensure no exception was thrown.

assert training_job.output_model_package_arn is not None

# Verify show_metrics() works via MLflow path for OSS models
result = sft_trainer.show_metrics()

@mujtaba1747 mujtaba1747 Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same, can we also add stream_logs() below show_metrics()

import matplotlib
matplotlib.use("Agg")

df = sft_trainer.show_metrics()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we add stream logs here too?

First build creates a Model, second build with reuse finds it.
"""
training_job = TrainingJob.get(training_job_name=training_job_name, region=AWS_REGION)
unique_id = f"{int(time.time())}-{random.randint(100, 10000)}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is a super small chance of race condition here. If 2 codebuild test runs end up having the same unique_id. Might want to call this out as a code comment.

# Verify only one model exists with our unique prefix
sm_client = boto3.client("sagemaker", region_name=AWS_REGION)
models = sm_client.list_models(NameContains=f"reuse-build-{unique_id}", MaxResults=10).get("Models", [])
assert len(models) == 1, (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we assert model2.model_arn == model1.model_arn instead?

NameContains=f"nova-reuse-build-{unique_id}",
MaxResults=10,
).get("Models", [])
assert len(models) == 1, (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we assert model2.model_arn == model1.model_arn instead?

@amazeAmazing
amazeAmazing force-pushed the integ-tests-metrics-notifications-reuse branch from 1abebcf to e0ac4e3 Compare August 5, 2026 21:09
…es=True)

- Add show_metrics() assertions to existing Nova SFT tests (serverless + serverful)
- Add show_metrics() via MLflow to OSS Llama SFT test
- Add show_metrics() to MTRL trainer integration test
- Add reuse round-trip tests to test_model_customization_deployment.py (OSS, us-west-2)
- Add reuse round-trip tests to test_nova_model_customization_deployment.py (Nova, us-east-1)
- Add build(reuse_resources=True) tests to both deployment test files
@amazeAmazing
amazeAmazing force-pushed the integ-tests-metrics-notifications-reuse branch from e0ac4e3 to c4f3737 Compare August 5, 2026 21:31
@mujtaba1747
mujtaba1747 merged commit acd7308 into aws:master-nova-follow-ups Aug 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants