Skip to content

Commit 72e4266

Browse files
beniericpintaoz-aws
authored andcommitted
Cleanup ModelTrainer (#1542)
1 parent 4fe8738 commit 72e4266

File tree

8 files changed

+206
-236
lines changed

8 files changed

+206
-236
lines changed

src/sagemaker/modules/scripts/environment.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""This module is used to define the environment variables for the training job container."""
14-
1514
from __future__ import absolute_import
1615

1716
from typing import Dict, Any

src/sagemaker/modules/scripts/intelligent_params.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
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+
"""This module is used to set intelligent parameters for all python files under the given path."""
14+
from __future__ import absolute_import
15+
116
import argparse
217
import json
318
import os
@@ -7,8 +22,8 @@
722

823

924
def set_intelligent_params(path: str) -> None:
10-
"""
11-
Set intelligent parameters for all python files under the given path.
25+
"""Set intelligent parameters for all python files under the given path.
26+
1227
For python code with comment sm_hyper_param or sm_hp_{variable_name}, the value will be found in
1328
/opt/ml/input/config/hyperparameters.json, and this function will rewrite lines with these comments.
1429
@@ -25,8 +40,7 @@ def set_intelligent_params(path: str) -> None:
2540

2641

2742
def rewrite_file(file_path: str, hyperparameters: dict) -> None:
28-
"""
29-
Rewrite a single python file with intelligent parameters.
43+
"""Rewrite a single python file with intelligent parameters.
3044
3145
Args:
3246
file_path (str): The file path to rewrite
@@ -41,8 +55,7 @@ def rewrite_file(file_path: str, hyperparameters: dict) -> None:
4155

4256

4357
def rewrite_line(line: str, hyperparameters: dict) -> None:
44-
"""
45-
Rewrite a single line of python code with intelligent parameters.
58+
"""Rewrite a single line of python code with intelligent parameters.
4659
4760
Args:
4861
line (str): The python code to rewrite
@@ -70,8 +83,7 @@ def rewrite_line(line: str, hyperparameters: dict) -> None:
7083

7184

7285
def get_parameter_value(variable: str, comment: str, hyperparameters: dict) -> None:
73-
"""
74-
Get the parameter value by the variable name and comment.
86+
"""Get the parameter value by the variable name and comment.
7587
7688
Args:
7789
variable (str): The variable name

0 commit comments

Comments
 (0)