Skip to content
This repository was archived by the owner on Aug 26, 2020. It is now read-only.

Support to requirements.txt file - #60

Merged
mvsusp merged 3 commits into
aws:r2.0from
mvsusp:mvs-install-requirement.txt
May 16, 2018
Merged

mvsusp merged 3 commits into
aws:r2.0from
mvsusp:mvs-install-requirement.txt

Conversation

@mvsusp

@mvsusp mvsusp commented May 16, 2018

Copy link
Copy Markdown
Contributor

Description of changes:

  • Create a separate module for errors
  • Install dependencies via requirements.txt or setup.py provide with the user script
  • Fix download and import tests
  • Install additional data files to the package

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

@codecov-io

codecov-io commented May 16, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #60 into r2.0 will decrease coverage by 0.34%.
The diff coverage is 94.73%.

Impacted file tree graph

@@            Coverage Diff            @@
##             r2.0     #60      +/-   ##
=========================================
- Coverage   98.45%   98.1%   -0.35%     
=========================================
  Files          14      15       +1     
  Lines         452     475      +23     
  Branches       24      25       +1     
=========================================
+ Hits          445     466      +21     
- Misses          4       6       +2     
  Partials        3       3
Impacted Files Coverage Δ
src/sagemaker_containers/env.py 99.45% <100%> (ø) ⬆️
src/sagemaker_containers/transformer.py 100% <100%> (ø) ⬆️
src/sagemaker_containers/errors.py 100% <100%> (ø)
src/sagemaker_containers/modules.py 97.05% <92.3%> (-2.95%) ⬇️

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 73f9ba7...0f11321. Read the comment docs.

shutil.rmtree(tmp)


def write_file(path, content, mode='w'): # type: (str, str, str) -> None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this kind of function (along with tmpdir and read_json), belongs to this module (env.py) -- they're utility functions that could really live anywhere since they don't refer to variables in the module's scope. write_file, for example, is only called in another module (module.py) -- it could be _write_file in module.py

My concern is that users will depend on these utility functions and they'll be part of the sagemaker_containers.env interface, just like gpu_count, TrainingEnvironment-- are we ok with that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with you @andremoeller, are you ok if the follow up PR includes the code moves?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep!

subprocess.check_call(shlex.split('%s -m pip install %s -U' % (sys.executable, path)))
except subprocess.CalledProcessError:
raise RuntimeError('Failed to pip install %s:%s%s' % (path, os.linesep, traceback.format_exc()))
cmd = '%s -m pip install -U . ' % sys.executable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We got into trouble because I moved requirements.txt installation from TensorFlow into SageMaker Container Support, so we moved it back. I think @laurenyu knows more about why that didn't work though -- I suggest you make sure we aren't running into the same problem.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the issue last time was that the logic for downloading the user code was in the TF container, and the call to install requirements occurred before that downloading happened.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks to detail the issue @laurenyu. I believe that our current implementation does not have the same issue, I will make sure to integration on the framework containers to ensure that it is working.

subprocess.check_call(shlex.split('%s -m pip install %s -U' % (sys.executable, path)))
except subprocess.CalledProcessError:
raise RuntimeError('Failed to pip install %s:%s%s' % (path, os.linesep, traceback.format_exc()))
cmd = '%s -m pip install -U . ' % sys.executable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the issue last time was that the logic for downloading the user code was in the TF container, and the call to install requirements occurred before that downloading happened.

module = modules.download_and_import(user_module.url, 'test_script')
module = modules.download_and_import(user_module.url, user_module_name, cache=False)

# flake8: noqa ignore=W291 trailing whitespace

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do you need trailing whitespace here? does this mean things will break if someone's editor automatically deletes all trailing whitespace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. I will remove the noqa

@andremoeller andremoeller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes in a future PR

@mvsusp
mvsusp merged commit 258f9f7 into aws:r2.0 May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants