@@ -110,21 +110,21 @@ def has_condition(conditions: List[models.V1JobCondition], condition_type: str)
110
110
111
111
112
112
def get_script_for_python_packages (
113
- packages_to_install : List [str ], pip_index_url : str
113
+ packages_to_install : List [str ], pip_index_url : str , pip_args : Optional [ List [ str ]]
114
114
) -> str :
115
115
"""
116
116
Get init script to install Python packages from the given pip index URL.
117
117
"""
118
118
packages_str = " " .join ([str (package ) for package in packages_to_install ])
119
-
119
+ pip_args_str = " " . join ( pip_args ) if pip_args is not None else ""
120
120
script_for_python_packages = textwrap .dedent (
121
121
f"""
122
122
if ! [ -x "$(command -v pip)" ]; then
123
123
python -m ensurepip || python -m ensurepip --user || apt-get install python-pip
124
124
fi
125
125
126
126
PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install --quiet \
127
- --no-warn-script-location --index-url { pip_index_url } { packages_str }
127
+ --no-warn-script-location --index-url { pip_index_url } { pip_args_str } { packages_str }
128
128
"""
129
129
)
130
130
@@ -137,6 +137,7 @@ def get_command_using_train_func(
137
137
train_func_parameters : Optional [Dict [str , Any ]] = None ,
138
138
packages_to_install : Optional [List [str ]] = None ,
139
139
pip_index_url : str = constants .DEFAULT_PIP_INDEX_URL ,
140
+ pip_args : Optional [List [str ]] = None
140
141
) -> Tuple [List [str ], List [str ]]:
141
142
"""
142
143
Get container args and command from the given training function and parameters.
@@ -180,7 +181,7 @@ def get_command_using_train_func(
180
181
# Install Python packages if that is required.
181
182
if packages_to_install is not None :
182
183
exec_script = (
183
- get_script_for_python_packages (packages_to_install , pip_index_url )
184
+ get_script_for_python_packages (packages_to_install , pip_index_url , pip_args )
184
185
+ exec_script
185
186
)
186
187
0 commit comments