Skip to content

Commit

Permalink
feat!: Remove legacy instrumentation modules (#4604)
Browse files Browse the repository at this point in the history
* feat!: Remove legacy instrumentation modules

* Ruff 🐶

* Use correct llama_index instrumentor import in example

* Remove dependencies on openinference instrumentors

* Restore openinference-instrumentation dependency

* Mention OpenTelemetry instrumentors first
  • Loading branch information
anticorrelator authored Sep 13, 2024
1 parent 3174195 commit bbcc24f
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 181 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ dependencies = [
"opentelemetry-semantic-conventions",
"openinference-semantic-conventions>=0.1.9",
"openinference-instrumentation>=0.1.12",
"openinference-instrumentation-langchain>=0.1.26",
"openinference-instrumentation-llama-index>=2.2.1",
"openinference-instrumentation-openai>=0.1.11",
"sqlalchemy[asyncio]>=2.0.4, <3",
"alembic>=1.3.0, <2",
"aiosqlite",
Expand Down
86 changes: 86 additions & 0 deletions src/phoenix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import sys
from importlib.abc import Loader, MetaPathFinder
from importlib.machinery import ModuleSpec
from types import ModuleType
from typing import Any, Optional

from .inferences.fixtures import ExampleInferences, load_example
from .inferences.inferences import Inferences
from .inferences.schema import EmbeddingColumnNames, RetrievalEmbeddingColumnNames, Schema
Expand Down Expand Up @@ -51,3 +57,83 @@
"Client",
"evals",
]


class PhoenixTraceFinder(MetaPathFinder):
def find_spec(self, fullname: Any, path: Any, target: Any = None) -> Optional[ModuleSpec]:
if fullname == "phoenix.trace.openai":
return ModuleSpec(fullname, PhoenixTraceOpenAILoader())
if fullname == "phoenix.trace.langchain":
return ModuleSpec(fullname, PhoenixTraceLangchainLoader())
if fullname == "phoenix.trace.llama_index":
return ModuleSpec(fullname, PhoenixTraceLlamaIndexLoader())
return None


class PhoenixTraceOpenAILoader(Loader):
def create_module(self, spec: ModuleSpec) -> None:
return None

def exec_module(self, module: ModuleType) -> None:
raise ImportError(
"The legacy `phoenix.trace.openai` instrumentor module has been removed.\n"
"Please use OpenInference to instrument the OpenAI SDK. Additionally, the "
"`phoenix.otel` module can be used to quickly configure OpenTelemetry:\n\n"
"https://docs.arize.com/phoenix/tracing/integrations-tracing/openai"
"\n\n"
"Example usage:\n\n"
"```python\n"
"from phoenix.otel register\n"
"from openinference.instrumentation.openai import OpenAIInstrumentor\n\n"
"tracer_provider = register()\n"
"OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)\n"
"```\n"
)


class PhoenixTraceLangchainLoader(Loader):
def create_module(self, spec: ModuleSpec) -> None:
return None

"Please use OpenInference to instrument the Langchain SDK. Additionally, the `phoenix.otel` "
"module can be used to quickly configure OpenTelemetry:\n\n"

def exec_module(self, module: ModuleType) -> None:
raise ImportError(
"The legacy `phoenix.trace.langchain` instrumentor module has been removed.\n"
"Please use OpenInference to instrument the LangChain SDK. Additionally, the "
"`phoenix.otel` module can be used to quickly configure OpenTelemetry:\n\n"
"https://docs.arize.com/phoenix/tracing/integrations-tracing/langchain"
"\n\n"
"Example usage:\n\n"
"```python\n"
"from phoenix.otel import register\n"
"from openinference.instrumentation.langchain import LangChainInstrumentor\n\n"
"tracer_provider = register()\n"
"LangChainInstrumentor().instrument(tracer_provider=tracer_provider)\n"
"```\n"
)


class PhoenixTraceLlamaIndexLoader(Loader):
def create_module(self, spec: ModuleSpec) -> None:
return None

def exec_module(self, module: ModuleType) -> None:
raise ImportError(
"The legacy `phoenix.trace.llama_index` instrumentor module has been removed.\n"
"Please use OpenInference to instrument the LlamaIndex SDK. Additionally, the "
"`phoenix.otel` module can be used to quickly configure OpenTelemetry:\n\n"
"https://docs.arize.com/phoenix/tracing/integrations-tracing/llamaindex"
"\n\n"
"Example usage:\n\n"
"```python\n"
"from phoenix.otel import register\n"
"from openinference.instrumentation.llama_index import LlamaIndexInstrumentor\n\n"
"tracer_provider = register()\n"
"LlamaIndexInstrumentor().instrument(tracer_provider=tracer_provider)\n"
"```\n"
)


sys.meta_path.append(PhoenixTraceFinder())
3 changes: 0 additions & 3 deletions src/phoenix/trace/langchain/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions src/phoenix/trace/langchain/instrumentor.py

This file was deleted.

3 changes: 0 additions & 3 deletions src/phoenix/trace/llama_index/__init__.py

This file was deleted.

103 changes: 0 additions & 103 deletions src/phoenix/trace/llama_index/callback.py

This file was deleted.

3 changes: 0 additions & 3 deletions src/phoenix/trace/openai/__init__.py

This file was deleted.

31 changes: 0 additions & 31 deletions src/phoenix/trace/openai/instrumentor.py

This file was deleted.

0 comments on commit bbcc24f

Please sign in to comment.