Skip to content

New option --network-timeout #678

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

Merged
merged 3 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Name | Description|
|_\--show-traceback_|Show python traceback on error, useful for debugging the tool.|
|_--color \[yes | no | auto]_|Color mode.|
|_\--disable-pypi-version-check_|Don't periodically check PyPI to determine whether a new version of Neuromation CLI is available for download.|
|_\--network-timeout FLOAT_|Network read timeout, seconds.|
|_--version_|Show the version and exit.|
|_--help_|Show this message and exit.|

Expand Down
5 changes: 5 additions & 0 deletions python/neuromation/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def print_options(
help="Don't periodically check PyPI to determine whether a new version of "
"Neuromation CLI is available for download.",
)
@click.option(
"--network-timeout", type=float, help="Network read timeout, seconds.", default=60.0
)
@click.version_option(
version=neuromation.__version__, message="Neuromation Platform Client %(version)s"
)
Expand All @@ -117,6 +120,7 @@ def cli(
show_traceback: bool,
color: str,
disable_pypi_version_check: bool,
network_timeout: float,
) -> None:
# ▇ ◣
# ▇ ◥ ◣
Expand All @@ -143,6 +147,7 @@ def cli(
config.tty = tty
config.terminal_size = shutil.get_terminal_size()
config.disable_pypi_version_check = disable_pypi_version_check
config.network_timeout = network_timeout
ctx.obj = config
if not disable_pypi_version_check:
config.pypi.warn_if_has_newer_version()
Expand Down
5 changes: 5 additions & 0 deletions python/neuromation/cli/rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Config:
tty: bool = field(default=False) # don't save the field in config
terminal_size: Tuple[int, int] = field(default=(80, 24)) # don't save it in config
disable_pypi_version_check: bool = False # don't save it in config
network_timeout: float = 30.0

@property
def auth(self) -> Optional[str]:
Expand Down Expand Up @@ -107,6 +108,10 @@ def make_client(self, *, timeout: Optional[aiohttp.ClientTimeout] = None) -> Cli
kwargs: Dict[str, Any] = {}
if timeout is not None:
kwargs["timeout"] = timeout
else:
kwargs["timeout"] = aiohttp.ClientTimeout(
None, None, self.network_timeout, self.network_timeout
)
if self.registry_url:
kwargs["registry_url"] = self.registry_url
return Client(self.url, token, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion python/neuromation/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

log = logging.getLogger(__name__)

DEFAULT_TIMEOUT = aiohttp.ClientTimeout(None, None, 30, 30)
DEFAULT_TIMEOUT = aiohttp.ClientTimeout(None, None, 60, 60)


class ClientError(Exception):
Expand Down
6 changes: 6 additions & 0 deletions python/tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
JOB_OUTPUT_TIMEOUT = 60 * 5
JOB_OUTPUT_SLEEP_SECONDS = 2
STORAGE_MAX_WAIT = 60
NETWORK_TIMEOUT = 60.0 * 3

DUMMY_PROGRESS = ProgressBase.create_progress(False)

Expand Down Expand Up @@ -387,6 +388,7 @@ def _temp_config():
"--show-traceback",
"--disable-pypi-version-check",
"--color=no",
f"--network-timeout={self.config.network_timeout}",
]
+ arguments
)
Expand Down Expand Up @@ -487,6 +489,8 @@ def _temp_config():
config = rc.ConfigFactory.load()
else:
config = rc.ConfigFactory.load()

config.network_timeout = NETWORK_TIMEOUT
yield config


Expand Down Expand Up @@ -515,6 +519,8 @@ def _temp_config():
config = rc.ConfigFactory.load()
else:
pytest.skip("CLIENT_TEST_E2E_USER_NAME_ALT variable is not set")

config.network_timeout = NETWORK_TIMEOUT
yield config


Expand Down