Skip to content

Improve DockerRun method names and add typing information

Igor Ponomarev requested to merge improve-docker-run-method-names into master

Currently DockerRun has a few poorly named methods and attributes. For example, tty(). tty() what? tty() where? tty() how? A much better name would be enable_tty() which instantly tells what it does.

Add typing information to all methods and attributes where it is possible. This will in the future allow type checking the lava_dispatcher code base.

Also rename the internal __magick__ attributes because usually those names are reserved for Python language specification. Even if some libraries invent such attributes they are usually used for generic protocols. For example, Jinja2 has a __html__ protocol which implies that an object has internal HTML escape. Here in DockerRun they were used for private variables and using a _single_underscore is a more appropriate naming scheme.

Here is the list of renamed methods:

  • local() -> set_use_local_image(): what it does is makes docker not pull an image.
  • name() -> container_name, set_container_name(): assigns a name to container.
  • network() -> set_network_name(): sets a network name used by container.
  • suffix() -> set_suffix(): sets the container name suffix
  • hostname() -> set_hostname(): sets container name
  • workdir() -> set_workdir_path(): sets container working directory.
  • init() -> enable_init() disable_init(): enables or disables container PID 1 init.
  • interactive() -> enable_interactive(): enables container interactive mode.
  • tty() -> enable_tty(): enables container's TTY mode.
  • bind_mount() -> add_bind_mount(): adds a new bind mount for container.
  • environment() -> add_environment_variable(): adds a new environment variable for container.
Edited by Igor Ponomarev

Merge request reports