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

Added Docker client invocation builder; ability to form pipes (resolves #1) #2

Closed
wants to merge 2 commits into from

Conversation

hannes-ucsc
Copy link
Contributor

Resolves #1

"""
A builder (https://en.wikipedia.org/wiki/Builder_pattern) for Popen objects representing a
Docker client invocation. When building a Popen object, it distinguishes between three
layers, the `popen` layer, the `docker` layer and the `extra` layer. The `popen` layer
Copy link
Member

Choose a reason for hiding this comment

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

I don't like extra as a layer name, because it is never referred to as such in Docker docs. Leaving that off is perhaps not clear enough?

(Docker()
  .docker_command('run') # invoke `docker run`
  .docker_params('ubuntu', interactive=True) # pass `--interactive` and run `ubuntu` image
  .docker_params(rm=True)  # docker() is cumulative, also pass `--rm`
  .command('foo') # invoke `foo` command inside container
  .params('/', bar=42) # pass `--bar=42 /` to foo
  .popen_params(cwd='/foo/bar') # pass `cwd='/foo/bar'` to the Popen constructor
  .work_dir('/foo/bar')  # same
  .build_popen_call())

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 agree extra is bad and I like just leaving it off. So

extra_command => command
extra_params =>params

but there also the extra(command,*args,**opts) shortcut. What do we name that?

@hannes-ucsc hannes-ucsc force-pushed the issues/1-rewrite-docker-call branch from 3d975e8 to 5b504ac Compare September 7, 2016 01:28
- revised handling of boolean options (foo=False removes previous occurrences of --foo rather than add --foo=false)
- s/extra/container
- added keyword args to magic __ methods
- added documentation
- disallow multiple docker command
- make docker_command and container_command not cumulative
@hannes-ucsc
Copy link
Contributor Author

hannes-ucsc commented Sep 7, 2016

@heuermh, I looked at all docker command --help's and found only three commands that have these "extra" arguments: create, run and exec. So I renamed extra to container. What do you think?

@heuermh
Copy link
Member

heuermh commented Sep 7, 2016

Yes, I like container better than extra. Thanks for thinking on it!

glennhickey pushed a commit to glennhickey/toil-lib that referenced this pull request Jan 30, 2017
…nstallable

Added toil dependency to setup.py
@hannes-ucsc hannes-ucsc closed this May 4, 2021
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.

Signature of docker_call is getting out of control
2 participants