55# pylint: disable=too-many-statements
66# pylint: disable=unnecessary-lambda
77
8+ import contextlib
89import json
910import logging
1011import re
2122 10 * MINUTE
2223) # NOTE: smash is 13Gib, math 2Gib
2324_WAITING_TIME_FILE_CREATION_PER_GB_IN_TERMINAL : Final [int ] = 10 * SECOND
25+ _DEFAULT_RESPONSE_TO_WAIT_FOR : Final [re .Pattern ] = re .compile (
26+ r"/api/contents/workspace"
27+ )
2428_SERVICE_NAME_EXPECTED_RESPONSE_TO_WAIT_FOR : Final [dict [str , re .Pattern ]] = {
25- "jupyter-math" : re .compile (r"/api/contents/workspace" ),
26- "jupyter-smash" : re .compile (r"/api/contents/workspace" ),
27- "jupyter-smash-8-0-0" : re .compile (r"/api/contents/workspace" ),
28- "jupyter-octave-python-math" : re .compile (r"/api/contents" ),
29+ "jupyter-octave-python-math" : re .compile (r"/api/contents" ), # old way
2930}
3031
32+ _DEFAULT_TAB_TO_WAIT_FOR : Final [str ] = "README.md"
3133_SERVICE_NAME_TAB_TO_WAIT_FOR : Final [dict [str , str ]] = {
32- "jupyter-math" : "README.ipynb" ,
33- "jupyter-smash" : "README.ipynb" ,
34- "jupyter-smash-8-0-0" : "README.ipynb" ,
34+ "jupyter-ml-pytorch" : "README.ipynb"
3535}
3636
3737
@@ -73,9 +73,12 @@ def test_jupyterlab(
7373):
7474 # NOTE: this waits for the jupyter to send message, but is not quite enough
7575 with log_context (
76- logging .INFO , f"Waiting for { service_key } responsive"
76+ logging .INFO ,
77+ f"Waiting for { service_key } to be responsive (waiting for { _SERVICE_NAME_EXPECTED_RESPONSE_TO_WAIT_FOR .get (service_key , _DEFAULT_RESPONSE_TO_WAIT_FOR )} )" ,
7778 ), page .expect_response (
78- _SERVICE_NAME_EXPECTED_RESPONSE_TO_WAIT_FOR [service_key ],
79+ _SERVICE_NAME_EXPECTED_RESPONSE_TO_WAIT_FOR .get (
80+ service_key , _DEFAULT_RESPONSE_TO_WAIT_FOR
81+ ),
7982 timeout = _WAITING_FOR_SERVICE_TO_START ,
8083 ):
8184 create_project_from_service_dashboard (ServiceType .DYNAMIC , service_key , None )
@@ -87,12 +90,19 @@ def test_jupyterlab(
8790 )
8891 return
8992
93+ if service_key == "jupyter-ml-pytorch" :
94+ with contextlib .suppress (TimeoutError ):
95+ iframe .get_by_role ("button" , name = "Select" , exact = True ).click ()
96+
9097 with log_context (
9198 logging .INFO ,
92- f"Waiting for { _SERVICE_NAME_TAB_TO_WAIT_FOR [ service_key ] } to become visible" ,
99+ f"Waiting for { _SERVICE_NAME_TAB_TO_WAIT_FOR . get ( service_key , _DEFAULT_TAB_TO_WAIT_FOR ) } to become visible" ,
93100 ):
94101 iframe .get_by_role (
95- "tab" , name = _SERVICE_NAME_TAB_TO_WAIT_FOR [service_key ]
102+ "tab" ,
103+ name = _SERVICE_NAME_TAB_TO_WAIT_FOR .get (
104+ service_key , _DEFAULT_TAB_TO_WAIT_FOR
105+ ),
96106 ).wait_for (state = "visible" )
97107 if large_file_size :
98108 with log_context (
@@ -130,6 +140,11 @@ def test_jupyterlab(
130140 # NOTE: this is to let some tester see something
131141 page .wait_for_timeout (2000 )
132142
143+ if service_key == "jupyter-ml-pytorch" :
144+ print (
145+ f"skipping any more complicated stuff since this is { service_key = } which is different from the others"
146+ )
147+ return
133148 # Wait until iframe is shown and create new notebook with print statement
134149 with log_context (logging .INFO , "Running new notebook" ):
135150 iframe .get_by_role ("button" , name = "New Launcher" ).click ()
0 commit comments