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

Add services #26

Merged
merged 1 commit into from Jun 28, 2017
Merged

Add services #26

merged 1 commit into from Jun 28, 2017

Conversation

barrachri
Copy link

Updated:

  • docker version
  • docker-compose version

Added:

  • first draft for services and swarm
  • tests for both

@codecov-io
Copy link

codecov-io commented May 30, 2017

Codecov Report

Merging #26 into master will increase coverage by 5.18%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
+ Coverage   69.85%   75.03%   +5.18%     
==========================================
  Files           9       12       +3     
  Lines         617      677      +60     
==========================================
+ Hits          431      508      +77     
+ Misses        186      169      -17
Impacted Files Coverage Δ
aiodocker/docker.py 66.57% <100%> (+0.58%) ⬆️
aiodocker/tasks.py 100% <100%> (ø)
aiodocker/swarm.py 88.23% <88.23%> (ø)
aiodocker/services.py 92% <92%> (ø)
aiodocker/utils.py 76.08% <0%> (+22.82%) ⬆️

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 992546a...7139827. Read the comment docs.


data = {}

if config is not None and isinstance(config, dict):
Copy link
Member

Choose a reason for hiding this comment

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

this check is not required since we defined config couple lines earlier

for k, v in config.items():
if v is not None:
data[k] = v
elif config is not None:
Copy link
Member

Choose a reason for hiding this comment

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

same, this elif can not be reached

data = {}

if config is not None and isinstance(config, dict):
for k, v in config.items():
Copy link
Member

Choose a reason for hiding this comment

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

minor thing, but what do you think about {k: v for k, v in config.items() if v is not None} instead for loop ?

def __init__(self, docker):
self.docker = docker

async def list(self, filters: dict={}) -> list:
Copy link
Member

@jettify jettify May 30, 2017

Choose a reason for hiding this comment

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

having mutable structure as default is not good idea, probably should be
filters: Optional[dict]=None and then params=filters or {}

@barrachri
Copy link
Author

@jettify thanks for the feedback.

I am going to prepare a new PR.

@barrachri
Copy link
Author

@jettify :)

@jettify jettify mentioned this pull request Jun 7, 2017
@jettify
Copy link
Member

jettify commented Jun 7, 2017

Asked question about typing, in #29 , what is your thoughts on this?

@barrachri
Copy link
Author

Personally I am 👍 in adding typing. Would be useful also to verify the type of the inputs.

@barrachri
Copy link
Author

I cleaned the typing part.

@achimnol
Copy link
Member

All tests pass at my local setup merged with this PR.
Unfortunately I don't have enough time to make detailed code reviews right now.
@jettify Would you like to continue reviewing?

@asvetlov
Copy link
Member

I have the same note -- please make optional arguments keyword-only.

barrachri referenced this pull request Jun 26, 2017
 * Both prev/this commit passes test suite multiple times in my EC2
   Ubuntu 16.04 setup with Python 3.6.1 and Docker-CE 17.03.
   Hm....

 * NOTE: Docker emits TEXT websocket messages instead of BINARY, even
   for the terminal emulation.
@jettify
Copy link
Member

jettify commented Jun 26, 2017

Do we want to change f strings to format here?

@@ -57,3 +60,67 @@ def httpize(d: Optional[dict]) -> Optional[dict]:
d = decoder.decode(b'', final=True)
if d:
yield d


def clean_config(config: Optional[dict]) -> dict:
Copy link
Member

Choose a reason for hiding this comment

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

lets also add tests for this helpers, should be very easy, we can do this in separate PR since, current one is already large.

@asvetlov
Copy link
Member

Please merge master to make sure your tests are passed on python 3.5

@barrachri barrachri force-pushed the add_services branch 3 times, most recently from 1812bd5 to 5da4ec9 Compare June 27, 2017 14:34
@asvetlov
Copy link
Member

You clone still conflicts with master :(

@barrachri barrachri force-pushed the add_services branch 2 times, most recently from ff6ea1c to 4607847 Compare June 27, 2017 17:24

my_services = []
for i in range(3):
name = f"service-{i}"
Copy link
Member

Choose a reason for hiding this comment

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

Tests should go on Python 3.5 too

@barrachri
Copy link
Author

Ufff, cleaned everything :)

@asvetlov
Copy link
Member

Cool!

@asvetlov asvetlov merged commit b5f7b25 into aio-libs:master Jun 28, 2017
@barrachri barrachri deleted the add_services branch June 29, 2017 12:18
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.

None yet

5 participants