title: Change model file save location on AWS SageMaker Training Job
body: <p>I am trying to run custom python/sklearn sagemaker script on AWS, basically learning from these examples: <a href="https://github.com/aws/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/scikit_learn_randomforest/Sklearn_on_SageMaker_end2end.ipynb" rel="nofollow noreferrer">https://github.com/aws/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/scikit_learn_randomforest/Sklearn_on_SageMaker_end2end.ipynb</a></p>
  <p>All works fine, if define the arguments, train the model and output the file:</p>
  <pre><code>parser.add_argument('--model-dir', type=str, default=os.environ.get('SM_MODEL_DIR'))
  parser.add_argument('--train', type=str, default=os.environ.get('SM_CHANNEL_TRAIN'))
  parser.add_argument('--test', type=str, default=os.environ.get('SM_CHANNEL_TEST'))
  
  # train the model...
  
  joblib.dump(model, os.path.join(args.model_dir, &quot;model.joblib&quot;))
  </code></pre>
  <p>And call the job with:</p>
  <pre><code>aws_sklearn.fit({'train': 's3://path/to/train', 'test': 's3://path/to/test'}, wait=False)
  </code></pre>
  <p>In this case model gets stored on different auto-generated bucket, which I do not want. I want to get the output (.joblib file) in the same s3 bucket I took data from. So I add the parameter <code>model-dir</code>:</p>
  <pre><code>aws_sklearn.fit({'train': 's3://path/to/train', 'test': 's3://path/to/test', `model-dir`: 's3://path/to/model'}, wait=False)
  </code></pre>
  <p>But it results in error:
  <code>FileNotFoundError: [Errno 2] No such file or directory: 's3://path/to/model/model.joblib'</code></p>
  <p>Same happens if I hardcode the output path inside the training script.</p>
  <p>So the main question, how can I get the output file in the bucket of my choice?</p>