Skip to content
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

Client-side support for streaming neuro-save #946

Merged
merged 11 commits into from
Aug 24, 2019
Merged

Conversation

atemate
Copy link
Contributor

@atemate atemate commented Aug 5, 2019

No description provided.

@@ -162,14 +171,43 @@ def __init__(self, core: _Core, config: _Config) -> None:
# an error is raised for status >= 400
return None # 201 status code

async def save(self, id: str, image: RemoteImage) -> None:
async def save(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking on dependency graph I'm inclining to a thought that this method actually belongs to images, not jobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as far as I understood, the CLI command should be neuro job save, not neuro image save 😕

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 a good question.
In docker save belongs to docker image group, not docker container.
Maybe we should apply the same change to our CLI.

Anyway, for now please keep CLI command as is but move API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

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 moved both save() back to jobs because when it belongs to images, this functionality does not work on windows as Images.__init__() requires docker available on the local machine, which is not necessary for save().

Let's keep it less clean for now, and later refactor it out to a separate class (a separate member of Client).

Copy link
Contributor

Choose a reason for hiding this comment

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

Separate member of Client sounds even better.
What name do you suggest?
What prevents you from making this refactoring now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What name do you suggest

maybe something like ImagesLocal (for current Images) and ImagesRemote? meaning if the user's machine works with local docker or remote docker.

What prevents you from making this refactoring now?

It will require many non-functional changes; let's keep this PR as-is and do refactoring it in a separate PR?

neuromation/api/abc.py Outdated Show resolved Hide resolved
neuromation/api/jobs.py Outdated Show resolved Hide resolved
neuromation/api/jobs.py Outdated Show resolved Hide resolved
neuromation/cli/job.py Outdated Show resolved Hide resolved
@atemate atemate force-pushed the ay/docker-stream-retry branch from f1b29f8 to def39d3 Compare August 6, 2019 02:04
@codecov
Copy link

codecov bot commented Aug 6, 2019

Codecov Report

Merging #946 into master will increase coverage by 0.27%.
The diff coverage is 83.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #946      +/-   ##
==========================================
+ Coverage    87.3%   87.57%   +0.27%     
==========================================
  Files          37       37              
  Lines        4215     4259      +44     
  Branches      636      641       +5     
==========================================
+ Hits         3680     3730      +50     
+ Misses        420      413       -7     
- Partials      115      116       +1
Impacted Files Coverage Δ
neuromation/cli/formatters/images.py 100% <100%> (+6.34%) ⬆️
neuromation/api/abc.py 100% <100%> (ø) ⬆️
neuromation/cli/job.py 79.86% <20%> (-0.2%) ⬇️
neuromation/api/images.py 76.51% <78.57%> (+6.26%) ⬆️
neuromation/api/jobs.py 94.46% <92%> (-0.34%) ⬇️
neuromation/api/users.py 87.14% <0%> (-5.97%) ⬇️
neuromation/api/parsing_utils.py 100% <0%> (ø) ⬆️
neuromation/cli/share.py 100% <0%> (ø) ⬆️
neuromation/api/login.py 96.57% <0%> (+1.52%) ⬆️

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 1ae10a0...def39d3. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 6, 2019

Codecov Report

Merging #946 into master will increase coverage by 0.25%.
The diff coverage is 97.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #946      +/-   ##
==========================================
+ Coverage   92.21%   92.47%   +0.25%     
==========================================
  Files          37       37              
  Lines        4253     4345      +92     
  Branches      640      647       +7     
==========================================
+ Hits         3922     4018      +96     
+ Misses        223      220       -3     
+ Partials      108      107       -1
Impacted Files Coverage Δ
neuromation/api/abc.py 100% <100%> (ø) ⬆️
neuromation/api/jobs.py 96.85% <100%> (+0.54%) ⬆️
neuromation/cli/job.py 89.18% <100%> (+0.45%) ⬆️
neuromation/api/images.py 97.67% <92%> (+3.45%) ⬆️
neuromation/cli/formatters/images.py 94.31% <96%> (+0.66%) ⬆️

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 fd70a84...b88959e. Read the comment docs.

neuromation/api/abc.py Outdated Show resolved Hide resolved
neuromation/api/images.py Outdated Show resolved Hide resolved
neuromation/api/images.py Outdated Show resolved Hide resolved
@@ -162,15 +157,6 @@ def __init__(self, core: _Core, config: _Config) -> None:
# an error is raised for status >= 400
return None # 201 status code

async def save(self, id: str, image: RemoteImage) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to api/images.py

Artem Yushkovskiy added 2 commits August 7, 2019 11:48
@atemate atemate marked this pull request as ready for review August 7, 2019 15:51
@atemate atemate changed the title WIP: Client-side support for streaming neuro-save Client-side support for streaming neuro-save Aug 7, 2019


@dataclass(frozen=True)
class ImageCommitStep:
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you have always two ImageCommitStep messages: one with status==CommitStarted, second with status=CommitFinished.

Why not replace it with two distinct message type:

@dataclass
class ImageCommitStarted:
    pass  # really no context data? I expect job id at least

@class
class ImageCommitFinished:
    container: str
    target_image: RemoteImage
    # job id again, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I don't see the difference. Re-worked.

@dataclass(frozen=True)
class ImageCommitStarted:
job_id: str
container: str
Copy link
Contributor

Choose a reason for hiding this comment

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

What container string is?
In jobs API we have complex Container dataclass. I have an understanding of what dataclass fields mean. We'll have documentation for it soon.
As a user, I have no idea what to do with container-as-string except printing it may be (but what is the string format)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's 64-long SHA256 hash of docker container

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mostly technical information, but since we reveal operations "commit" and "push", I decided to print it as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hash of docker container or image?
If this is a local docker container hash -- how can I use this info as a client?
Client has no access to docker daemon deployed on the node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hash of docker container.

Client has no access to docker daemon deployed on the node.

true. I will remove container: str.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, we also should not print Pushing image artemyushkovskiy/test:latest => image://artemyushkovskiy/test:latest because the source image does not make sense for the user

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 removed messages about "container", but I will not fix docker-push messages "Pushing image artemyushkovskiy/test:latest => image://artemyushkovskiy/test:latest" in this PR as it is a very minor issue that requires lots of changes.

@lgtm-com
Copy link

lgtm-com bot commented Aug 22, 2019

This pull request fixes 5 alerts when merging 6831aaf into 9b5e44f - view on LGTM.com

fixed alerts:

  • 3 for Conflicting attributes in base classes
  • 2 for Module is imported with 'import' and 'import from'

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

LGTM on green

Artem Yushkovskiy added 2 commits August 23, 2019 14:18
@atemate atemate merged commit 1eb7b31 into master Aug 24, 2019
@atemate atemate deleted the ay/docker-stream-retry branch August 24, 2019 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants