Skip to content

Commit ea95f87

Browse files
authored
Merge pull request aws#9 from verdimrc/fp-revert-to-code
FrameworkProcessor: revert `run(entry_point=...)` back to `run(code=...)`
2 parents 4a1c53c + 690b8ae commit ea95f87

File tree

8 files changed

+34
-32
lines changed

8 files changed

+34
-32
lines changed

src/sagemaker/mxnet/processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
5151
Unless ``image_uri`` is specified, the MXNet environment is an
5252
Amazon-built Docker container that executes functions defined in the supplied
53-
``entry_point`` Python script.
53+
``code`` Python script.
5454
5555
The arguments have the exact same meaning as in ``FrameworkProcessor``.
5656

src/sagemaker/processing.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def __init__(
12641264
image_uri (str): The URI of the Docker image to use for the
12651265
processing jobs (default: None).
12661266
command ([str]): The command to run, along with any command-line flags
1267-
to *precede* the ```entry_point script``` (default: ['python']).
1267+
to *precede* the ```code script``` (default: ['python']).
12681268
volume_size_in_gb (int): Size in GB of the EBS volume
12691269
to use for storing data during processing (default: 30).
12701270
volume_kms_key (str): A KMS key for the processing volume (default: None).
@@ -1361,7 +1361,7 @@ def _pre_init_normalization(
13611361

13621362
def run( # type: ignore[override]
13631363
self,
1364-
entry_point,
1364+
code,
13651365
source_dir=None,
13661366
dependencies=None,
13671367
git_config=None,
@@ -1377,9 +1377,9 @@ def run( # type: ignore[override]
13771377
"""Runs a processing job.
13781378
13791379
Args:
1380-
entrypoint (str): Path (absolute or relative) to the local Python source
1380+
code (str): Path (absolute or relative) to the local Python source
13811381
file which should be executed as the entry point to training. If
1382-
``source_dir`` is specified, then ``entry_point`` must point to a file
1382+
``source_dir`` is specified, then ``code`` must point to a file
13831383
located at the root of ``source_dir``.
13841384
source_dir (str): Path (absolute, relative or an S3 URI) to a directory
13851385
with any other training source code dependencies aside from the entry
@@ -1464,9 +1464,7 @@ def run( # type: ignore[override]
14641464
if job_name is None:
14651465
job_name = self._generate_current_job_name()
14661466

1467-
estimator = self._upload_payload(
1468-
entry_point, source_dir, dependencies, git_config, job_name
1469-
)
1467+
estimator = self._upload_payload(code, source_dir, dependencies, git_config, job_name)
14701468
inputs = self._patch_inputs_with_payload(
14711469
inputs, estimator._hyperparameters["sagemaker_submit_directory"]
14721470
)
@@ -1511,13 +1509,14 @@ def _generate_framework_script(self, user_script: str) -> str:
15111509
This script implements the "framework" functionality for setting up your code:
15121510
Untar-ing the sourcedir bundle in the ```code``` input; installing extra
15131511
runtime dependencies if specified; and then invoking the ```command``` and
1514-
```entry_point``` configured for the job.
1512+
```code``` configured for the job.
15151513
15161514
Args:
1517-
user_script (str): Relative path to ```entry_point``` in the source bundle
1515+
user_script (str): Relative path to ```code``` in the source bundle
15181516
- e.g. 'process.py'.
15191517
"""
1520-
return dedent("""\
1518+
return dedent(
1519+
"""\
15211520
#!/bin/bash
15221521
15231522
cd /opt/ml/processing/input/code/
@@ -1529,7 +1528,8 @@ def _generate_framework_script(self, user_script: str) -> str:
15291528
[[ -f 'requirements.txt' ]] && pip install -r requirements.txt
15301529
15311530
{entry_point_command} {entry_point} "$@"
1532-
""").format(
1531+
"""
1532+
).format(
15331533
entry_point_command=" ".join(self.command),
15341534
entry_point=user_script,
15351535
)
@@ -1605,7 +1605,7 @@ def _set_entrypoint(self, command, user_script_name):
16051605
command ([str]): Ignored in favor of self.framework_entrypoint_command
16061606
user_script_name (str): A filename with an extension.
16071607
"""
1608-
1608+
16091609
user_script_location = str(
16101610
pathlib.PurePosixPath(
16111611
self._CODE_CONTAINER_BASE_PATH, self._CODE_CONTAINER_INPUT_NAME, user_script_name

src/sagemaker/pytorch/processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
5151
Unless ``image_uri`` is specified, the PyTorch environment is an
5252
Amazon-built Docker container that executes functions defined in the supplied
53-
``entry_point`` Python script.
53+
``code`` Python script.
5454
5555
The arguments have the exact same meaning as in ``FrameworkProcessor``.
5656

src/sagemaker/sklearn/processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SKLearnProcessor(FrameworkProcessor):
2828
2929
Unless ``image_uri`` is specified, the scikit-learn environment is an
3030
Amazon-built Docker container that executes functions defined in the supplied
31-
``entry_point`` Python script.
31+
``code`` Python script.
3232
3333
The arguments have the exact same meaning as in ``FrameworkProcessor``.
3434

src/sagemaker/tensorflow/processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
5151
Unless ``image_uri`` is specified, the TensorFlow environment is an
5252
Amazon-built Docker container that executes functions defined in the supplied
53-
``entry_point`` Python script.
53+
``code`` Python script.
5454
5555
The arguments have the exact same meaning as in ``FrameworkProcessor``.
5656

src/sagemaker/xgboost/processing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
"""This processor executes a Python script in an XGBoost execution environment.
5050
5151
Unless ``image_uri`` is specified, the XGBoost environment is an Amazon-built
52-
Docker container that executes functions defined in the supplied ``entry_point``
52+
Docker container that executes functions defined in the supplied ``code``
5353
Python script.
5454
5555
The arguments have the exact same meaning as in ``FrameworkProcessor``.

tests/integ/test_processing.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_sklearn(sagemaker_session, sklearn_latest_version, cpu_instance_type):
130130
)
131131

132132
sklearn_processor.run(
133-
entry_point=script_path,
133+
code=script_path,
134134
inputs=[ProcessingInput(source=input_file_path, destination="/opt/ml/processing/inputs/")],
135135
wait=False,
136136
logs=False,
@@ -174,7 +174,7 @@ def test_sklearn_with_customizations(
174174
)
175175

176176
sklearn_processor.run(
177-
entry_point=os.path.join(DATA_DIR, "dummy_script.py"),
177+
code=os.path.join(DATA_DIR, "dummy_script.py"),
178178
inputs=[
179179
ProcessingInput(
180180
source=input_file_path,
@@ -258,7 +258,7 @@ def test_sklearn_with_custom_default_bucket(
258258
)
259259

260260
sklearn_processor.run(
261-
entry_point=os.path.join(DATA_DIR, "dummy_script.py"),
261+
code=os.path.join(DATA_DIR, "dummy_script.py"),
262262
inputs=[
263263
ProcessingInput(
264264
source=input_file_path,
@@ -338,7 +338,7 @@ def test_sklearn_with_no_inputs_or_outputs(
338338
)
339339

340340
sklearn_processor.run(
341-
entry_point=os.path.join(DATA_DIR, "dummy_script.py"),
341+
code=os.path.join(DATA_DIR, "dummy_script.py"),
342342
arguments=["-v"],
343343
wait=True,
344344
logs=True,
@@ -695,7 +695,7 @@ def test_sklearn_with_network_config(sagemaker_session, sklearn_latest_version,
695695
)
696696

697697
sklearn_processor.run(
698-
entry_point=script_path,
698+
code=script_path,
699699
inputs=[ProcessingInput(source=input_file_path, destination="/opt/ml/processing/inputs/")],
700700
wait=False,
701701
logs=False,

tests/unit/test_processing.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def test_sklearn_processor_with_required_parameters(
9292
sagemaker_session=sagemaker_session,
9393
)
9494

95-
processor.run(entry_point="/local/path/to/processing_code.py")
95+
processor.run(code="/local/path/to/processing_code.py")
9696

9797
expected_args = _get_expected_args_modular_code(processor._current_job_name)
9898

@@ -137,7 +137,7 @@ def test_sklearn_with_all_parameters(
137137

138138
with patch("sagemaker.estimator.tar_and_upload_dir", return_value=uploaded_code):
139139
processor.run(
140-
entry_point="processing_code.py",
140+
code="processing_code.py",
141141
source_dir="/local/path/to/source_dir",
142142
dependencies=["/local/path/to/dep_01"],
143143
inputs=_get_data_inputs_all_parameters(),
@@ -200,7 +200,7 @@ def test_sklearn_with_all_parameters_via_run_args(
200200
)
201201

202202
processor.run(
203-
entry_point=run_args.code,
203+
code=run_args.code,
204204
inputs=run_args.inputs,
205205
outputs=run_args.outputs,
206206
arguments=run_args.arguments,
@@ -223,11 +223,11 @@ def test_sklearn_with_all_parameters_via_run_args(
223223
# Verify the alternate command was applied successfully:
224224
framework_script = processor._generate_framework_script("processing_code.py")
225225
expected_invocation = f"{' '.join(custom_command)} processing_code.py"
226-
assert f"\n{expected_invocation}" in framework_script, (
227-
"Framework script should contain customized invocation:\n{}\n\nGot:\n{}".format(
228-
expected_invocation,
229-
framework_script,
230-
)
226+
assert (
227+
f"\n{expected_invocation}" in framework_script
228+
), "Framework script should contain customized invocation:\n{}\n\nGot:\n{}".format(
229+
expected_invocation,
230+
framework_script,
231231
)
232232

233233

@@ -276,7 +276,7 @@ def test_sklearn_with_all_parameters_via_run_args_called_twice(
276276
)
277277

278278
processor.run(
279-
entry_point=run_args.code,
279+
code=run_args.code,
280280
inputs=run_args.inputs,
281281
outputs=run_args.outputs,
282282
arguments=run_args.arguments,
@@ -838,7 +838,9 @@ def _get_data_outputs_all_parameters():
838838
]
839839

840840

841-
def _get_expected_args_all_parameters_modular_code(job_name, code_s3_uri=MOCKED_S3_URI, instance_count=1):
841+
def _get_expected_args_all_parameters_modular_code(
842+
job_name, code_s3_uri=MOCKED_S3_URI, instance_count=1
843+
):
842844
# Add something to inputs
843845
return {
844846
"inputs": [

0 commit comments

Comments
 (0)