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
+
1
16
import argparse
2
17
import json
3
18
import os
7
22
8
23
9
24
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
+
12
27
For python code with comment sm_hyper_param or sm_hp_{variable_name}, the value will be found in
13
28
/opt/ml/input/config/hyperparameters.json, and this function will rewrite lines with these comments.
14
29
@@ -25,8 +40,7 @@ def set_intelligent_params(path: str) -> None:
25
40
26
41
27
42
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.
30
44
31
45
Args:
32
46
file_path (str): The file path to rewrite
@@ -41,8 +55,7 @@ def rewrite_file(file_path: str, hyperparameters: dict) -> None:
41
55
42
56
43
57
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.
46
59
47
60
Args:
48
61
line (str): The python code to rewrite
@@ -70,8 +83,7 @@ def rewrite_line(line: str, hyperparameters: dict) -> None:
70
83
71
84
72
85
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.
75
87
76
88
Args:
77
89
variable (str): The variable name
0 commit comments