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

Environment extends map - #35

Merged
mvsusp merged 12 commits into
aws:r2.0from
mvsusp:mvs-env-mapping
Apr 26, 2018
Merged

mvsusp merged 12 commits into
aws:r2.0from
mvsusp:mvs-env-mapping

Conversation

@mvsusp

@mvsusp mvsusp commented Apr 25, 2018

Copy link
Copy Markdown
Contributor
  • Environment extend Mapping
  • Improved Environment test coverage
  • ignoring python 2 code coverage when running python 3 tests and vice versa

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



class Environment(object):
class Environment(collections.Mapping):

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.

what is rationale for this change?

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.

+1

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.

discussed offline. ok.

Comment thread src/sagemaker_containers/environment.py Outdated
input_data_config = read_input_data_config()

sagemaker_hyperparameters, hyperparameters = split_hyperparameters(read_hyperparameters())
hps = read_hyperparameters()

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.

hyperparameters

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.

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.

ya but we should take opportunity to fix

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.

Should I move the Environment class to another file them?
What do you suggest @jesterhazy

@@ -0,0 +1,14 @@
def split_by_criteria(dictionary, keys): # type: (dict, set) -> (dict, dict)

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.

is this function used anywhere except Environment? if not, it should be private method in environment

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.

Environment by design is a namedtuple, POCO, POJO, (put your plain class of choice here).
Another design decision is that this library is composed by small functions that can be utilized as well. Private methods and classes are only used when necessary.

I have changes outside the scope of this PR that already use split_by_criteria.

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.

discussed offline ok.

@mvsusp
mvsusp requested a review from iquintero April 25, 2018 23:46
Comment thread src/sagemaker_containers/environment.py Outdated
USE_NGINX_ENV = 'SAGEMAKER_USE_NGINX' # type: str

BASE_PATH = os.environ.get(BASE_PATH_ENV, os.path.join('/opt', 'ml')) # type: str
BASE_PATH = os.environ.get(BASE_PATH_ENV, os.path.join(os.sep, 'opt', 'ml')) # type: str

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 remeber when doing

os.path.join(something, '/something_else') it would result in

/something_else instead of something/something_else.
is using os.sep working around it? does it even need to be there?

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.

if first arg to join has '/' it's ok, but if later ones do then it's trouble. looks like os.sep here is just to avoid platform-specific separator. but '/' should work fine on all platforms and is more readable

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 will revert.



class Environment(object):
class Environment(collections.Mapping):

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.

+1

Comment thread .coveragerc_py35
partial_branches =
pragma: no cover
pragma: py3 no cover
if six.PY3

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.

should be six.PY2 here

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 catch!

@codecov-io

codecov-io commented Apr 26, 2018 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (r2.0@de43fc8). Click here to learn what that means.
The diff coverage is 97.29%.

Impacted file tree graph

@@           Coverage Diff           @@
##             r2.0      #35   +/-   ##
=======================================
  Coverage        ?   99.52%           
=======================================
  Files           ?        4           
  Lines           ?      211           
  Branches        ?       15           
=======================================
  Hits            ?      210           
  Misses          ?        0           
  Partials        ?        1
Impacted Files Coverage Δ
src/sagemaker_containers/collections.py 100% <100%> (ø)
src/sagemaker_containers/__init__.py 100% <100%> (ø)
src/sagemaker_containers/environment.py 99.36% <96.87%> (ø)

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 de43fc8...37cb196. Read the comment docs.

@mvsusp
mvsusp merged commit b427a68 into aws:r2.0 Apr 26, 2018
@mvsusp
mvsusp deleted the mvs-env-mapping branch April 26, 2018 01:08
@mvsusp mvsusp mentioned this pull request Apr 26, 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