Skip to content

Commit

Permalink
Expanded Client Timeout Controls (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
czaloom authored Jul 8, 2024
1 parent 033f059 commit faa43d2
Show file tree
Hide file tree
Showing 5 changed files with 452 additions and 103 deletions.
15 changes: 14 additions & 1 deletion client/unit-tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@

import pytest

from valor.client import connect, get_connection, reset_connection
from valor.client import (
_format_request_timeout,
connect,
get_connection,
reset_connection,
)
from valor.exceptions import (
ClientAlreadyConnectedError,
ClientConnectionFailed,
ClientNotConnectedError,
)


def test__format_request_timeout():
assert _format_request_timeout(timeout=None, default=30) == 30
assert _format_request_timeout(timeout=60, default=30) == 60
assert _format_request_timeout(timeout=-1, default=30) is None
assert _format_request_timeout(timeout=0, default=30) is None
assert _format_request_timeout(timeout=-0.1, default=30) is None


@patch("valor.client.ClientConnection")
def test_connect(ClientConnection):
connect(host="host")
Expand Down
19 changes: 19 additions & 0 deletions client/unit-tests/test_coretypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from unittest.mock import patch

import pytest

from valor import Client


@patch("time.sleep")
@patch("valor.Client")
def test_timeouts(mock_sleep, mock_client):

with pytest.raises(TimeoutError):
Client.delete_dataset(mock_client, name="some_dataset", timeout=1)

with pytest.raises(TimeoutError):
Client.delete_model(mock_client, name="some_dataset", timeout=1)

with pytest.raises(TimeoutError):
Client.delete_evaluation(mock_client, evaluation_id=1, timeout=1)
Loading

0 comments on commit faa43d2

Please sign in to comment.