Skip to content

Commit 273449c

Browse files
committed
fix: Reverting name change for code coverage
1 parent 8b0ec90 commit 273449c

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/sagemaker/jumpstart/hub/parser_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing import Any, Dict, List, Optional
1919

2020

21-
def pascal_to_snake(camel_case_string: str) -> str:
21+
def camel_to_snake(camel_case_string: str) -> str:
2222
"""Converts PascalCase to snake_case_string using a regex.
2323
2424
This regex cannot handle whitespace ("PascalString TwoWords")

src/sagemaker/jumpstart/hub/parsers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
HubModelDocument,
2828
)
2929
from sagemaker.jumpstart.hub.parser_utils import (
30-
pascal_to_snake,
30+
camel_to_snake,
3131
snake_to_upper_camel,
3232
walk_and_apply_json,
3333
)
@@ -86,7 +86,7 @@ def get_model_spec_arg_keys(
8686
arg_keys = []
8787

8888
if naming_convention == NamingConventionType.SNAKE_CASE:
89-
arg_keys = [pascal_to_snake(key) for key in arg_keys]
89+
arg_keys = [camel_to_snake(key) for key in arg_keys]
9090
elif naming_convention == NamingConventionType.UPPER_CAMEL_CASE:
9191
return arg_keys
9292
else:
@@ -207,7 +207,7 @@ def make_model_specs_from_describe_hub_content_response(
207207
default_payloads: Dict[str, Any] = {}
208208
if hub_model_document.default_payloads is not None:
209209
for alias, payload in hub_model_document.default_payloads.items():
210-
default_payloads[alias] = walk_and_apply_json(payload.to_json(), pascal_to_snake)
210+
default_payloads[alias] = walk_and_apply_json(payload.to_json(), camel_to_snake)
211211
specs["default_payloads"] = default_payloads
212212
specs["gated_bucket"] = hub_model_document.gated_bucket
213213
specs["inference_volume_size"] = hub_model_document.inference_volume_size

src/sagemaker/jumpstart/types.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from sagemaker.compute_resource_requirements.resource_requirements import ResourceRequirements
4040
from sagemaker.enums import EndpointType
4141
from sagemaker.jumpstart.hub.parser_utils import (
42-
pascal_to_snake,
42+
camel_to_snake,
4343
walk_and_apply_json,
4444
)
4545

@@ -239,7 +239,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None:
239239
return
240240

241241
if self._is_hub_content:
242-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
242+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
243243

244244
self.framework = json_obj.get("framework")
245245
self.framework_version = json_obj.get("framework_version")
@@ -293,7 +293,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None:
293293
"""
294294

295295
if self._is_hub_content:
296-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
296+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
297297
self.name = json_obj["name"]
298298
self.type = json_obj["type"]
299299
self.default = json_obj["default"]
@@ -361,7 +361,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None:
361361
Args:
362362
json_obj (Dict[str, Any]): Dictionary representation of environment variable.
363363
"""
364-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
364+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
365365
self.name = json_obj["name"]
366366
self.type = json_obj["type"]
367367
self.default = json_obj["default"]
@@ -411,7 +411,7 @@ def from_json(self, json_obj: Optional[Dict[str, Any]]) -> None:
411411
return
412412

413413
if self._is_hub_content:
414-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
414+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
415415
self.default_content_type = json_obj["default_content_type"]
416416
self.supported_content_types = json_obj["supported_content_types"]
417417
self.default_accept_type = json_obj["default_accept_type"]
@@ -465,7 +465,7 @@ def from_json(self, json_obj: Optional[Dict[str, Any]]) -> None:
465465
return
466466

467467
if self._is_hub_content:
468-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
468+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
469469
self.raw_payload = json_obj
470470
self.content_type = json_obj["content_type"]
471471
self.body = json_obj.get("body")
@@ -538,7 +538,7 @@ def from_describe_hub_content_response(self, response: Optional[Dict[str, Any]])
538538
if response is None:
539539
return
540540

541-
response = walk_and_apply_json(response, pascal_to_snake)
541+
response = walk_and_apply_json(response, camel_to_snake)
542542
self.aliases: Optional[dict] = response.get("aliases")
543543
self.regional_aliases = None
544544
self.variants: Optional[dict] = response.get("variants")
@@ -1174,7 +1174,7 @@ def __init__(self, spec: Optional[Dict[str, Any]], is_hub_content=False):
11741174
spec (Dict[str, Any]): Dictionary representation of training config ranking.
11751175
"""
11761176
if is_hub_content:
1177-
spec = walk_and_apply_json(spec, pascal_to_snake)
1177+
spec = walk_and_apply_json(spec, camel_to_snake)
11781178
self.from_json(spec)
11791179

11801180
def from_json(self, json_obj: Dict[str, Any]) -> None:
@@ -1280,7 +1280,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None:
12801280
json_obj (Dict[str, Any]): Dictionary representation of spec.
12811281
"""
12821282
if self._is_hub_content:
1283-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
1283+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
12841284
self.model_id: str = json_obj.get("model_id")
12851285
self.url: str = json_obj.get("url")
12861286
self.version: str = json_obj.get("version")
@@ -1509,7 +1509,7 @@ def __init__(
15091509
ValueError: If the component field is invalid.
15101510
"""
15111511
if is_hub_content:
1512-
component = walk_and_apply_json(component, pascal_to_snake)
1512+
component = walk_and_apply_json(component, camel_to_snake)
15131513
self.component_name = component_name
15141514
super().__init__(component, is_hub_content)
15151515
self.from_json(component)
@@ -1562,8 +1562,8 @@ def __init__(
15621562
The list of components that are used to construct the resolved config.
15631563
"""
15641564
if is_hub_content:
1565-
config = walk_and_apply_json(config, pascal_to_snake)
1566-
base_fields = walk_and_apply_json(base_fields, pascal_to_snake)
1565+
config = walk_and_apply_json(config, camel_to_snake)
1566+
base_fields = walk_and_apply_json(base_fields, camel_to_snake)
15671567
self.base_fields = base_fields
15681568
self.config_components: Dict[str, JumpStartConfigComponent] = config_components
15691569
self.benchmark_metrics: Dict[str, List[JumpStartBenchmarkStat]] = (
@@ -1729,7 +1729,7 @@ def from_json(self, json_obj: Dict[str, Any]) -> None:
17291729
"""
17301730
super().from_json(json_obj)
17311731
if self._is_hub_content:
1732-
json_obj = walk_and_apply_json(json_obj, pascal_to_snake)
1732+
json_obj = walk_and_apply_json(json_obj, camel_to_snake)
17331733
self.inference_config_components: Optional[Dict[str, JumpStartConfigComponent]] = (
17341734
{
17351735
component_name: JumpStartConfigComponent(component_name, component)

src/sagemaker/jumpstart/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
from sagemaker.jumpstart import constants, enums
3535
from sagemaker.jumpstart import accessors
36-
from sagemaker.jumpstart.hub.parser_utils import pascal_to_snake, snake_to_upper_camel
36+
from sagemaker.jumpstart.hub.parser_utils import camel_to_snake, snake_to_upper_camel
3737
from sagemaker.s3 import parse_s3_url
3838
from sagemaker.jumpstart.exceptions import (
3939
DeprecatedJumpStartModelError,
@@ -1149,7 +1149,7 @@ def get_jumpstart_configs(
11491149
return (
11501150
{
11511151
config_name: metadata_configs.configs[
1152-
pascal_to_snake(snake_to_upper_camel(config_name))
1152+
camel_to_snake(snake_to_upper_camel(config_name))
11531153
]
11541154
for config_name in config_names
11551155
}

tests/unit/sagemaker/jumpstart/hub/test_parser_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313
from __future__ import absolute_import
1414
import pytest
15-
from sagemaker.jumpstart.hub.parser_utils import pascal_to_snake
15+
from sagemaker.jumpstart.hub.parser_utils import camel_to_snake
1616

1717
REGION = "us-east-1"
1818
ACCOUNT_ID = "123456789123"
@@ -31,4 +31,4 @@
3131
],
3232
)
3333
def test_parse_(input_string, expected):
34-
assert expected == pascal_to_snake(input_string)
34+
assert expected == camel_to_snake(input_string)

tests/unit/sagemaker/jumpstart/hub/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_walk_and_apply_json():
268268
}
269269

270270
result = parser_utils.walk_and_apply_json(
271-
test_json, parser_utils.pascal_to_snake, ["ignore_my_children"]
271+
test_json, parser_utils.camel_to_snake, ["ignore_my_children"]
272272
)
273273
assert result == {
274274
"camel_case_key": "value",
@@ -294,7 +294,7 @@ def test_walk_and_apply_json_no_stop():
294294
"CamelCaseObjectListKey": {"instance.ml.type.xlarge": [{"ShouldChangeMe": "string"}]},
295295
}
296296

297-
result = parser_utils.walk_and_apply_json(test_json, parser_utils.pascal_to_snake)
297+
result = parser_utils.walk_and_apply_json(test_json, parser_utils.camel_to_snake)
298298
assert result == {
299299
"camel_case_key": "value",
300300
"camel_case_object_key": {

0 commit comments

Comments
 (0)