Skip to content

Commit e7b8154

Browse files
committed
fix formatting/linting suggestions
1 parent c74ca68 commit e7b8154

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

src/sagemaker/djl_inference/djl_predictor.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Default Predictor for JSON inputs/outputs used with DJL LMI containers"""
14+
from __future__ import absolute_import
115
from sagemaker.predictor import Predictor
216
from sagemaker import Session
317
from sagemaker.serializers import BaseSerializer, JSONSerializer

src/sagemaker/djl_inference/model.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
def _set_env_var_from_property(
2929
property_value: Optional[Any], env_key: str, env: dict, override_env_var=False
3030
) -> dict:
31+
"""Utility method to set an environment variable configuration"""
3132
if not property_value:
3233
return env
3334
if override_env_var or env_key not in env:
@@ -129,20 +130,23 @@ def __init__(
129130
self._initialize_model()
130131

131132
def _initialize_model(self):
133+
"""Placeholder docstring"""
132134
self._validate_model_artifacts()
133135
self.engine = self._infer_engine()
134136
self.env = self._configure_environment_variables()
135137
self.image_uri = self._infer_image_uri()
136138

137139
def _validate_model_artifacts(self):
140+
"""Placeholder docstring"""
138141
if self.model_id is not None and self.model_data is not None:
139142
raise ValueError(
140143
"both model_id and model_data are provided. Please only provide one of them"
141144
)
142145

143146
def _infer_engine(self) -> Optional[str]:
147+
"""Placeholder docstring"""
144148
if self.engine is not None:
145-
logger.info(f"Using provided engine {self.engine}")
149+
logger.info("Using provided engine %s", self.engine)
146150
return self.engine
147151

148152
if self.task is not None:
@@ -151,6 +155,7 @@ def _infer_engine(self) -> Optional[str]:
151155
return "Python"
152156

153157
def _infer_image_uri(self):
158+
"""Placeholder docstring"""
154159
if self.image_uri is not None:
155160
return self.image_uri
156161
if self.djl_framework is None:
@@ -162,6 +167,7 @@ def _infer_image_uri(self):
162167
)
163168

164169
def _configure_environment_variables(self) -> Dict[str, str]:
170+
"""Placeholder docstring"""
165171
env = self.env.copy() if self.env else {}
166172
env = _set_env_var_from_property(self.model_id, "HF_MODEL_ID", env)
167173
env = _set_env_var_from_property(self.task, "HF_TASK", env)
@@ -188,6 +194,7 @@ def serving_image_uri(
188194
accelerator_type=None,
189195
serverless_inference_config=None,
190196
):
197+
"""Placeholder docstring"""
191198
if self.image_uri:
192199
return self.image_uri
193200
return image_uris.retrieve(

src/sagemaker/serve/builder/djl_builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def _build_for_hf_djl(self):
255255
self.schema_builder.sample_input["parameters"][
256256
"max_new_tokens"
257257
] = _default_max_new_tokens
258-
logger.info(f"env vars are {self.env_vars}")
259258
self.pysdk_model = self._create_djl_model()
260259

261260
if self.mode == Mode.LOCAL_CONTAINER:

src/sagemaker/serve/utils/hf_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""Utility functions for fetching model information from HuggingFace Hub"""
14+
from __future__ import absolute_import
115
import json
216
import urllib.request
317
from json import JSONDecodeError

tests/unit/test_djl_inference.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
# language governing permissions and limitations under the License.
1313
from __future__ import absolute_import
1414

15-
import json
16-
from json import JSONDecodeError
17-
1815
import pytest
19-
from mock import Mock, MagicMock
20-
from mock import patch
16+
from mock import Mock
2117

2218
from sagemaker.djl_inference import (
2319
DJLModel,

0 commit comments

Comments
 (0)