Skip to content

Commit 1ebdb68

Browse files
Add auth to Python SDK (tensorzero#4329)
* Add auth to Python SDK * Add auth to Python SDK * Add auth to Python SDK * Add Python SDK tests for auth * Add Python SDK tests for auth * Add Python SDK tests for auth
1 parent de76bfe commit 1ebdb68

File tree

7 files changed

+596
-122
lines changed

7 files changed

+596
-122
lines changed

clients/python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dev = [
5757
"pytest-xdist",
5858
"pytest-rerunfailures",
5959
"pytest",
60+
"pytest-httpserver",
6061
"openai",
6162
"clickhouse-connect",
6263
"pandas",

clients/python/requirements.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,97 @@ lz4==4.4.4 \
368368
--hash=sha256:f5024d3ca2383470f7c4ef4d0ed8eabad0b22b23eeefde1c192cf1a38d5e9f78 \
369369
--hash=sha256:fff9f3a1ed63d45cb6514bfb8293005dc4141341ce3500abdfeb76124c0b9b2e
370370
# via clickhouse-connect
371+
markupsafe==3.0.3 \
372+
--hash=sha256:0303439a41979d9e74d18ff5e2dd8c43ed6c6001fd40e5bf2e43f7bd9bbc523f \
373+
--hash=sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a \
374+
--hash=sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf \
375+
--hash=sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19 \
376+
--hash=sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf \
377+
--hash=sha256:0f4b68347f8c5eab4a13419215bdfd7f8c9b19f2b25520968adfad23eb0ce60c \
378+
--hash=sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175 \
379+
--hash=sha256:116bb52f642a37c115f517494ea5feb03889e04df47eeff5b130b1808ce7c219 \
380+
--hash=sha256:12c63dfb4a98206f045aa9563db46507995f7ef6d83b2f68eda65c307c6829eb \
381+
--hash=sha256:133a43e73a802c5562be9bbcd03d090aa5a1fe899db609c29e8c8d815c5f6de6 \
382+
--hash=sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab \
383+
--hash=sha256:15d939a21d546304880945ca1ecb8a039db6b4dc49b2c5a400387cdae6a62e26 \
384+
--hash=sha256:177b5253b2834fe3678cb4a5f0059808258584c559193998be2601324fdeafb1 \
385+
--hash=sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce \
386+
--hash=sha256:1b4b79e8ebf6b55351f0d91fe80f893b4743f104bff22e90697db1590e47a218 \
387+
--hash=sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634 \
388+
--hash=sha256:1ba88449deb3de88bd40044603fafffb7bc2b055d626a330323a9ed736661695 \
389+
--hash=sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad \
390+
--hash=sha256:218551f6df4868a8d527e3062d0fb968682fe92054e89978594c28e642c43a73 \
391+
--hash=sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c \
392+
--hash=sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe \
393+
--hash=sha256:2a15a08b17dd94c53a1da0438822d70ebcd13f8c3a95abe3a9ef9f11a94830aa \
394+
--hash=sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559 \
395+
--hash=sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa \
396+
--hash=sha256:3524b778fe5cfb3452a09d31e7b5adefeea8c5be1d43c4f810ba09f2ceb29d37 \
397+
--hash=sha256:3537e01efc9d4dccdf77221fb1cb3b8e1a38d5428920e0657ce299b20324d758 \
398+
--hash=sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f \
399+
--hash=sha256:38664109c14ffc9e7437e86b4dceb442b0096dfe3541d7864d9cbe1da4cf36c8 \
400+
--hash=sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d \
401+
--hash=sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c \
402+
--hash=sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97 \
403+
--hash=sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a \
404+
--hash=sha256:4e885a3d1efa2eadc93c894a21770e4bc67899e3543680313b09f139e149ab19 \
405+
--hash=sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9 \
406+
--hash=sha256:509fa21c6deb7a7a273d629cf5ec029bc209d1a51178615ddf718f5918992ab9 \
407+
--hash=sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc \
408+
--hash=sha256:591ae9f2a647529ca990bc681daebdd52c8791ff06c2bfa05b65163e28102ef2 \
409+
--hash=sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4 \
410+
--hash=sha256:69c0b73548bc525c8cb9a251cddf1931d1db4d2258e9599c28c07ef3580ef354 \
411+
--hash=sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50 \
412+
--hash=sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698 \
413+
--hash=sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9 \
414+
--hash=sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b \
415+
--hash=sha256:795e7751525cae078558e679d646ae45574b47ed6e7771863fcc079a6171a0fc \
416+
--hash=sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115 \
417+
--hash=sha256:7c3fb7d25180895632e5d3148dbdc29ea38ccb7fd210aa27acbd1201a1902c6e \
418+
--hash=sha256:7e68f88e5b8799aa49c85cd116c932a1ac15caaa3f5db09087854d218359e485 \
419+
--hash=sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f \
420+
--hash=sha256:8485f406a96febb5140bfeca44a73e3ce5116b2501ac54fe953e488fb1d03b12 \
421+
--hash=sha256:8709b08f4a89aa7586de0aadc8da56180242ee0ada3999749b183aa23df95025 \
422+
--hash=sha256:8f71bc33915be5186016f675cd83a1e08523649b0e33efdb898db577ef5bb009 \
423+
--hash=sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d \
424+
--hash=sha256:949b8d66bc381ee8b007cd945914c721d9aba8e27f71959d750a46f7c282b20b \
425+
--hash=sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a \
426+
--hash=sha256:9a1abfdc021a164803f4d485104931fb8f8c1efd55bc6b748d2f5774e78b62c5 \
427+
--hash=sha256:9b79b7a16f7fedff2495d684f2b59b0457c3b493778c9eed31111be64d58279f \
428+
--hash=sha256:a320721ab5a1aba0a233739394eb907f8c8da5c98c9181d1161e77a0c8e36f2d \
429+
--hash=sha256:a4afe79fb3de0b7097d81da19090f4df4f8d3a2b3adaa8764138aac2e44f3af1 \
430+
--hash=sha256:ad2cf8aa28b8c020ab2fc8287b0f823d0a7d8630784c31e9ee5edea20f406287 \
431+
--hash=sha256:b8512a91625c9b3da6f127803b166b629725e68af71f8184ae7e7d54686a56d6 \
432+
--hash=sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f \
433+
--hash=sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581 \
434+
--hash=sha256:bdd37121970bfd8be76c5fb069c7751683bdf373db1ed6c010162b2a130248ed \
435+
--hash=sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b \
436+
--hash=sha256:c0c0b3ade1c0b13b936d7970b1d37a57acde9199dc2aecc4c336773e1d86049c \
437+
--hash=sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026 \
438+
--hash=sha256:c4ffb7ebf07cfe8931028e3e4c85f0357459a3f9f9490886198848f4fa002ec8 \
439+
--hash=sha256:ccfcd093f13f0f0b7fdd0f198b90053bf7b2f02a3927a30e63f3ccc9df56b676 \
440+
--hash=sha256:d2ee202e79d8ed691ceebae8e0486bd9a2cd4794cec4824e1c99b6f5009502f6 \
441+
--hash=sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e \
442+
--hash=sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d \
443+
--hash=sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d \
444+
--hash=sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01 \
445+
--hash=sha256:df2449253ef108a379b8b5d6b43f4b1a8e81a061d6537becd5582fba5f9196d7 \
446+
--hash=sha256:e1c1493fb6e50ab01d20a22826e57520f1284df32f2d8601fdd90b6304601419 \
447+
--hash=sha256:e1cf1972137e83c5d4c136c43ced9ac51d0e124706ee1c8aa8532c1287fa8795 \
448+
--hash=sha256:e2103a929dfa2fcaf9bb4e7c091983a49c9ac3b19c9061b6d5427dd7d14d81a1 \
449+
--hash=sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5 \
450+
--hash=sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d \
451+
--hash=sha256:e8fc20152abba6b83724d7ff268c249fa196d8259ff481f3b1476383f8f24e42 \
452+
--hash=sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe \
453+
--hash=sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda \
454+
--hash=sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e \
455+
--hash=sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737 \
456+
--hash=sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523 \
457+
--hash=sha256:f42d0984e947b8adf7dd6dde396e720934d12c506ce84eea8476409563607591 \
458+
--hash=sha256:f71a396b3bf33ecaa1626c255855702aca4d3d9fea5e051b41ac59a9c1c41edc \
459+
--hash=sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a \
460+
--hash=sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50
461+
# via werkzeug
371462
maturin==1.8.3 \
372463
--hash=sha256:11564fac7486313b7baf3aa4e82c20e1b20364aad3fde2ccbc4c07693c0b7e16 \
373464
--hash=sha256:22cd8b6dc490fee99a62590f914f0c04ddad1dd6dbd5c7e933b3f882b1bd78c2 \
@@ -781,6 +872,9 @@ pytest==8.3.5 \
781872
pytest-asyncio==0.26.0 \
782873
--hash=sha256:7b51ed894f4fbea1340262bdae5135797ebbe21d8638978e35d31c6d19f72fb0 \
783874
--hash=sha256:c4df2a697648241ff39e7f0e4a73050b03f123f760673956cf0d72a4990e312f
875+
pytest-httpserver==1.1.3 \
876+
--hash=sha256:5f84757810233e19e2bb5287f3826a71c97a3740abe3a363af9155c0f82fdbb9 \
877+
--hash=sha256:af819d6b533f84b4680b9416a5b3f67f1df3701f1da54924afd4d6e4ba5917ec
784878
pytest-rerunfailures==15.1 \
785879
--hash=sha256:c6040368abd7b8138c5b67288be17d6e5611b7368755ce0465dda0362c8ece80 \
786880
--hash=sha256:f674c3594845aba8b23c78e99b1ff8068556cc6a8b277f728071fdc4f4b0b355
@@ -907,6 +1001,10 @@ uuid-utils==0.10.0 \
9071001
--hash=sha256:e0badcbfe3c72b5b30d59c2b12f120923127abd95a0d2aa64ddc1234e495abc2 \
9081002
--hash=sha256:ffc49c33edf87d1ec8112a9b43e4cf55326877716f929c165a2cc307d31c73d5
9091003
# via tensorzero
1004+
werkzeug==3.1.3 \
1005+
--hash=sha256:54b78bf3716d19a65be4fceccc0d1d7b89e608834989dfae50ea87564639213e \
1006+
--hash=sha256:60723ce945c19328679790e3282cc758aa4a6040e4bb330f53d30fa546d44746
1007+
# via pytest-httpserver
9101008
zstandard==0.23.0 \
9111009
--hash=sha256:034b88913ecc1b097f528e42b539453fa82c3557e414b3de9d5632c80439a473 \
9121010
--hash=sha256:0a7f0804bb3799414af278e9ad51be25edf67f78f916e08afdb983e74161b916 \

clients/python/src/lib.rs

Lines changed: 17 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -301,46 +301,6 @@ fn make_dummy_client() -> Client {
301301

302302
#[pymethods]
303303
impl BaseTensorZeroGateway {
304-
#[new]
305-
#[pyo3(signature = (base_url, *, timeout=None, verbose_errors=false))]
306-
fn new(
307-
py: Python<'_>,
308-
base_url: &str,
309-
timeout: Option<f64>,
310-
verbose_errors: bool,
311-
) -> PyResult<Self> {
312-
let mut client_builder = ClientBuilder::new(ClientBuilderMode::HTTPGateway {
313-
url: Url::parse(base_url)
314-
.map_err(|e| PyValueError::new_err(format!("Failed to parse base_url: {e:?}")))?,
315-
})
316-
.with_verbose_errors(verbose_errors);
317-
if let Some(timeout) = timeout {
318-
let http_client = reqwest::Client::builder()
319-
.timeout(
320-
Duration::try_from_secs_f64(timeout)
321-
.map_err(|e| PyValueError::new_err(format!("Invalid timeout: {e}")))?,
322-
)
323-
.build()
324-
.map_err(|e| {
325-
PyValueError::new_err(format!("Failed to build HTTP client: {e:?}"))
326-
})?;
327-
client_builder = client_builder.with_http_client(http_client);
328-
}
329-
let client = match client_builder.build_http() {
330-
Ok(client) => client,
331-
Err(e) => {
332-
return Err(tensorzero_core_error(
333-
py,
334-
&format!("Failed to construct TensorZero client: {e:?}"),
335-
)?);
336-
}
337-
};
338-
339-
Ok(Self {
340-
client: DropInTokio::new(client, make_dummy_client),
341-
})
342-
}
343-
344304
#[pyo3(signature = (*, input, function_name=None, model_name=None, episode_id=None, stream=None, params=None, variant_name=None, dryrun=None, output_schema=None, allowed_tools=None, provider_tools=None, additional_tools=None, tool_choice=None, parallel_tool_calls=None, internal=None, tags=None, credentials=None, cache_options=None, extra_body=None, extra_headers=None, include_original_response=None, otlp_traces_extra_headers=None, internal_dynamic_variant_config=None))]
345305
#[expect(clippy::too_many_arguments)]
346306
fn _prepare_inference_request(
@@ -581,47 +541,34 @@ impl BaseTensorZeroGateway {
581541
}
582542
#[pymethods]
583543
impl TensorZeroGateway {
584-
#[new]
585-
#[pyo3(signature = (base_url, *, timeout=None))]
586-
fn new(
587-
py: Python<'_>,
588-
base_url: &str,
589-
timeout: Option<f64>,
590-
) -> PyResult<(Self, BaseTensorZeroGateway)> {
591-
tracing::warn!("TensorZeroGateway.__init__ is deprecated. Use TensorZeroGateway.build_http or TensorZeroGateway.build_embedded instead.");
592-
Ok((
593-
Self {},
594-
BaseTensorZeroGateway::new(py, base_url, timeout, false)?,
595-
))
596-
}
597-
598544
#[classmethod]
599-
#[pyo3(signature = (*, gateway_url, timeout=None, verbose_errors=false))]
545+
#[pyo3(signature = (*, gateway_url, timeout=None, verbose_errors=false, api_key=None))]
600546
/// Initialize the TensorZero client, using the HTTP gateway.
601547
/// :param gateway_url: The base URL of the TensorZero gateway. Example: "http://localhost:3000"
602548
/// :param timeout: The timeout for the HTTP client in seconds. If not provided, no timeout will be set.
603549
/// :param verbose_errors: If true, the client will increase the detail in errors (increasing the risk of leaking sensitive information).
550+
/// :param api_key: The API key to use for authentication with the TensorZero Gateway. If not provided, the client will attempt to read from the TENSORZERO_API_KEY environment variable.
604551
/// :return: A `TensorZeroGateway` instance configured to use the HTTP gateway.
605552
fn build_http(
606553
cls: &Bound<'_, PyType>,
607554
gateway_url: &str,
608555
timeout: Option<f64>,
609556
verbose_errors: bool,
557+
api_key: Option<String>,
610558
) -> PyResult<Py<TensorZeroGateway>> {
611559
let mut client_builder = ClientBuilder::new(ClientBuilderMode::HTTPGateway {
612560
url: Url::parse(gateway_url)
613561
.map_err(|e| PyValueError::new_err(format!("Invalid gateway URL: {e}")))?,
614562
})
615563
.with_verbose_errors(verbose_errors);
564+
if let Some(api_key) = api_key {
565+
client_builder = client_builder.with_api_key(api_key);
566+
}
616567
if let Some(timeout) = timeout {
617-
let http_client = reqwest::Client::builder()
618-
.timeout(
619-
Duration::try_from_secs_f64(timeout)
620-
.map_err(|e| PyValueError::new_err(format!("Invalid timeout: {e}")))?,
621-
)
622-
.build()
623-
.map_err(|e| PyValueError::new_err(format!("Failed to build HTTP client: {e}")))?;
624-
client_builder = client_builder.with_http_client(http_client);
568+
client_builder = client_builder.with_timeout(
569+
Duration::try_from_secs_f64(timeout)
570+
.map_err(|e| PyValueError::new_err(format!("Invalid timeout: {e}")))?,
571+
);
625572
}
626573
let client_fut = client_builder.build();
627574
let client_res = tokio_block_on_without_gil(cls.py(), client_fut);
@@ -641,18 +588,6 @@ impl TensorZeroGateway {
641588
Py::new(cls.py(), instance)
642589
}
643590

644-
/// **Deprecated** (use `build_http` or `build_embedded` instead)
645-
/// Initialize the TensorZero client.
646-
///
647-
/// :param base_url: The base URL of the TensorZero gateway. Example: "http://localhost:3000"
648-
/// :param timeout: The timeout for the HTTP client in seconds. If not provided, no timeout will be set.
649-
#[expect(unused_variables)]
650-
#[pyo3(signature = (base_url, *, timeout=None))]
651-
fn __init__(this: Py<Self>, base_url: &str, timeout: Option<f64>) -> Py<Self> {
652-
// The actual logic is in the 'new' method - this method just exists to generate a docstring
653-
this
654-
}
655-
656591
/// Close the connection to the TensorZero gateway.
657592
#[expect(clippy::unused_self)]
658593
fn close(&self) {
@@ -1391,46 +1326,33 @@ struct AsyncTensorZeroGateway {}
13911326

13921327
#[pymethods]
13931328
impl AsyncTensorZeroGateway {
1394-
#[new]
1395-
#[pyo3(signature = (base_url, *, timeout=None))]
1396-
fn new(
1397-
py: Python<'_>,
1398-
base_url: &str,
1399-
timeout: Option<f64>,
1400-
) -> PyResult<(Self, BaseTensorZeroGateway)> {
1401-
tracing::warn!("AsyncTensorZeroGateway.__init__ is deprecated. Use AsyncTensorZeroGateway.build_http or AsyncTensorZeroGateway.build_embedded instead.");
1402-
Ok((
1403-
Self {},
1404-
BaseTensorZeroGateway::new(py, base_url, timeout, false)?,
1405-
))
1406-
}
1407-
14081329
#[classmethod]
1409-
#[pyo3(signature = (*, gateway_url, timeout=None, verbose_errors=false, async_setup=true))]
1330+
#[pyo3(signature = (*, gateway_url, timeout=None, verbose_errors=false, async_setup=true, api_key=None))]
14101331
/// Initialize the TensorZero client, using the HTTP gateway.
14111332
/// :param gateway_url: The base URL of the TensorZero gateway. Example: "http://localhost:3000"
14121333
/// :param timeout: The timeout for the HTTP client in seconds. If not provided, no timeout will be set.
14131334
/// :param verbose_errors: If true, the client will increase the detail in errors (increasing the risk of leaking sensitive information).
14141335
/// :param async_setup: If true, this method will return a `Future` that resolves to an `AsyncTensorZeroGateway` instance. Otherwise, it will block and construct the `AsyncTensorZeroGateway`
1336+
/// :param api_key: The API key to use for authentication with the TensorZero Gateway. If not provided, the client will attempt to read from the TENSORZERO_API_KEY environment variable.
14151337
/// :return: An `AsyncTensorZeroGateway` instance configured to use the HTTP gateway.
14161338
fn build_http(
14171339
cls: &Bound<'_, PyType>,
14181340
gateway_url: &str,
14191341
timeout: Option<f64>,
14201342
verbose_errors: bool,
14211343
async_setup: bool,
1344+
api_key: Option<String>,
14221345
) -> PyResult<Py<PyAny>> {
14231346
let mut client_builder = ClientBuilder::new(ClientBuilderMode::HTTPGateway {
14241347
url: Url::parse(gateway_url)
14251348
.map_err(|e| PyValueError::new_err(format!("Invalid gateway URL: {e}")))?,
14261349
})
14271350
.with_verbose_errors(verbose_errors);
1351+
if let Some(api_key) = api_key {
1352+
client_builder = client_builder.with_api_key(api_key);
1353+
}
14281354
if let Some(timeout) = timeout {
1429-
let http_client = reqwest::Client::builder()
1430-
.timeout(Duration::from_secs_f64(timeout))
1431-
.build()
1432-
.map_err(|e| PyValueError::new_err(format!("Failed to build HTTP client: {e}")))?;
1433-
client_builder = client_builder.with_http_client(http_client);
1355+
client_builder = client_builder.with_timeout(Duration::from_secs_f64(timeout));
14341356
}
14351357
let client_fut = client_builder.build();
14361358
let build_gateway = async move {
@@ -1463,18 +1385,6 @@ impl AsyncTensorZeroGateway {
14631385
}
14641386
}
14651387

1466-
/// **Deprecated** (use `build_http` or `build_embedded` instead)
1467-
/// Initialize the TensorZero client.
1468-
///
1469-
/// :param base_url: The base URL of the TensorZero gateway. Example: "http://localhost:3000"
1470-
/// :param timeout: The timeout for the HTTP client in seconds. If not provided, no timeout will be set.
1471-
#[expect(unused_variables)]
1472-
#[pyo3(signature = (base_url, *, timeout=None))]
1473-
fn __init__(this: Py<Self>, base_url: &str, timeout: Option<f64>) -> Py<Self> {
1474-
// The actual logic is in the 'new' method - this method just exists to generate a docstring
1475-
this
1476-
}
1477-
14781388
/// Close the connection to the TensorZero gateway.
14791389
async fn close(&self) {
14801390
// TODO - implement closing the 'reqwest' connection pool: https://github.com/tensorzero/tensorzero/issues/857

0 commit comments

Comments
 (0)