diff --git a/python/langsmith/client.py b/python/langsmith/client.py index c3a49f337..b3b5fc993 100644 --- a/python/langsmith/client.py +++ b/python/langsmith/client.py @@ -369,7 +369,6 @@ class Client: "_write_api_urls", "_settings", "_manual_cleanup", - "_pyo3_client", ] def __init__( @@ -517,54 +516,6 @@ def __init__( else ls_utils.get_env_var("HIDE_OUTPUTS") == "true" ) - # To set this up on the Rust side: - # - Navigate to the rust/crates/langsmith-pyo3 directory. - # - Run: - # maturin build --release - # - Then, back inside python/langsmith, run: - # poetry install --with pyo3 - # - # To trigger this code, set the `LANGSMITH_USE_PYO3_CLIENT` env var to any value. - # - # Currently this requires Python 3.13 since the Poetry setup references the 3.13 wheel. - # Once the PyO3 package is uploaded to PyPI, we won't have to specify the *wheel* itself - # and can instead reference the *PyPI package name*. That will allow Poetry to choose - # a wheel that matches the locally-installed version of Python. - self._pyo3_client = None - if ls_utils.get_env_var("USE_PYO3_CLIENT") is not None: - langsmith_pyo3 = None - try: - import langsmith_pyo3 - except ImportError as e: - logger.warning( - "Failed to import `langsmith_pyo3` when PyO3 client was requested, " - "falling back to Python impl: %s", - repr(e), - ) - - if langsmith_pyo3: - # TODO: tweak these constants as needed - queue_capacity = 1_000_000 - batch_size = 100 - batch_timeout_millis = 1000 - worker_threads = 1 - - try: - self._pyo3_client = langsmith_pyo3.BlockingTracingClient( - self.api_url, - self.api_key, - queue_capacity, - batch_size, - batch_timeout_millis, - worker_threads, - ) - except Exception as e: - logger.warning( - "Failed to instantiate `langsmith_pyo3.BlockingTracingClient` " - "when PyO3 client was requested, falling back to Python impl: %s", - repr(e), - ) - self._settings: Union[ls_schemas.LangSmithSettings, None] = None self._manual_cleanup = False @@ -1275,26 +1226,16 @@ def create_run( copy=False, ) self._insert_runtime_env([run_create]) - if ( + self.tracing_queue is not None # batch ingest requires trace_id and dotted_order to be set - run_create.get("trace_id") is not None + and run_create.get("trace_id") is not None and run_create.get("dotted_order") is not None ): - if self._pyo3_client is not None: - # `self._run_transform()` above turns the `id` key into a `UUID` object. - # We need to pass a string since `orjson` doesn't seem to serialize `UUID` objects. - run_create["id"] = str(run_create["id"]) - self._pyo3_client.create_run(run_create) - elif self.tracing_queue is not None: - serialized_op = serialize_run_dict("post", run_create) - self.tracing_queue.put( - TracingQueueItem(run_create["dotted_order"], serialized_op) - ) - else: - # Neither Rust nor Python batch ingestion is configured, - # fall back to the non-batch approach. - self._create_run(run_create) + serialized_op = serialize_run_dict("post", run_create) + self.tracing_queue.put( + TracingQueueItem(run_create["dotted_order"], serialized_op) + ) else: self._create_run(run_create) diff --git a/python/poetry.lock b/python/poetry.lock index c20503c2e..2b362f986 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "annotated-types" @@ -590,20 +590,6 @@ files = [ {file = "jiter-0.7.0.tar.gz", hash = "sha256:c061d9738535497b5509f8970584f20de1e900806b239a39a9994fc191dad630"}, ] -[[package]] -name = "langsmith-pyo3" -version = "0.1.0" -description = "" -optional = false -python-versions = ">=3.8" -files = [ - {file = "langsmith_pyo3-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl", hash = "sha256:ad2ed04b910c5aaf4d5b8c3f97409a6e0ba5e20f5159a54f4c2e3abf64fae4cd"}, -] - -[package.source] -type = "file" -url = "../rust/target/wheels/langsmith_pyo3-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl" - [[package]] name = "marshmallow" version = "3.22.0" @@ -2084,4 +2070,4 @@ vcr = [] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "da81a1c72795bd7fdb2d039621adfcdc760b3b452936c79b45f9ac015a6c6b9e" +content-hash = "a5a6c61cba1b5ce9cf739700a780c2df63ff7aaa482c29de9910418263318586" diff --git a/python/pyproject.toml b/python/pyproject.toml index df2649123..51dfb7e3f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -69,9 +69,6 @@ openai = "^1.10" [tool.poetry.group.test.dependencies] pytest-socket = "^0.7.0" -[tool.poetry.group.pyo3.dependencies] -langsmith-pyo3 = {path = "../rust/target/wheels/langsmith_pyo3-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl"} - [tool.poetry.extras] vcr = ["vcrpy"]