Skip to content

Commit 9695cd5

Browse files
committed
add details about env variables
1 parent 9f97499 commit 9695cd5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/sagemaker/mxnet/README.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,16 @@ The code executed from your main guard needs to:
599599
3. Save the model
600600

601601
Hyperparameters will be passed as command-line arguments to your training script.
602-
In addition, the locations for finding input data and saving the model and output data will need to be defined.
602+
In addition, the locations for finding input data and saving the model and output data will be provided as environment variables rather than as arguments to a function.
603+
You can find the full list of available environment variables in the `SageMaker Containers README <https://github.com/aws/sagemaker-containers#list-of-provided-environment-variables-by-sagemaker-containers>`__.
604+
603605
We recommend using `an argument parser <https://docs.python.org/3.5/howto/argparse.html>`__ for this part.
604606
Using the ``argparse`` library as an example, the code would look something like this:
605607

606608
.. code:: python
607609
608610
import argparse
611+
import os
609612
610613
if __name__ == '__main__':
611614
parser = argparse.ArgumentParser()
@@ -616,9 +619,9 @@ Using the ``argparse`` library as an example, the code would look something like
616619
parser.add_argument('--learning-rate', type=float, default=0.1)
617620
618621
# input data and model directories
619-
parser.add_argument('--model-dir', type=str, default='opt/ml/model')
620-
parser.add_argument('--train', type=str, default='opt/ml/input/data/train')
621-
parser.add_argument('--test', type=str, default='opt/ml/input/data/test')
622+
parser.add_argument('--model-dir', type=str, default=os.environ['SM_MODEL_DIR'])
623+
parser.add_argument('--train', type=str, default=os.environ['SM_CHANNEL_TRAIN'])
624+
parser.add_argument('--test', type=str, default=os.environ['SM_CHANNEL_TEST'])
622625
623626
args, _ = parser.parse_known_args()
624627

0 commit comments

Comments
 (0)