Skip to content

Add support for additional files #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed

Conversation

mvsusp
Copy link
Contributor

@mvsusp mvsusp commented Nov 16, 2018

Issue #, if available:

Description of changes:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have updated the changelog with a description of my changes (if appropriate)
  • I have updated any necessary documentation (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mvsusp mvsusp changed the title [WIP] Add support for additional files Add support for additional files Nov 16, 2018
@mvsusp mvsusp requested review from nadiaya and iquintero November 16, 2018 14:07
directory are preserved when training on Amazon SageMaker.
source_dir (str or [str]): Single path (absolute or relative) or a list of paths to directories with
any other training source code dependencies aside from the entry point file (default: None).
The structures within this directories are preserved when training on Amazon SageMaker.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these directories

source_dir (str): Path (absolute or relative) to a directory with any other training
source code dependencies aside from tne entry point file (default: None). Structure within this
directory are preserved when training on Amazon SageMaker.
source_dir (str or [str]): Single path (absolute or relative) or a list of paths to directories with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be more explicit and use list[str] for lists. also I'd change it to "A single path"

source code dependencies aside from tne entry point file (default: None). Structure within this
directory are preserved when training on Amazon SageMaker.
source_dir (str or [str]): Single path (absolute or relative) or a list of paths to directories with
any other training source code dependencies aside from the entry point file (default: None).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this line to "any source code (other than the entry point file) needed for training"

directory are preserved when training on Amazon SageMaker.
source_dir (str or [str]): Single path (absolute or relative) or a list of paths to directories with
any other training source code dependencies aside from the entry point file (default: None).
The structures within this directories are preserved when training on Amazon SageMaker.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we include explanation about the structure of how to access each of the directories? i.e. I assume (but am still reading the PR) that it'll be something like:

| base dir from unpacking the tar
| - source dir 1
| - source dir 2
| - etc.

based on reading the docstring, but it'd be good to be explicit about it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, more documentation and examples would be helpful.

@@ -118,31 +118,43 @@ def tar_and_upload_dir(session, bucket, s3_key_prefix, script, directory):
bucket (str): S3 bucket to which the compressed file is uploaded.
s3_key_prefix (str): Prefix for the S3 key.
script (str): Script filename.
directory (str): Directory containing the source file. If it starts with "s3://", no action is taken.
directory (str or None): Directory containing the source file. If it starts with "s3://", no action is taken.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add additional_files to the docstring

source_files = [os.path.join(directory, name) for name in os.listdir(directory)]
key = '%s/sourcedir.tar.gz' % s3_key_prefix

if directory and directory.lower().startswith("s3://"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quotes for the string

CHANGELOG.rst Outdated
@@ -14,6 +14,7 @@ CHANGELOG
* feature: HyperparameterTuner: Make input channels optional
* feature: Add support for Chainer 5.0
* feature: Estimator: add support for MetricDefinitions
* feature: source_dir accepts a list of directories
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still haven't heard an explanation for why this is useful. why can't user just stage their files properly in a single source dir before creating an estimator?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From someone on the outside looking in, this looks confusing and unneeded. I understand there's probably a (pressing) reason why we want to do this - but it feels like a hack that we're adding to the PythonSDK to overcome a problem in another system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also against this change because of the same reason Jonathan mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User could stage the files before calling the estimator. User can also copy their own code to S3, and not use the estimator. Or they could build their own docker container, and make boto calls instead of using the SDK at all. The point of this project is to make things easier.

os.remove(tar_file)


def _list_root_files(script, directory, additional_files):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not independently unit tested. This logic is confusing (I'm not sure I completely understand it). I suggest unit testing this and providing some developer documentation describing the contract.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am personally against testing private methods, it adds unnecessary coupling to non public facing signatures and does not provide a good grasp of the functionality.

I do agree that testing should be extensive, and cover any edge cases. The tests that I wrote are here https://github.com/aws/sagemaker-python-sdk/pull/494/files#diff-3108f99e19f25f4c77ad4f63d486b174R147

Let me know if you any suggestions of improvement of these methods.

Copy link
Contributor Author

@mvsusp mvsusp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reviews, I will close this PR for now.

directory are preserved when training on Amazon SageMaker.
source_dir (str or [str]): Single path (absolute or relative) or a list of paths to directories with
any other training source code dependencies aside from the entry point file (default: None).
The structures within this directories are preserved when training on Amazon SageMaker.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, more documentation and examples would be helpful.

os.remove(tar_file)


def _list_root_files(script, directory, additional_files):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am personally against testing private methods, it adds unnecessary coupling to non public facing signatures and does not provide a good grasp of the functionality.

I do agree that testing should be extensive, and cover any edge cases. The tests that I wrote are here https://github.com/aws/sagemaker-python-sdk/pull/494/files#diff-3108f99e19f25f4c77ad4f63d486b174R147

Let me know if you any suggestions of improvement of these methods.

@mvsusp mvsusp closed this Nov 16, 2018
@nadiaya nadiaya reopened this Nov 18, 2018
@codecov-io
Copy link

codecov-io commented Nov 18, 2018

Codecov Report

Merging #494 into master will decrease coverage by 0.04%.
The diff coverage is 87.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #494      +/-   ##
==========================================
- Coverage   94.28%   94.24%   -0.05%     
==========================================
  Files          59       59              
  Lines        4551     4567      +16     
==========================================
+ Hits         4291     4304      +13     
- Misses        260      263       +3
Impacted Files Coverage Δ
src/sagemaker/mxnet/estimator.py 100% <ø> (ø) ⬆️
src/sagemaker/chainer/estimator.py 100% <ø> (ø) ⬆️
src/sagemaker/pytorch/estimator.py 100% <ø> (ø) ⬆️
src/sagemaker/fw_utils.py 100% <100%> (ø) ⬆️
src/sagemaker/model.py 93.15% <60%> (-2.51%) ⬇️
src/sagemaker/estimator.py 89.79% <71.42%> (-0.52%) ⬇️
src/sagemaker/tensorflow/estimator.py 95.18% <0%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e37ac12...cf52ca8. Read the comment docs.

@mvsusp mvsusp closed this Nov 19, 2018
ChoiByungWook pushed a commit that referenced this pull request Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants