Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruinong Tian committed Oct 2, 2024
1 parent 8dec79e commit a973f8d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/image_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def full_version_with_type(self):
# 1.11-cpu, 1.11-gpu
def major_minor_with_type(self):
return self.major_version + "." + self.minor_version + "-" + self.image_type

# 1-cpu, 1-gpu
def major_with_type(self):
return self.major_version + "-" + self.image_type
9 changes: 7 additions & 2 deletions src/version_release_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ImageVersion,
)


def generate_new_version_release(args):
target_version = str(get_semver(args.target_patch_version))
image_type = args.image_type
Expand All @@ -18,5 +19,9 @@ def generate_new_version_release(args):
print("```")

print("## Change Logs")
print(f"Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v{image_version.major_version}/v{image_version.major_minor()}/v{image_version.full_version()}/CHANGELOG-{image_type}.md")
print(f"Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v{image_version.major_version}/v{image_version.major_minor()}/v{image_version.full_version()}/RELEASE.md")
print(
f"Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v{image_version.major_version}/v{image_version.major_minor()}/v{image_version.full_version()}/CHANGELOG-{image_type}.md"
)
print(
f"Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v{image_version.major_version}/v{image_version.major_minor()}/v{image_version.full_version()}/RELEASE.md"
)
73 changes: 37 additions & 36 deletions test/test_version_release_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,73 @@
from unittest.mock import patch
from version_release_generator import generate_new_version_release


class TestVersionReleaseGenerator(unittest.TestCase):
def test_generate_new_version_release_v0(self):
args = lambda: None
args.target_patch_version = '0.13.0'
args.image_type = 'cpu'
args.target_patch_version = "0.13.0"
args.image_type = "cpu"

# Act
with patch('builtins.print') as mock_print:
with patch("builtins.print") as mock_print:
generate_new_version_release(args)

# Assert
expected_output = [
'### Public ECR Gallery URL',
'https://gallery.ecr.aws/sagemaker/sagemaker-distribution',
'### Public ECR Image URL',
'```',
'public.ecr.aws/sagemaker/sagemaker-distribution:0.13.0-cpu',
'```',
'## Change Logs',
'Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v0/v0.13/v0.13.0/CHANGELOG-cpu.md',
'Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v0/v0.13/v0.13.0/RELEASE.md'
"### Public ECR Gallery URL",
"https://gallery.ecr.aws/sagemaker/sagemaker-distribution",
"### Public ECR Image URL",
"```",
"public.ecr.aws/sagemaker/sagemaker-distribution:0.13.0-cpu",
"```",
"## Change Logs",
"Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v0/v0.13/v0.13.0/CHANGELOG-cpu.md",
"Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v0/v0.13/v0.13.0/RELEASE.md",
]
mock_print.assert_has_calls([unittest.mock.call(line) for line in expected_output])

def test_generate_new_version_release_v1(self):
args = lambda: None
args.target_patch_version = '1.2.3'
args.image_type = 'cpu'
args.target_patch_version = "1.2.3"
args.image_type = "cpu"

# Act
with patch('builtins.print') as mock_print:
with patch("builtins.print") as mock_print:
generate_new_version_release(args)

# Assert
expected_output = [
'### Public ECR Gallery URL',
'https://gallery.ecr.aws/sagemaker/sagemaker-distribution',
'### Public ECR Image URL',
'```',
'public.ecr.aws/sagemaker/sagemaker-distribution:1.2.3-cpu',
'```',
'## Change Logs',
'Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v1/v1.2/v1.2.3/CHANGELOG-cpu.md',
'Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v1/v1.2/v1.2.3/RELEASE.md'
"### Public ECR Gallery URL",
"https://gallery.ecr.aws/sagemaker/sagemaker-distribution",
"### Public ECR Image URL",
"```",
"public.ecr.aws/sagemaker/sagemaker-distribution:1.2.3-cpu",
"```",
"## Change Logs",
"Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v1/v1.2/v1.2.3/CHANGELOG-cpu.md",
"Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v1/v1.2/v1.2.3/RELEASE.md",
]
mock_print.assert_has_calls([unittest.mock.call(line) for line in expected_output])

def test_generate_new_version_release_v2(self):
args = lambda: None
args.target_patch_version = '2.0.0'
args.image_type = 'gpu'
args.target_patch_version = "2.0.0"
args.image_type = "gpu"

# Act
with patch('builtins.print') as mock_print:
with patch("builtins.print") as mock_print:
generate_new_version_release(args)

# Assert
expected_output = [
'### Public ECR Gallery URL',
'https://gallery.ecr.aws/sagemaker/sagemaker-distribution',
'### Public ECR Image URL',
'```',
'public.ecr.aws/sagemaker/sagemaker-distribution:2.0.0-gpu',
'```',
'## Change Logs',
'Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v2/v2.0/v2.0.0/CHANGELOG-gpu.md',
'Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v2/v2.0/v2.0.0/RELEASE.md'
"### Public ECR Gallery URL",
"https://gallery.ecr.aws/sagemaker/sagemaker-distribution",
"### Public ECR Image URL",
"```",
"public.ecr.aws/sagemaker/sagemaker-distribution:2.0.0-gpu",
"```",
"## Change Logs",
"Change log: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v2/v2.0/v2.0.0/CHANGELOG-gpu.md",
"Release note: https://github.com/aws/sagemaker-distribution/blob/main/build_artifacts/v2/v2.0/v2.0.0/RELEASE.md",
]
mock_print.assert_has_calls([unittest.mock.call(line) for line in expected_output])

0 comments on commit a973f8d

Please sign in to comment.