@@ -104,7 +104,8 @@ def train(self, input_data_config, output_data_config, hyperparameters, job_name
104104 os .mkdir (shared_dir )
105105
106106 data_dir = self ._create_tmp_folder ()
107- volumes = self ._prepare_training_volumes (data_dir , input_data_config , hyperparameters )
107+ volumes = self ._prepare_training_volumes (data_dir , input_data_config , output_data_config ,
108+ hyperparameters )
108109
109110 # Create the configuration files for each container that we will create
110111 # Each container will map the additional local volumes (if any).
@@ -281,7 +282,8 @@ def write_config_files(self, host, hyperparameters, input_data_config):
281282 _write_json_file (os .path .join (config_path , 'resourceconfig.json' ), resource_config )
282283 _write_json_file (os .path .join (config_path , 'inputdataconfig.json' ), json_input_data_config )
283284
284- def _prepare_training_volumes (self , data_dir , input_data_config , hyperparameters ):
285+ def _prepare_training_volumes (self , data_dir , input_data_config , output_data_config ,
286+ hyperparameters ):
285287 shared_dir = os .path .join (self .container_root , 'shared' )
286288 model_dir = os .path .join (self .container_root , 'model' )
287289 volumes = []
@@ -309,6 +311,14 @@ def _prepare_training_volumes(self, data_dir, input_data_config, hyperparameters
309311 # Also mount a directory that all the containers can access.
310312 volumes .append (_Volume (shared_dir , '/opt/ml/shared' ))
311313
314+ parsed_uri = urlparse (output_data_config ['S3OutputPath' ])
315+ if parsed_uri .scheme == 'file' \
316+ and sagemaker .rl .estimator .SAGEMAKER_OUTPUT_LOCATION in hyperparameters :
317+ intermediate_dir = os .path .join (parsed_uri .path , 'output' , 'intermediate' )
318+ if not os .path .exists (intermediate_dir ):
319+ os .makedirs (intermediate_dir )
320+ volumes .append (_Volume (intermediate_dir , '/opt/ml/output/intermediate' ))
321+
312322 return volumes
313323
314324 def _prepare_serving_volumes (self , model_location ):
0 commit comments