diff --git a/python/pyproject.toml b/python/pyproject.toml index 174a2546c..3219d79b3 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,6 +19,7 @@ dependencies = [ "requests >= 2.31.0", "gql[all] == 3.5.0", "matplotlib >= 3.4.3", + "ipywidgets >= 8.1.5", ] diff --git a/python/tests/graphql/edit_graph/test_graphql.py b/python/tests/graphql/edit_graph/test_graphql.py index 6b6a06b96..aa65bcb30 100644 --- a/python/tests/graphql/edit_graph/test_graphql.py +++ b/python/tests/graphql/edit_graph/test_graphql.py @@ -28,7 +28,10 @@ def test_failed_server_start_in_time(): def test_wrong_url(): with pytest.raises(Exception) as excinfo: client = RaphtoryClient("http://broken_url.com") - assert str(excinfo.value) == "Could not connect to the given server - no response" + assert ( + str(excinfo.value) + == "Could not connect to the given server - no response --error sending request for url (http://broken_url.com/)" + ) def test_successful_server_start_in_time(): diff --git a/raphtory-graphql/src/python/client/raphtory_client.rs b/raphtory-graphql/src/python/client/raphtory_client.rs index 9f30c2858..379393b4f 100644 --- a/raphtory-graphql/src/python/client/raphtory_client.rs +++ b/raphtory-graphql/src/python/client/raphtory_client.rs @@ -102,9 +102,10 @@ impl PyRaphtoryClient { ))) } } - Err(_) => Err(PyValueError::new_err( - "Could not connect to the given server - no response", - )), + Err(e) => Err(PyValueError::new_err(format!( + "Could not connect to the given server - no response --{}", + e.to_string() + ))), } } diff --git a/raphtory-graphql/src/python/server/running_server.rs b/raphtory-graphql/src/python/server/running_server.rs index b750fba04..3e0b8dbfc 100644 --- a/raphtory-graphql/src/python/server/running_server.rs +++ b/raphtory-graphql/src/python/server/running_server.rs @@ -20,7 +20,7 @@ pub struct PyRunningGraphServer { pub(crate) struct ServerHandler { pub(crate) join_handle: JoinHandle>, sender: CrossbeamSender, - pub(crate) client: PyRaphtoryClient, + port: u16, } impl PyRunningGraphServer { @@ -29,13 +29,11 @@ impl PyRunningGraphServer { sender: CrossbeamSender, port: u16, ) -> PyResult { - let url = format!("http://localhost:{port}"); let server_handler = Some(ServerHandler { join_handle, sender, - client: PyRaphtoryClient::new(url)?, + port, }); - Ok(PyRunningGraphServer { server_handler }) } @@ -83,7 +81,11 @@ impl PyRunningGraphServer { #[pymethods] impl PyRunningGraphServer { pub(crate) fn get_client(&self) -> PyResult { - self.apply_if_alive(|handler| Ok(handler.client.clone())) + self.apply_if_alive(|handler| { + let port = handler.port; + let url = format!("http://localhost:{port}"); + Ok(PyRaphtoryClient::new(url)?) + }) } /// Stop the server and wait for it to finish diff --git a/raphtory-graphql/src/python/server/server.rs b/raphtory-graphql/src/python/server/server.rs index 434f30a9f..4c88ff4a3 100644 --- a/raphtory-graphql/src/python/server/server.rs +++ b/raphtory-graphql/src/python/server/server.rs @@ -313,10 +313,8 @@ impl PyGraphServer { let mut server = PyRunningGraphServer::new(join_handle, sender, port)?; if let Some(server_handler) = &server.server_handler { - match PyRunningGraphServer::wait_for_server_online( - &server_handler.client.url, - timeout_ms, - ) { + let url = format!("http://localhost:{port}"); + match PyRunningGraphServer::wait_for_server_online(&url, timeout_ms) { Ok(_) => return Ok(server), Err(e) => { PyRunningGraphServer::stop_server(&mut server, py)?;