Opening this issue on behalf of a SageMaker customer. The customer has pre-compressed and uploaded their source_dir to S3, and wants to set requirements_file to a relative path contained in the source.
The generic Frameworks Estimator allows source_dir to be an S3 location. In this case it skips validation/upload.
Skipping source_dir validation:
| # validate source dir will raise a ValueError if there is something wrong with the |
| # source directory. We are intentionally not handling it because this is a critical error. |
| ifself.source_dirandnotself.source_dir.lower().startswith('s3://'): |
| validate_source_dir(self.entry_point, self.source_dir) |
Skipping
source_dir upload:
| If directory is an S3 URI, an UploadedCode object will be returned, but nothing will be |
| uploaded to S3 (this allow reuse of code already in S3). |
However the Tensorflow Estimator runs a validation for requirements_file which fails if the location source_dir/requirements_file is not a valid path on the local os:
| def_validate_requirements_file(self, requirements_file): |
| ifnotrequirements_file: |
| return |
| |
| ifnotself.source_dir: |
| raiseValueError('Must specify source_dir along with a requirements file.') |
| |
| ifos.path.isabs(requirements_file): |
| raiseValueError('Requirements file {} is not a path relative to source_dir.'.format( |
| requirements_file)) |
| |
| ifnotos.path.exists(os.path.join(self.source_dir, requirements_file)): |
| raiseValueError('Requirements file {} does not exist.'.format(requirements_file)) |
Seems like it would be easy to skip the local path validation if source_dir is an S3 location. Something like this could be added to _validate_requirements_file:
if source_dir.lower().startswith('s3://'):
return
I know that support for requirements.txt files is limited between the "legacy" TensorFlow container and the newer "script mode" version. But this is a small bug in the SDK which could easily be fixed.
Opening this issue on behalf of a SageMaker customer. The customer has pre-compressed and uploaded their
source_dirto S3, and wants to setrequirements_fileto a relative path contained in the source.The generic Frameworks Estimator allows
source_dirto be an S3 location. In this case it skips validation/upload.Skipping
source_dirvalidation:sagemaker-python-sdk/src/sagemaker/estimator.py
Lines 830 to 833 in 8b33a30
Skipping
source_dirupload:sagemaker-python-sdk/src/sagemaker/fw_utils.py
Lines 143 to 144 in 8b33a30
However the Tensorflow Estimator runs a validation for
requirements_filewhich fails if the locationsource_dir/requirements_fileis not a valid path on the local os:sagemaker-python-sdk/src/sagemaker/tensorflow/estimator.py
Lines 273 to 285 in 8b33a30
Seems like it would be easy to skip the local path validation if
source_diris an S3 location. Something like this could be added to_validate_requirements_file:I know that support for
requirements.txtfiles is limited between the "legacy" TensorFlow container and the newer "script mode" version. But this is a small bug in the SDK which could easily be fixed.