Repository: getmoto/moto
Pull request #6899 (2023-10-11 03:57:17)

Sagemaker: Add describe_model_package_group
This pull request implements for sagemaker :

- describe_model_package_group

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getmoto/moto/pull/6899?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) Report
> Merging [#6899](https://app.codecov.io/gh/getmoto/moto/pull/6899?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (6476c54) into [master](https://app.codecov.io/gh/getmoto/moto/commit/f39bb45f2c7dc07fc05f26a8520ef36212497ddd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (f39bb45) will **decrease** coverage by `0.01%`.
> The diff coverage is `88.88%`.

```diff
@@            Coverage Diff             @@
##           master    #6899      +/-   ##
==========================================
- Coverage   95.82%   95.82%   -0.01%     
==========================================
  Files         826      826              
  Lines       80961    80970       +9     
==========================================
+ Hits        77579    77587       +8     
- Misses       3382     3383       +1     
```

| [Flag](https://app.codecov.io/gh/getmoto/moto/pull/6899/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | |
|---|---|---|
| [servertests](https://app.codecov.io/gh/getmoto/moto/pull/6899/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `36.76% <11.11%> (-0.01%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/getmoto/moto/pull/6899/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `95.76% <88.88%> (-0.01%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files](https://app.codecov.io/gh/getmoto/moto/pull/6899?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | |
|---|---|---|
| [moto/sagemaker/responses.py](https://app.codecov.io/gh/getmoto/moto/pull/6899?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#diff-bW90by9zYWdlbWFrZXIvcmVzcG9uc2VzLnB5) | `98.02% <100.00%> (+0.01%)` | :arrow_up: |
| [moto/sagemaker/models.py](https://app.codecov.io/gh/getmoto/moto/pull/6899?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#diff-bW90by9zYWdlbWFrZXIvbW9kZWxzLnB5) | `92.30% <80.00%> (-0.05%)` | :arrow_down: |



Patch:
diff --git a/IMPLEMENTATION_COVERAGE.md b/IMPLEMENTATION_COVERAGE.md
index 34e5703b0..c9302c490 100644
--- a/IMPLEMENTATION_COVERAGE.md
+++ b/IMPLEMENTATION_COVERAGE.md
@@ -6380,7 +6380,7 @@
 - [ ] describe_model_card_export_job
 - [ ] describe_model_explainability_job_definition
 - [X] describe_model_package
-- [ ] describe_model_package_group
+- [X] describe_model_package_group
 - [ ] describe_model_quality_job_definition
 - [ ] describe_monitoring_schedule
 - [ ] describe_notebook_instance
diff --git a/moto/sagemaker/models.py b/moto/sagemaker/models.py
index 8a36e33ee..208c0f09c 100644
--- a/moto/sagemaker/models.py
+++ b/moto/sagemaker/models.py
@@ -3260,6 +3260,16 @@ class SageMakerModelBackend(BaseBackend):
         )
         return model_package_group_summary_list
 
+    def describe_model_package_group(
+        self, model_package_group_name: str
+    ) -> ModelPackageGroup:
+        model_package_group = self.model_package_groups.get(model_package_group_name)
+        if model_package_group is None:
+            raise ValidationError(
+                f"Model package group {model_package_group_name} not found"
+            )
+        return model_package_group
+
     @paginate(pagination_model=PAGINATION_MODEL)  # type: ignore[misc]
     def list_model_packages(  # type: ignore[misc]
         self,
diff --git a/moto/sagemaker/responses.py b/moto/sagemaker/responses.py
index acddec2c8..f490296d7 100644
--- a/moto/sagemaker/responses.py
+++ b/moto/sagemaker/responses.py
@@ -874,6 +874,15 @@ class SageMakerResponse(BaseResponse):
             model_package.gen_response_object(),
         )
 
+    def describe_model_package_group(self) -> str:
+        model_package_group_name = self._get_param("ModelPackageGroupName")
+        model_package_group = self.sagemaker_backend.describe_model_package_group(
+            model_package_group_name=model_package_group_name,
+        )
+        return json.dumps(
+            model_package_group.gen_response_object(),
+        )
+
     def update_model_package(self) -> str:
         model_package_arn = self._get_param("ModelPackageArn")
         model_approval_status = self._get_param("ModelApprovalStatus")


Test patch:
diff --git a/tests/test_sagemaker/test_sagemaker_model_package_groups.py b/tests/test_sagemaker/test_sagemaker_model_package_groups.py
index 49a1d99fb..147975064 100644
--- a/tests/test_sagemaker/test_sagemaker_model_package_groups.py
+++ b/tests/test_sagemaker/test_sagemaker_model_package_groups.py
@@ -1,8 +1,10 @@
 """Unit tests for sagemaker-supported APIs."""
 from unittest import SkipTest
+from datetime import datetime
 
 import boto3
 from freezegun import freeze_time
+from dateutil.tz import tzutc  # type: ignore
 
 from moto import mock_sagemaker, settings
 
@@ -163,3 +165,28 @@ def test_list_model_package_groups_sort_order():
         resp["ModelPackageGroupSummaryList"][1]["ModelPackageGroupName"]
         == "test-model-package-group-1"
     )
+
+
+@mock_sagemaker
+def test_describe_model_package_group():
+    if settings.TEST_SERVER_MODE:
+        raise SkipTest("Can't freeze time in ServerMode")
+    client = boto3.client("sagemaker", region_name="eu-west-1")
+    with freeze_time("2020-01-01 00:00:00"):
+        client.create_model_package_group(
+            ModelPackageGroupName="test-model-package-group",
+            ModelPackageGroupDescription="test-model-package-group-description",
+        )
+    resp = client.describe_model_package_group(
+        ModelPackageGroupName="test-model-package-group"
+    )
+    assert resp["ModelPackageGroupName"] == "test-model-package-group"
+    assert (
+        resp["ModelPackageGroupDescription"] == "test-model-package-group-description"
+    )
+    assert (
+        resp["ModelPackageGroupArn"]
+        == "arn:aws:sagemaker:eu-west-1:123456789012:model-package-group/test-model-package-group"
+    )
+    assert resp["ModelPackageGroupStatus"] == "Completed"
+    assert resp["CreationTime"] == datetime(2020, 1, 1, 0, 0, 0, tzinfo=tzutc())