sagemaker-core 1.0.32__py3-none-any.whl → 1.0.33__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sagemaker-core might be problematic. Click here for more details.

@@ -6471,10 +6471,12 @@ class DataQualityJobDefinition(Base):
6471
6471
  "CreationTimeBefore": creation_time_before,
6472
6472
  "CreationTimeAfter": creation_time_after,
6473
6473
  }
6474
+
6474
6475
  custom_key_mapping = {
6475
6476
  "monitoring_job_definition_name": "job_definition_name",
6476
6477
  "monitoring_job_definition_arn": "job_definition_arn",
6477
6478
  }
6479
+
6478
6480
  # serialize the input request
6479
6481
  operation_input_args = serialize(operation_input_args)
6480
6482
  logger.debug(f"Serialized input request: {operation_input_args}")
@@ -12613,6 +12615,84 @@ class HubContent(Base):
12613
12615
  region=region,
12614
12616
  )
12615
12617
 
12618
+ @classmethod
12619
+ @Base.add_validate_call
12620
+ def get_all(
12621
+ cls,
12622
+ hub_name: str,
12623
+ hub_content_type: str,
12624
+ name_contains: Optional[str] = Unassigned(),
12625
+ max_schema_version: Optional[str] = Unassigned(),
12626
+ creation_time_before: Optional[datetime.datetime] = Unassigned(),
12627
+ creation_time_after: Optional[datetime.datetime] = Unassigned(),
12628
+ sort_by: Optional[str] = Unassigned(),
12629
+ sort_order: Optional[str] = Unassigned(),
12630
+ session: Optional[Session] = None,
12631
+ region: Optional[str] = None,
12632
+ ) -> ResourceIterator["HubContent"]:
12633
+ """
12634
+ Get all HubContent resources
12635
+
12636
+ Parameters:
12637
+ hub_name: The name of the hub to list the contents of.
12638
+ hub_content_type: The type of hub content to list.
12639
+ name_contains: Only list hub content if the name contains the specified string.
12640
+ max_schema_version: The upper bound of the hub content schema verion.
12641
+ creation_time_before: Only list hub content that was created before the time specified.
12642
+ creation_time_after: Only list hub content that was created after the time specified.
12643
+ sort_by: Sort hub content versions by either name or creation time.
12644
+ sort_order: Sort hubs by ascending or descending order.
12645
+ max_results: The maximum amount of hub content to list.
12646
+ next_token: If the response to a previous ListHubContents request was truncated, the response includes a NextToken. To retrieve the next set of hub content, use the token in the next request.
12647
+ session: Boto3 session.
12648
+ region: Region name.
12649
+
12650
+ Returns:
12651
+ Iterator for listed HubContent resources.
12652
+
12653
+ Raises:
12654
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
12655
+ The error message and error code can be parsed from the exception as follows:
12656
+ ```
12657
+ try:
12658
+ # AWS service call here
12659
+ except botocore.exceptions.ClientError as e:
12660
+ error_message = e.response['Error']['Message']
12661
+ error_code = e.response['Error']['Code']
12662
+ ```
12663
+ ResourceNotFound: Resource being access is not found.
12664
+ """
12665
+
12666
+ client = Base.get_sagemaker_client(
12667
+ session=session, region_name=region, service_name="sagemaker"
12668
+ )
12669
+
12670
+ operation_input_args = {
12671
+ "HubName": hub_name,
12672
+ "HubContentType": hub_content_type,
12673
+ "NameContains": name_contains,
12674
+ "MaxSchemaVersion": max_schema_version,
12675
+ "CreationTimeBefore": creation_time_before,
12676
+ "CreationTimeAfter": creation_time_after,
12677
+ "SortBy": sort_by,
12678
+ "SortOrder": sort_order,
12679
+ }
12680
+ extract_name_mapping = {"hub_content_arn": ["hub-content/", "hub_name"]}
12681
+
12682
+ # serialize the input request
12683
+ operation_input_args = serialize(operation_input_args)
12684
+ logger.debug(f"Serialized input request: {operation_input_args}")
12685
+
12686
+ return ResourceIterator(
12687
+ client=client,
12688
+ list_method="list_hub_contents",
12689
+ summaries_key="HubContentSummaries",
12690
+ summary_name="HubContentInfo",
12691
+ resource_cls=HubContent,
12692
+ extract_name_mapping=extract_name_mapping,
12693
+ list_method_kwargs=operation_input_args,
12694
+ )
12695
+
12616
12696
  @Base.add_validate_call
12617
12697
  def get_all_versions(
12618
12698
  self,
@@ -14915,6 +14995,81 @@ class ImageVersion(Base):
14915
14995
  raise e
14916
14996
  time.sleep(poll)
14917
14997
 
14998
+ @classmethod
14999
+ @Base.add_validate_call
15000
+ def get_all(
15001
+ cls,
15002
+ image_name: str,
15003
+ creation_time_after: Optional[datetime.datetime] = Unassigned(),
15004
+ creation_time_before: Optional[datetime.datetime] = Unassigned(),
15005
+ last_modified_time_after: Optional[datetime.datetime] = Unassigned(),
15006
+ last_modified_time_before: Optional[datetime.datetime] = Unassigned(),
15007
+ sort_by: Optional[str] = Unassigned(),
15008
+ sort_order: Optional[str] = Unassigned(),
15009
+ session: Optional[Session] = None,
15010
+ region: Optional[str] = None,
15011
+ ) -> ResourceIterator["ImageVersion"]:
15012
+ """
15013
+ Get all ImageVersion resources
15014
+
15015
+ Parameters:
15016
+ image_name: The name of the image to list the versions of.
15017
+ creation_time_after: A filter that returns only versions created on or after the specified time.
15018
+ creation_time_before: A filter that returns only versions created on or before the specified time.
15019
+ last_modified_time_after: A filter that returns only versions modified on or after the specified time.
15020
+ last_modified_time_before: A filter that returns only versions modified on or before the specified time.
15021
+ max_results: The maximum number of versions to return in the response. The default value is 10.
15022
+ next_token: If the previous call to ListImageVersions didn't return the full set of versions, the call returns a token for getting the next set of versions.
15023
+ sort_by: The property used to sort results. The default value is CREATION_TIME.
15024
+ sort_order: The sort order. The default value is DESCENDING.
15025
+ session: Boto3 session.
15026
+ region: Region name.
15027
+
15028
+ Returns:
15029
+ Iterator for listed ImageVersion resources.
15030
+
15031
+ Raises:
15032
+ botocore.exceptions.ClientError: This exception is raised for AWS service related errors.
15033
+ The error message and error code can be parsed from the exception as follows:
15034
+ ```
15035
+ try:
15036
+ # AWS service call here
15037
+ except botocore.exceptions.ClientError as e:
15038
+ error_message = e.response['Error']['Message']
15039
+ error_code = e.response['Error']['Code']
15040
+ ```
15041
+ ResourceNotFound: Resource being access is not found.
15042
+ """
15043
+
15044
+ client = Base.get_sagemaker_client(
15045
+ session=session, region_name=region, service_name="sagemaker"
15046
+ )
15047
+
15048
+ operation_input_args = {
15049
+ "CreationTimeAfter": creation_time_after,
15050
+ "CreationTimeBefore": creation_time_before,
15051
+ "ImageName": image_name,
15052
+ "LastModifiedTimeAfter": last_modified_time_after,
15053
+ "LastModifiedTimeBefore": last_modified_time_before,
15054
+ "SortBy": sort_by,
15055
+ "SortOrder": sort_order,
15056
+ }
15057
+ extract_name_mapping = {"image_version_arn": ["image-version/", "image_name"]}
15058
+
15059
+ # serialize the input request
15060
+ operation_input_args = serialize(operation_input_args)
15061
+ logger.debug(f"Serialized input request: {operation_input_args}")
15062
+
15063
+ return ResourceIterator(
15064
+ client=client,
15065
+ list_method="list_image_versions",
15066
+ summaries_key="ImageVersions",
15067
+ summary_name="ImageVersion",
15068
+ resource_cls=ImageVersion,
15069
+ extract_name_mapping=extract_name_mapping,
15070
+ list_method_kwargs=operation_input_args,
15071
+ )
15072
+
14918
15073
 
14919
15074
  class InferenceComponent(Base):
14920
15075
  """
@@ -18504,10 +18659,12 @@ class ModelBiasJobDefinition(Base):
18504
18659
  "CreationTimeBefore": creation_time_before,
18505
18660
  "CreationTimeAfter": creation_time_after,
18506
18661
  }
18662
+
18507
18663
  custom_key_mapping = {
18508
18664
  "monitoring_job_definition_name": "job_definition_name",
18509
18665
  "monitoring_job_definition_arn": "job_definition_arn",
18510
18666
  }
18667
+
18511
18668
  # serialize the input request
18512
18669
  operation_input_args = serialize(operation_input_args)
18513
18670
  logger.debug(f"Serialized input request: {operation_input_args}")
@@ -19733,10 +19890,12 @@ class ModelExplainabilityJobDefinition(Base):
19733
19890
  "CreationTimeBefore": creation_time_before,
19734
19891
  "CreationTimeAfter": creation_time_after,
19735
19892
  }
19893
+
19736
19894
  custom_key_mapping = {
19737
19895
  "monitoring_job_definition_name": "job_definition_name",
19738
19896
  "monitoring_job_definition_arn": "job_definition_arn",
19739
19897
  }
19898
+
19740
19899
  # serialize the input request
19741
19900
  operation_input_args = serialize(operation_input_args)
19742
19901
  logger.debug(f"Serialized input request: {operation_input_args}")
@@ -21350,10 +21509,12 @@ class ModelQualityJobDefinition(Base):
21350
21509
  "CreationTimeBefore": creation_time_before,
21351
21510
  "CreationTimeAfter": creation_time_after,
21352
21511
  }
21512
+
21353
21513
  custom_key_mapping = {
21354
21514
  "monitoring_job_definition_name": "job_definition_name",
21355
21515
  "monitoring_job_definition_arn": "job_definition_arn",
21356
21516
  }
21517
+
21357
21518
  # serialize the input request
21358
21519
  operation_input_args = serialize(operation_input_args)
21359
21520
  logger.debug(f"Serialized input request: {operation_input_args}")
@@ -387,6 +387,7 @@ class ResourceIterator(Generic[T]):
387
387
  list_method: str,
388
388
  list_method_kwargs: dict = {},
389
389
  custom_key_mapping: dict = None,
390
+ extract_name_mapping: dict = None,
390
391
  ):
391
392
  """Initialize a ResourceIterator object
392
393
 
@@ -398,6 +399,7 @@ class ResourceIterator(Generic[T]):
398
399
  list_method (str): The list method string used to make list calls to the client.
399
400
  list_method_kwargs (dict, optional): The kwargs used to make list method calls. Defaults to {}.
400
401
  custom_key_mapping (dict, optional): The custom key mapping used to map keys from summary object to those expected from resource object during initialization. Defaults to None.
402
+ extract_name_mapping (dict, optional): The extract name mapping used to extract names from arn in summary object and map to those expected from resource object during initialization. Defaults to None.
401
403
  """
402
404
  self.summaries_key = summaries_key
403
405
  self.summary_name = summary_name
@@ -405,6 +407,7 @@ class ResourceIterator(Generic[T]):
405
407
  self.list_method = list_method
406
408
  self.list_method_kwargs = list_method_kwargs
407
409
  self.custom_key_mapping = custom_key_mapping
410
+ self.extract_name_mapping = extract_name_mapping
408
411
 
409
412
  self.resource_cls = resource_cls
410
413
  self.index = 0
@@ -433,6 +436,12 @@ class ResourceIterator(Generic[T]):
433
436
  if self.custom_key_mapping:
434
437
  init_data = {self.custom_key_mapping.get(k, k): v for k, v in init_data.items()}
435
438
 
439
+ # Extract name from arn. Currently implemented for HubContent and ImageVersion
440
+ if self.extract_name_mapping:
441
+ for arn, target in self.extract_name_mapping.items():
442
+ name = init_data[arn].split(target[0])[1].split("/")[0]
443
+ init_data.update({target[1]: name})
444
+
436
445
  # Filter out the fields that are not in the resource class
437
446
  fields = self.resource_cls.__annotations__
438
447
  init_data = {k: v for k, v in init_data.items() if k in fields}
@@ -1754,14 +1754,27 @@ class ResourcesCodeGen:
1754
1754
  get_operation_required_input = []
1755
1755
 
1756
1756
  custom_key_mapping_str = ""
1757
+ custom_key_mapping = {}
1758
+ extract_name_mapping_str = ""
1759
+ extract_name_mapping = {}
1757
1760
  if any(member not in summary_members for member in get_operation_required_input):
1758
- if "MonitoringJobDefinitionSummary" == summary_name:
1761
+ if summary_name == "MonitoringJobDefinitionSummary":
1759
1762
  custom_key_mapping = {
1760
1763
  "monitoring_job_definition_name": "job_definition_name",
1761
1764
  "monitoring_job_definition_arn": "job_definition_arn",
1762
1765
  }
1763
- custom_key_mapping_str = f"custom_key_mapping = {json.dumps(custom_key_mapping)}"
1764
- custom_key_mapping_str = add_indent(custom_key_mapping_str, 4)
1766
+ elif summary_name == "HubContentInfo":
1767
+ # HubContentArn -- arn:<partition>:sagemaker:<region>:<account-id>:hub-content/<hub-name>/<type>/<name>/<version>
1768
+ # {source key from input: (target label in arn, target key in output)}
1769
+ extract_name_mapping = {
1770
+ "hub_content_arn": ("hub-content/", "hub_name"),
1771
+ }
1772
+ elif summary_name == "ImageVersion":
1773
+ # ImageVersionArn -- arn:aws:sagemaker:<region>:<account>:image-version/<image-name>/<version-number>
1774
+ # {source key from input: (target label in arn, target key in output)}
1775
+ extract_name_mapping = {
1776
+ "image_version_arn": ("image-version/", "image_name"),
1777
+ }
1765
1778
  else:
1766
1779
  log.warning(
1767
1780
  f"Resource {resource_name} summaries do not have required members to create object instance. Resource may require custom key mapping for get_all().\n"
@@ -1769,6 +1782,15 @@ class ResourcesCodeGen:
1769
1782
  )
1770
1783
  return ""
1771
1784
 
1785
+ if custom_key_mapping:
1786
+ custom_key_mapping_str = add_indent(
1787
+ f"custom_key_mapping = {json.dumps(custom_key_mapping)}", 4
1788
+ )
1789
+ if extract_name_mapping:
1790
+ extract_name_mapping_str = add_indent(
1791
+ f"extract_name_mapping = {json.dumps(extract_name_mapping)}", 4
1792
+ )
1793
+
1772
1794
  resource_iterator_args_list = [
1773
1795
  "client=client",
1774
1796
  f"list_method='{operation}'",
@@ -1780,6 +1802,9 @@ class ResourcesCodeGen:
1780
1802
  if custom_key_mapping_str:
1781
1803
  resource_iterator_args_list.append(f"custom_key_mapping=custom_key_mapping")
1782
1804
 
1805
+ if extract_name_mapping_str:
1806
+ resource_iterator_args_list.append(f"extract_name_mapping=extract_name_mapping")
1807
+
1783
1808
  exclude_list = ["next_token", "max_results"]
1784
1809
  get_all_args = self._generate_method_args(operation_input_shape_name, exclude_list)
1785
1810
 
@@ -1792,6 +1817,7 @@ class ResourcesCodeGen:
1792
1817
  resource=resource_name,
1793
1818
  operation=operation,
1794
1819
  custom_key_mapping=custom_key_mapping_str,
1820
+ extract_name_mapping=extract_name_mapping_str,
1795
1821
  resource_iterator_args=resource_iterator_args,
1796
1822
  )
1797
1823
  return formatted_method
@@ -1822,6 +1848,7 @@ class ResourcesCodeGen:
1822
1848
  get_all_args=get_all_args,
1823
1849
  operation_input_args=operation_input_args,
1824
1850
  custom_key_mapping=custom_key_mapping_str,
1851
+ extract_name_mapping=extract_name_mapping_str,
1825
1852
  resource_iterator_args=resource_iterator_args,
1826
1853
  )
1827
1854
  return formatted_method
@@ -512,6 +512,7 @@ def get_all(
512
512
  operation_input_args = {{
513
513
  {operation_input_args}
514
514
  }}
515
+ {extract_name_mapping}
515
516
  {custom_key_mapping}
516
517
  # serialize the input request
517
518
  operation_input_args = serialize(operation_input_args)
@@ -542,6 +543,7 @@ def get_all(
542
543
 
543
544
  """
544
545
  client = Base.get_sagemaker_client(session=session, region_name=region, service_name="{service_name}")
546
+ {extract_name_mapping}
545
547
  {custom_key_mapping}
546
548
  return ResourceIterator(
547
549
  {resource_iterator_args}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sagemaker-core
3
- Version: 1.0.32
3
+ Version: 1.0.33
4
4
  Summary: An python package for sagemaker core functionalities
5
5
  Author-email: AWS <sagemaker-interests@amazon.com>
6
6
  Project-URL: Repository, https://github.com/aws/sagemaker-core.git
@@ -20,7 +20,7 @@ Requires-Dist: pydantic<3.0.0,>=2.0.0
20
20
  Requires-Dist: PyYAML<7.0,>=6.0
21
21
  Requires-Dist: jsonschema<5.0.0
22
22
  Requires-Dist: platformdirs<5.0.0,>=4.0.0
23
- Requires-Dist: rich<14.0.0,>=13.0.0
23
+ Requires-Dist: rich<15.0.0,>=14.0.0
24
24
  Requires-Dist: mock<5.0,>4.0
25
25
  Requires-Dist: importlib-metadata<7.0,>=1.4.0
26
26
  Provides-Extra: codegen
@@ -7,10 +7,10 @@ sagemaker_core/main/config_schema.py,sha256=Wxe2gJash1rrxBomGhSYmII1LmJ3E70LIuSW
7
7
  sagemaker_core/main/exceptions.py,sha256=87DUlrmHxaWoiYNlpNY9ixxFMPRk_dIGPsA2e_xdVwQ,5602
8
8
  sagemaker_core/main/intelligent_defaults_helper.py,sha256=5SDM6UavZtp-k5LhqRL7GRIDgzFB5UsC_p7YuiSPK9A,8334
9
9
  sagemaker_core/main/logs.py,sha256=yfEH7uP91nbE1lefymOlBr81ziBzsDSIOF2Qyd54FJE,6241
10
- sagemaker_core/main/resources.py,sha256=jNX5jp5tmwa0t8PYPxWrRRBAGIn0G-iq3C-7TvBxEPw,1420815
10
+ sagemaker_core/main/resources.py,sha256=jtD_9MUoyJkTDGAAnvEVpaconzPF6kRFBdio_mN_3zs,1427804
11
11
  sagemaker_core/main/shapes.py,sha256=YfcsZIpYetJPZHNo-VfajMCaqT6eGYXI_1EvCLr0dGg,739047
12
12
  sagemaker_core/main/user_agent.py,sha256=BPYDAfDd70ObP-VAjl7aDHALHyGknkpRP21ktVr_LDw,2744
13
- sagemaker_core/main/utils.py,sha256=qTGJDcZwrAQSsdyg8A78x4PKU4Wu1rY6Cn3OIbIspaA,18546
13
+ sagemaker_core/main/utils.py,sha256=tJyHjHFwwmz8LHMlOLf5_Exu4h-kFVnAxvXkbChkuHQ,19215
14
14
  sagemaker_core/main/code_injection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  sagemaker_core/main/code_injection/base.py,sha256=11_Jif0nOzfbLGlXaacKf-wcizzfS64U0OSZGoVffFU,1733
16
16
  sagemaker_core/main/code_injection/codec.py,sha256=nA51E9iNWHyKou1G23rKSRL4WitdkFRbMuFkyrGHzKU,8428
@@ -23,13 +23,13 @@ sagemaker_core/tools/codegen.py,sha256=mKWVi2pWnPxyIoWUEPYjEc9Gw7D9bCOrHqa00yzIZ
23
23
  sagemaker_core/tools/constants.py,sha256=XEwsUJ4w952mpnk-K0TS7R2uJhZyVPjcR47nrzgVXtg,3483
24
24
  sagemaker_core/tools/data_extractor.py,sha256=pNfmTA0NUA96IgfLrla7a36Qjc1NljbwgZYaOhouKqQ,2113
25
25
  sagemaker_core/tools/method.py,sha256=Ud2YeH2SPkj7xtIxBuUdRfQwCmovMUzGGkcIvzhpQeQ,805
26
- sagemaker_core/tools/resources_codegen.py,sha256=wz9HU_crbHeZUp5ylMqgfWbHCCgVLfD31hFBGBSuW_A,85100
26
+ sagemaker_core/tools/resources_codegen.py,sha256=jYhbGQ0X5xuQGgIJp6UOHY_RU-PsLFe4JfpdjL1lPCk,86445
27
27
  sagemaker_core/tools/resources_extractor.py,sha256=hN61ehZbPnhFW-2FIVDi7NsEz4rLvGr-WoglHQGfrug,14523
28
28
  sagemaker_core/tools/shapes_codegen.py,sha256=4lsePZpjk7M6RpJs5yar_m4z5MzwGHFrvCkdS_-R12c,12172
29
29
  sagemaker_core/tools/shapes_extractor.py,sha256=vxVKjXD3lmjrkoKiexjUnOt8ITbFxQSeiDtx7P6Qtkw,14226
30
- sagemaker_core/tools/templates.py,sha256=vIgRWConRGAQ-Mri6LwfkArqWHlL3KXcvbbYa-t_MV4,23414
31
- sagemaker_core-1.0.32.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
32
- sagemaker_core-1.0.32.dist-info/METADATA,sha256=N-vlVke2GuSZYAnC04SYBHYOuDIMaGbWBgBYXcqVNgM,4885
33
- sagemaker_core-1.0.32.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
34
- sagemaker_core-1.0.32.dist-info/top_level.txt,sha256=R3GAZZ1zC5JxqdE_0x2Lu_WYi2Xfke7VsiP3L5zngfA,15
35
- sagemaker_core-1.0.32.dist-info/RECORD,,
30
+ sagemaker_core/tools/templates.py,sha256=0lOIH3Rq2CXWkQhK6VenN_TE_v5p852s2kQyb_BeQxA,23460
31
+ sagemaker_core-1.0.33.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
32
+ sagemaker_core-1.0.33.dist-info/METADATA,sha256=0AkeGwVa8WdSOps6dTQQZh0_KmS3uRLV_NWmH0PkuEM,4885
33
+ sagemaker_core-1.0.33.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
34
+ sagemaker_core-1.0.33.dist-info/top_level.txt,sha256=R3GAZZ1zC5JxqdE_0x2Lu_WYi2Xfke7VsiP3L5zngfA,15
35
+ sagemaker_core-1.0.33.dist-info/RECORD,,