Skip to content

change: enable inconsistent-return-statements Pylint check #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ disable=
useless-object-inheritance, # TODO: Remove unnecessary imports
cyclic-import, # TODO: Resolve cyclic imports
no-self-use, # TODO: Convert methods to functions where appropriate
inconsistent-return-statements, # TODO: Make returns consistent
consider-merging-isinstance, # TODO: Merge isinstance where appropriate
consider-using-in, # TODO: Consider merging comparisons with "in"
too-many-public-methods, # TODO: Resolve
Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _prepare_channel(
input_mode=None,
):
if not channel_uri:
return
return None
if not channel_name:
raise ValueError(
"Expected a channel name if a channel URI {} is specified".format(channel_uri)
Expand Down
8 changes: 7 additions & 1 deletion src/sagemaker/local/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,21 @@ def get_data_source_instance(data_source, sagemaker_session):
sagemaker_session (:class:`sagemaker.session.Session`): a SageMaker Session to interact with
S3 if required.

Returns
Returns:
:class:`sagemaker.local.data.DataSource`: an Instance of a Data Source

Raises:
ValueError: If parsed_uri scheme is neither `file` nor `s3`, raise an error.

"""
parsed_uri = urlparse(data_source)
if parsed_uri.scheme == "file":
return LocalFileDataSource(parsed_uri.netloc + parsed_uri.path)
if parsed_uri.scheme == "s3":
return S3DataSource(parsed_uri.netloc, parsed_uri.path, sagemaker_session)
raise ValueError(
"data_source must be either file or s3. parsed_uri.scheme: {}".format(parsed_uri.scheme)
)


def get_splitter_instance(split_type):
Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def deploy(

if self.predictor_cls:
return self.predictor_cls(self.endpoint_name, self.sagemaker_session)
return None

def transformer(
self,
Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def deploy(
)
if self.predictor_cls:
return self.predictor_cls(self.endpoint_name, self.sagemaker_session)
return None

def _create_sagemaker_pipeline_model(self, instance_type):
"""Create a SageMaker Model Entity
Expand Down
5 changes: 5 additions & 0 deletions src/sagemaker/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ def __call__(self, stream, content_type=CONTENT_TYPE_NPY):
return np.load(BytesIO(stream.read()))
finally:
stream.close()
raise ValueError(
"content_type must be one of the following: CSV, JSON, NPY. content_type: {}".format(
content_type
)
)


numpy_deserializer = _NumpyDeserializer()
Expand Down
10 changes: 9 additions & 1 deletion src/sagemaker/rl/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def create_model(
MXNet was used as RL backend;
* sagemaker.tensorflow.serving.Model - if image_name wasn't specified and
TensorFlow was used as RL backend.

Raises:
ValueError: If image_name was not specified and framework enum is not valid.
"""
base_args = dict(
model_data=self.model_data,
Expand Down Expand Up @@ -230,6 +231,9 @@ def create_model(
return MXNetModel(
framework_version=self.framework_version, py_version=PYTHON_VERSION, **extended_args
)
raise ValueError(
"An unknown RLFramework enum was passed in. framework: {}".format(self.framework)
)

def train_image(self):
"""Return the Docker image to use for training.
Expand Down Expand Up @@ -399,6 +403,9 @@ def default_metric_definitions(cls, toolkit):

Returns:
list: metric definitions

Raises:
ValueError: If toolkit enum is not valid.
"""
if toolkit is RLToolkit.COACH:
return [
Expand All @@ -412,3 +419,4 @@ def default_metric_definitions(cls, toolkit):
{"Name": "episode_reward_mean", "Regex": "episode_reward_mean: (%s)" % float_regex},
{"Name": "episode_reward_max", "Regex": "episode_reward_max: (%s)" % float_regex},
]
raise ValueError("An unknown RLToolkit enum was passed in. toolkit: {}".format(toolkit))