Skip to content

Commit 93f1bbf

Browse files
diningPhilosopher64Prabhakar Kumar
authored and
Prabhakar Kumar
committed
Updates timeouts for processes started by jupyter-matlab-proxy to match timeouts from matlab-proxy.
1 parent cd35979 commit 93f1bbf

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies = [
4646
"jupyter-server-proxy",
4747
"simpervisor>=1.0.0",
4848
"jupyter-contrib-nbextensions",
49-
"matlab-proxy>=0.8.0",
49+
"matlab-proxy>=0.9.1",
5050
"psutil",
5151
"requests",
5252
]

src/jupyter_matlab_kernel/kernel.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from requests.exceptions import HTTPError
1414

1515
from jupyter_matlab_kernel import mwi_comm_helpers
16+
from matlab_proxy import util as mwi_util
17+
from matlab_proxy import settings as mwi_settings
18+
19+
20+
_MATLAB_STARTUP_TIMEOUT = mwi_settings.get_process_startup_timeout()
1621

1722

1823
class MATLABConnectionError(Exception):
@@ -142,7 +147,7 @@ def start_matlab_proxy():
142147
# Thus we need to go one level higher to acquire the process id of the jupyter server.
143148
# Note: conda environments do not require this, and for these environments sys.prefix == sys.base_prefix
144149
is_virtual_env = sys.prefix != sys.base_prefix
145-
if sys.platform == "win32" and is_virtual_env:
150+
if mwi_util.system.is_windows() and is_virtual_env:
146151
jupyter_server_pid = psutil.Process(jupyter_server_pid).ppid()
147152

148153
nb_server = dict()
@@ -465,10 +470,9 @@ def perform_startup_checks(self):
465470

466471
# Wait until MATLAB is started before sending requests.
467472
timeout = 0
468-
MATLAB_STARTUP_MAX_TIMEOUT = 120
469473
while (
470474
self.matlab_status != "up"
471-
and timeout != MATLAB_STARTUP_MAX_TIMEOUT
475+
and timeout != _MATLAB_STARTUP_TIMEOUT
472476
and not self.matlab_proxy_has_error
473477
):
474478
if self.is_matlab_licensed:
@@ -496,7 +500,7 @@ def perform_startup_checks(self):
496500
# If MATLAB is not available after 15 seconds of licensing information
497501
# being available either through user input or through matlab-proxy cache,
498502
# then display connection error to the user.
499-
if timeout == MATLAB_STARTUP_MAX_TIMEOUT or self.matlab_proxy_has_error:
503+
if timeout == _MATLAB_STARTUP_TIMEOUT or self.matlab_proxy_has_error:
500504
raise MATLABConnectionError
501505

502506
def display_output(self, out):

tests/e2e/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const config = {
2525
webServer: {
2626
command: webserverCommand,
2727
url: BASE_URL + '/api',
28-
timeout: 120 * 1000,
28+
timeout: 600 * 1000, // This value should be the same as the one we get from matlab_proxy.settings.get_process_startup_timeout()
2929
reuseExistingServer: !process.env.CI
3030
},
3131

tests/integration/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import pytest
77
import requests
88

9+
from matlab_proxy import settings as mwi_settings
10+
11+
_MATLAB_STARTUP_TIMEOUT = mwi_settings.get_process_startup_timeout()
12+
913

1014
@pytest.fixture(autouse=True, scope="module")
1115
def matlab_proxy_fixture(module_monkeypatch):
@@ -50,7 +54,7 @@ def matlab_proxy_fixture(module_monkeypatch):
5054
integration_test_utils.poll_web_service(
5155
matlab_proxy_url,
5256
step=5,
53-
timeout=120,
57+
timeout=_MATLAB_STARTUP_TIMEOUT,
5458
ignore_exceptions=(
5559
requests.exceptions.ConnectionError,
5660
requests.exceptions.SSLError,
@@ -122,6 +126,5 @@ def __get_matlab_config_file():
122126
Returns:
123127
string: MATLAB config file path
124128
"""
125-
from matlab_proxy import settings
126129

127-
return settings.get()["matlab_config_file"]
130+
return mwi_settings.get()["matlab_config_file"]

tests/integration/integration_test_utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import requests
1010

11+
from matlab_proxy.settings import get_process_startup_timeout
12+
13+
MATLAB_STARTUP_TIMEOUT = get_process_startup_timeout()
14+
1115

1216
def perform_basic_checks():
1317
"""
@@ -85,18 +89,13 @@ def wait_matlab_proxy_ready(matlab_proxy_url):
8589

8690
from jupyter_matlab_kernel import mwi_comm_helpers
8791

88-
# Timeout for polling the matlab-proxy http endpoints.
89-
# matlab-proxy takes more time to be 'up' in machines
90-
# other than Linux
91-
MAX_TIMEOUT = 120 if system.is_linux() else 300
92-
9392
is_matlab_licensed = False
9493
matlab_status = "down"
9594
start_time = time.time()
9695

9796
# Poll for matlab-proxy to be up
9897
while matlab_status in ["down", "starting"] and (
99-
time.time() - start_time < MAX_TIMEOUT
98+
time.time() - start_time < MATLAB_STARTUP_TIMEOUT
10099
):
101100
time.sleep(1)
102101
try:

tests/unit/test_jupyter_server_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_get_env_with_token_auth_disabled(monkeypatch):
5555
assert r.get(mwi_env.get_env_name_mwi_auth_token()) == None
5656

5757

58-
def test_setup_matlab(monkeypatch):
58+
def test_setup_matlab():
5959
"""Tests for a valid Server Process Configuration Dictionary
6060
6161
This test checks if the jupyter proxy returns the expected Server Process Configuration

0 commit comments

Comments
 (0)