Skip to content

Commit

Permalink
Move docker flags into xmanager/xm_flags.py.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 615550137
Change-Id: I6d0b28a2807094f6dc3153694bca018699aa9567
GitOrigin-RevId: e5a52f14730b34c9cab16f70b27b05119c456acc
  • Loading branch information
fionalang authored and alpiccioni committed Dec 4, 2024
1 parent ec291b3 commit f225592
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 2 additions & 8 deletions xmanager/docker/docker_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@
import subprocess
from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union

from absl import flags
from absl import logging
import docker
from docker import errors
from docker import types
from docker.models import containers
from docker.utils import utils

_USE_SUBPROCESS = flags.DEFINE_bool(
'xm_subprocess_docker_impl',
False,
'Launch docker using `subprocess` command.',
)
from xmanager import xm_flags

Ports = Dict[Union[int, str], Union[None, int, Tuple[str, int], List[int]]]

Expand Down Expand Up @@ -96,7 +90,7 @@ def run_container(
interactive: bool = False,
) -> Optional[containers.Container]:
"""Runs a given container image."""
if _USE_SUBPROCESS.value or interactive:
if xm_flags.SUBPROCESS_DOCKER.value or interactive:
return self.run_container_subprocess(
image_id,
args,
Expand Down
8 changes: 8 additions & 0 deletions xmanager/xm_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
'xm_bazel_command', 'bazel', 'A command that runs Bazel.',
)

# -------------------- docker ---------------------

SUBPROCESS_DOCKER = flags.DEFINE_bool(
'xm_subprocess_docker_impl',
False,
'Launch docker using `subprocess` command.',
)

# -------------------- contrib --------------------

GCS_PATH = flags.DEFINE_string(
Expand Down

0 comments on commit f225592

Please sign in to comment.