2323
2424
2525class PropertiesMeta (type ):
26- """Load an internal shapes attribute from the botocore sagemaker service model."""
26+ """Load an internal shapes attribute from the botocore service model
2727
28- _shapes = None
28+ for sagemaker and emr service.
29+ """
30+
31+ _shapes_map = dict ()
2932 _primitive_types = {"string" , "boolean" , "integer" , "float" }
3033
3134 def __new__ (mcs , * args , ** kwargs ):
32- """Loads up the shapes from the botocore sagemaker service model."""
33- if mcs ._shapes is None :
35+ """Loads up the shapes from the botocore service model."""
36+ if len ( mcs ._shapes_map . keys ()) == 0 :
3437 loader = botocore .loaders .Loader ()
35- model = loader .load_service_model ("sagemaker" , "service-2" )
36- mcs ._shapes = model ["shapes" ]
38+
39+ sagemaker_model = loader .load_service_model ("sagemaker" , "service-2" )
40+ emr_model = loader .load_service_model ("emr" , "service-2" )
41+ mcs ._shapes_map ["sagemaker" ] = sagemaker_model ["shapes" ]
42+ mcs ._shapes_map ["emr" ] = emr_model ["shapes" ]
43+
3744 return super ().__new__ (mcs , * args , ** kwargs )
3845
3946
@@ -45,32 +52,41 @@ def __init__(
4552 path : str ,
4653 shape_name : str = None ,
4754 shape_names : List [str ] = None ,
55+ service_name : str = "sagemaker" ,
4856 ):
4957 """Create a Properties instance representing the given shape.
5058
5159 Args:
5260 path (str): The parent path of the Properties instance.
53- shape_name (str): The botocore sagemaker service model shape name.
54- shape_names (str): A List of the botocore sagemaker service model shape name.
61+ shape_name (str): The botocore service model shape name.
62+ shape_names (str): A List of the botocore service model shape name.
5563 """
5664 self ._path = path
5765 shape_names = [] if shape_names is None else shape_names
5866 self ._shape_names = shape_names if shape_name is None else [shape_name ] + shape_names
5967
68+ shapes = Properties ._shapes_map .get (service_name , {})
69+
6070 for name in self ._shape_names :
61- shape = Properties . _shapes .get (name , {})
71+ shape = shapes .get (name , {})
6272 shape_type = shape .get ("type" )
6373 if shape_type in Properties ._primitive_types :
6474 self .__str__ = name
6575 elif shape_type == "structure" :
6676 members = shape ["members" ]
6777 for key , info in members .items ():
68- if Properties ._shapes .get (info ["shape" ], {}).get ("type" ) == "list" :
69- self .__dict__ [key ] = PropertiesList (f"{ path } .{ key } " , info ["shape" ])
70- elif Properties ._shapes .get (info ["shape" ], {}).get ("type" ) == "map" :
71- self .__dict__ [key ] = PropertiesMap (f"{ path } .{ key } " , info ["shape" ])
78+ if shapes .get (info ["shape" ], {}).get ("type" ) == "list" :
79+ self .__dict__ [key ] = PropertiesList (
80+ f"{ path } .{ key } " , info ["shape" ], service_name
81+ )
82+ elif shapes .get (info ["shape" ], {}).get ("type" ) == "map" :
83+ self .__dict__ [key ] = PropertiesMap (
84+ f"{ path } .{ key } " , info ["shape" ], service_name
85+ )
7286 else :
73- self .__dict__ [key ] = Properties (f"{ path } .{ key } " , info ["shape" ])
87+ self .__dict__ [key ] = Properties (
88+ f"{ path } .{ key } " , info ["shape" ], service_name = service_name
89+ )
7490
7591 @property
7692 def expr (self ):
@@ -81,16 +97,17 @@ def expr(self):
8197class PropertiesList (Properties ):
8298 """PropertiesList for use in workflow expressions."""
8399
84- def __init__ (self , path : str , shape_name : str = None ):
100+ def __init__ (self , path : str , shape_name : str = None , service_name : str = "sagemaker" ):
85101 """Create a PropertiesList instance representing the given shape.
86102
87103 Args:
88104 path (str): The parent path of the PropertiesList instance.
89- shape_name (str): The botocore sagemaker service model shape name.
90- root_shape_name (str): The botocore sagemaker service model shape name.
105+ shape_name (str): The botocore service model shape name.
106+ service_name (str): The botocore service name.
91107 """
92108 super (PropertiesList , self ).__init__ (path , shape_name )
93109 self .shape_name = shape_name
110+ self .service_name = service_name
94111 self ._items : Dict [Union [int , str ], Properties ] = dict ()
95112
96113 def __getitem__ (self , item : Union [int , str ]):
@@ -100,7 +117,7 @@ def __getitem__(self, item: Union[int, str]):
100117 item (Union[int, str]): The index of the item in sequence.
101118 """
102119 if item not in self ._items .keys ():
103- shape = Properties ._shapes .get (self .shape_name )
120+ shape = Properties ._shapes_map . get ( self . service_name , {}) .get (self .shape_name )
104121 member = shape ["member" ]["shape" ]
105122 if isinstance (item , str ):
106123 property_item = Properties (f"{ self ._path } ['{ item } ']" , member )
@@ -114,15 +131,17 @@ def __getitem__(self, item: Union[int, str]):
114131class PropertiesMap (Properties ):
115132 """PropertiesMap for use in workflow expressions."""
116133
117- def __init__ (self , path : str , shape_name : str = None ):
134+ def __init__ (self , path : str , shape_name : str = None , service_name : str = "sagemaker" ):
118135 """Create a PropertiesMap instance representing the given shape.
119136
120137 Args:
121138 path (str): The parent path of the PropertiesMap instance.
122139 shape_name (str): The botocore sagemaker service model shape name.
140+ service_name (str): The botocore service name.
123141 """
124142 super (PropertiesMap , self ).__init__ (path , shape_name )
125143 self .shape_name = shape_name
144+ self .service_name = service_name
126145 self ._items : Dict [Union [int , str ], Properties ] = dict ()
127146
128147 def __getitem__ (self , item : Union [int , str ]):
@@ -132,7 +151,7 @@ def __getitem__(self, item: Union[int, str]):
132151 item (Union[int, str]): The index of the item in sequence.
133152 """
134153 if item not in self ._items .keys ():
135- shape = Properties ._shapes .get (self .shape_name )
154+ shape = Properties ._shapes_map . get ( self . service_name , {}) .get (self .shape_name )
136155 member = shape ["value" ]["shape" ]
137156 if isinstance (item , str ):
138157 property_item = Properties (f"{ self ._path } ['{ item } ']" , member )
0 commit comments