Skip to content

change: Format and add missing docstring placeholders #945

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 1 commit into from
Jul 18, 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 @@ -92,7 +92,6 @@ disable=
cyclic-import, # TODO: Resolve cyclic imports
no-self-use, # TODO: Convert methods to functions where appropriate
too-many-branches, # TODO: Simplify or ignore as appropriate
missing-docstring, # TODO: Fix missing docstring

[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
Expand Down
5 changes: 5 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Placeholder docstring"""
from __future__ import absolute_import

import os
Expand All @@ -22,6 +23,10 @@
class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
"""
Args:
name:
"""
if name == "__version__":
return "1.4.0"
else:
Expand Down
26 changes: 15 additions & 11 deletions examples/cli/host/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@


def model_fn(model_dir):
"""
Load the gluon model. Called once when hosting service starts.
"""Load the gluon model. Called once when hosting service starts.

Args:
model_dir: The directory where model files are stored.

:param: model_dir The directory where model files are stored.
:return: a model (in this case a Gluon network)
Returns:
a model (in this case a Gluon network)
"""
symbol = mx.sym.load("%s/model.json" % model_dir)
outputs = mx.symbol.softmax(data=symbol, name="softmax_label")
Expand All @@ -22,14 +24,16 @@ def model_fn(model_dir):


def transform_fn(net, data, input_content_type, output_content_type):
"""
Transform a request using the Gluon model. Called once per request.
"""Transform a request using the Gluon model. Called once per request.

Args:
net: The Gluon model.
data: The request payload.
input_content_type: The request content type.
output_content_type: The (desired) response content type.

:param net: The Gluon model.
:param data: The request payload.
:param input_content_type: The request content type.
:param output_content_type: The (desired) response content type.
:return: response payload and content type.
Returns:
response payload and content type.
"""
# we can use content types to vary input/output handling, but
# here we just assume json for both
Expand Down
32 changes: 32 additions & 0 deletions examples/cli/train/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
def train(channel_input_dirs, hyperparameters, **kwargs):
# SageMaker passes num_cpus, num_gpus and other args we can use to tailor training to
# the current container environment, but here we just use simple cpu context.
"""
Args:
channel_input_dirs:
hyperparameters:
**kwargs:
"""
ctx = mx.cpu()

# retrieve the hyperparameters we set in notebook (with some defaults)
Expand Down Expand Up @@ -80,6 +86,11 @@ def train(channel_input_dirs, hyperparameters, **kwargs):

def save(net, model_dir):
# save the model
"""
Args:
net:
model_dir:
"""
y = net(mx.sym.var("data"))
y.save("%s/model.json" % model_dir)
net.collect_params().save("%s/model.params" % model_dir)
Expand All @@ -95,11 +106,21 @@ def define_network():


def input_transformer(data, label):
"""
Args:
data:
label:
"""
data = data.reshape((-1,)).astype(np.float32) / 255
return data, label


def get_train_data(data_dir, batch_size):
"""
Args:
data_dir:
batch_size:
"""
return gluon.data.DataLoader(
gluon.data.vision.MNIST(data_dir, train=True, transform=input_transformer),
batch_size=batch_size,
Expand All @@ -109,6 +130,11 @@ def get_train_data(data_dir, batch_size):


def get_val_data(data_dir, batch_size):
"""
Args:
data_dir:
batch_size:
"""
return gluon.data.DataLoader(
gluon.data.vision.MNIST(data_dir, train=False, transform=input_transformer),
batch_size=batch_size,
Expand All @@ -117,6 +143,12 @@ def get_val_data(data_dir, batch_size):


def test(ctx, net, val_data):
"""
Args:
ctx:
net:
val_data:
"""
metric = mx.metric.Accuracy()
for data, label in val_data:
data = data.as_in_context(ctx)
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Placeholder docstring"""
from __future__ import absolute_import

import os
Expand All @@ -20,6 +21,10 @@


def read(fname):
"""
Args:
fname:
"""
return open(os.path.join(os.path.dirname(__file__), fname)).read()


Expand Down
1 change: 1 addition & 0 deletions src/sagemaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Placeholder docstring"""
from __future__ import absolute_import

import pkg_resources
Expand Down
Loading