arize-phoenix 4.30.2__py3-none-any.whl → 4.31.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of arize-phoenix might be problematic. Click here for more details.

phoenix/trace/fixtures.py CHANGED
@@ -8,7 +8,18 @@ from io import StringIO
8
8
  from random import getrandbits
9
9
  from tempfile import NamedTemporaryFile
10
10
  from time import sleep, time
11
- from typing import Dict, Iterable, Iterator, List, NamedTuple, Optional, Sequence, Tuple, cast
11
+ from typing import (
12
+ DefaultDict,
13
+ Dict,
14
+ Iterable,
15
+ Iterator,
16
+ List,
17
+ NamedTuple,
18
+ Optional,
19
+ Sequence,
20
+ Tuple,
21
+ cast,
22
+ )
12
23
  from urllib.parse import urljoin
13
24
 
14
25
  import httpx
@@ -20,7 +31,11 @@ import phoenix.trace.v1 as pb
20
31
  from phoenix import Client
21
32
  from phoenix.trace.schemas import Span
22
33
  from phoenix.trace.trace_dataset import TraceDataset
23
- from phoenix.trace.utils import download_json_traces_fixture, is_jsonl_file, json_lines_to_df
34
+ from phoenix.trace.utils import (
35
+ download_json_traces_fixture,
36
+ json_lines_to_df,
37
+ parse_file_extension,
38
+ )
24
39
 
25
40
  logger = logging.getLogger(__name__)
26
41
  logger.setLevel(logging.INFO)
@@ -58,7 +73,23 @@ class DatasetFixture:
58
73
 
59
74
  def load(self) -> "DatasetFixture":
60
75
  if self._df is None:
61
- df = pd.read_csv(_url(self.file_name))
76
+ url = _url(self.file_name)
77
+
78
+ if parse_file_extension(self.file_name) == ".jsonl":
79
+ df = json_lines_to_df(download_json_traces_fixture(url))
80
+ elif parse_file_extension(self.file_name) == ".csv":
81
+ df = pd.read_csv(_url(self.file_name))
82
+ else:
83
+ try:
84
+ df = pd.read_parquet(url)
85
+ except Exception:
86
+ logger.warning(
87
+ f"Failed to download example traces from {url=} "
88
+ "due to exception {e=}. "
89
+ "Returning empty dataframe for DatasetFixture"
90
+ )
91
+ df = pd.DataFrame()
92
+
62
93
  object.__setattr__(self, "_df", df)
63
94
  return self
64
95
 
@@ -105,6 +136,15 @@ demo_llama_index_rag_fixture = TracesFixture(
105
136
  file_name="demo_llama_index_rag_doc_relevance_eval.parquet",
106
137
  ),
107
138
  ),
139
+ dataset_fixtures=(
140
+ DatasetFixture(
141
+ file_name="demo_llama_index_finetune_dataset.jsonl",
142
+ input_keys=("messages",),
143
+ output_keys=("messages",),
144
+ name="Demo LlamaIndex: RAG Q&A",
145
+ description="OpenAI GPT-3.5 LLM dataset for LlamaIndex demo",
146
+ ),
147
+ ),
108
148
  )
109
149
 
110
150
  demo_llama_index_rag_llm_fixture = TracesFixture(
@@ -225,7 +265,7 @@ TRACES_FIXTURES: List[TracesFixture] = [
225
265
  NAME_TO_TRACES_FIXTURE: Dict[str, TracesFixture] = {
226
266
  fixture.name: fixture for fixture in TRACES_FIXTURES
227
267
  }
228
- PROJ_NAME_TO_TRACES_FIXTURE = defaultdict(list)
268
+ PROJ_NAME_TO_TRACES_FIXTURE: DefaultDict[str, List[TracesFixture]] = defaultdict(list)
229
269
  for fixture in TRACES_FIXTURES:
230
270
  if fixture.project_name:
231
271
  PROJ_NAME_TO_TRACES_FIXTURE[fixture.project_name].append(fixture)
@@ -268,14 +308,10 @@ def load_example_traces(fixture_name: str) -> TraceDataset:
268
308
  """
269
309
  Loads a trace dataframe by name.
270
310
  """
271
- host = "https://storage.googleapis.com/"
272
- bucket = "arize-phoenix-assets"
273
- prefix = "traces/"
274
311
  fixture = get_trace_fixture_by_name(fixture_name)
312
+ url = _url(fixture.file_name)
275
313
 
276
- url = f"{host}{bucket}/{prefix}{fixture.file_name}"
277
-
278
- if is_jsonl_file(fixture.file_name):
314
+ if parse_file_extension(fixture.file_name) == ".jsonl":
279
315
  return TraceDataset(json_lines_to_df(download_json_traces_fixture(url)))
280
316
 
281
317
  try:
phoenix/trace/utils.py CHANGED
@@ -8,14 +8,8 @@ from urllib import request
8
8
  import pandas as pd
9
9
 
10
10
 
11
- def is_jsonl_file(file_path: str) -> bool:
12
- """
13
- Check if the given file is a Parquet file.
14
- """
15
- file_extension = os.path.splitext(file_path)[-1]
16
- if file_extension == ".jsonl":
17
- return True
18
- return False
11
+ def parse_file_extension(file_path: str) -> str:
12
+ return os.path.splitext(file_path)[-1]
19
13
 
20
14
 
21
15
  def download_json_traces_fixture(
phoenix/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "4.30.2"
1
+ __version__ = "4.31.0"