Skip to content

Commit 798299a

Browse files
authored
change: enable attribute-defined-outside-init Pylint check (#933)
The logic behind this rule is to improve readability by defining all the attributes of a class inside the init function, even if it simply sets them to None.
1 parent 1b4c2b1 commit 798299a

File tree

8 files changed

+19
-3
lines changed

8 files changed

+19
-3
lines changed

.pylintrc

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ disable=
8484
line-too-long, # We let Flake8 take care of this # TODO: Fix these and stop relying on flake8
8585
len-as-condition, # TODO: Enable this check once pylint 2.4.0 is released and consumed due to the fix in https://github.com/PyCQA/pylint/issues/2684
8686
import-error, # Since we run Pylint before any of our builds in tox, this will always fail
87-
attribute-defined-outside-init, # TODO: Fix scope
8887
protected-access, # TODO: Fix access
8988
abstract-method, # TODO: Fix abstract methods
9089
wrong-import-order, # TODO: Fix import order

src/sagemaker/amazon/amazon_estimator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555
data_location = data_location or "s3://{}/sagemaker-record-sets/".format(
5656
self.sagemaker_session.default_bucket()
5757
)
58-
self.data_location = data_location
58+
self._data_location = data_location
5959

6060
def train_image(self):
6161
return get_image_uri(

src/sagemaker/analytics.py

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class AnalyticsMetricsBase(with_metaclass(ABCMeta, object)):
3737
Understands common functionality like persistence and caching.
3838
"""
3939

40+
def __init__(self):
41+
self._dataframe = None
42+
4043
def export_csv(self, filename):
4144
"""Persists the analytics dataframe to a file.
4245
@@ -88,6 +91,9 @@ def __init__(self, hyperparameter_tuning_job_name, sagemaker_session=None):
8891
sagemaker_session = sagemaker_session or Session()
8992
self._sage_client = sagemaker_session.sagemaker_client
9093
self._tuning_job_name = hyperparameter_tuning_job_name
94+
self._tuning_job_describe_result = None
95+
self._training_job_summaries = None
96+
super(HyperparameterTuningJobAnalytics, self).__init__()
9197
self.clear_cache()
9298

9399
@property
@@ -240,6 +246,8 @@ def __init__(
240246
self._metric_names = metric_names
241247
else:
242248
self._metric_names = self._metric_names_for_training_job()
249+
250+
super(TrainingJobAnalytics, self).__init__()
243251
self.clear_cache()
244252

245253
@property

src/sagemaker/estimator.py

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def __init__(
166166
self.output_path = output_path
167167
self.output_kms_key = output_kms_key
168168
self.latest_training_job = None
169+
self.deploy_instance_type = None
169170

170171
self._compiled_models = {}
171172

@@ -1086,6 +1087,8 @@ def __init__(
10861087
self.image_name = image_name
10871088
self._enable_network_isolation = enable_network_isolation
10881089

1090+
self.uploaded_code = None
1091+
10891092
self._hyperparameters = hyperparameters or {}
10901093

10911094
def enable_network_isolation(self):

src/sagemaker/local/entities.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def start(self, input_data_config, output_data_config, hyperparameters, job_name
7575
self.model_artifacts = self.container.train(
7676
input_data_config, output_data_config, hyperparameters, job_name
7777
)
78-
self.end = datetime.datetime.now()
78+
self.end_time = datetime.datetime.now()
7979
self.state = self._COMPLETED
8080

8181
def describe(self):
@@ -110,6 +110,9 @@ def __init__(self, transform_job_name, model_name, local_session=None):
110110
self.start_time = None
111111
self.end_time = None
112112
self.batch_strategy = None
113+
self.transform_resources = None
114+
self.input_data = None
115+
self.output_data = None
113116
self.environment = {}
114117
self.state = _LocalTransformJob._CREATING
115118

src/sagemaker/model.py

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def __init__(
100100
self.vpc_config = vpc_config
101101
self.sagemaker_session = sagemaker_session
102102
self._model_name = None
103+
self.endpoint_name = None
103104
self._is_compiled_model = False
104105
self._enable_network_isolation = enable_network_isolation
105106

src/sagemaker/pipeline.py

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def __init__(
5151
self.vpc_config = vpc_config
5252
self.sagemaker_session = sagemaker_session
5353
self._model_name = None
54+
self.endpoint_name = None
5455

5556
def pipeline_container_def(self, instance_type):
5657
"""Return a dict created by ``sagemaker.pipeline_container_def()`` for deploying this model to a specified

src/sagemaker/tuner.py

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def __init__(
247247
self.latest_tuning_job = None
248248
self.warm_start_config = warm_start_config
249249
self.early_stopping_type = early_stopping_type
250+
self.static_hyperparameters = None
250251

251252
def _prepare_for_training(self, job_name=None, include_cls_metadata=False):
252253
if job_name is not None:

0 commit comments

Comments
 (0)