arize-phoenix 0.0.2rc3__py3-none-any.whl → 0.0.2rc5__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.

@@ -35,8 +35,16 @@ class Session:
35
35
  )
36
36
  self._is_colab = _is_colab()
37
37
 
38
- def view(self, height: int = 500) -> "IFrame":
39
- # Display the app in an iframe
38
+ def view(self, height: int = 1000) -> "IFrame":
39
+ """
40
+ Returns an IFrame that can be displayed in a notebook to view the app.
41
+
42
+ Parameters
43
+ ----------
44
+ height : int, optional
45
+ The height of the IFrame in pixels. Defaults to 1000.
46
+ """
47
+ print(f"📺 Opening a view to the Phoenix app. The app is running at {self.url}")
40
48
  return IFrame(src=self.url, width="100%", height=height)
41
49
 
42
50
  @cached_property
@@ -72,20 +80,54 @@ def _wait_for_boot(url: str, polling_interval_secs: int = 1, max_retries: int =
72
80
 
73
81
 
74
82
  def launch_app(
75
- primary: Dataset, reference: Optional[Dataset], wait_for_boot: Optional[bool] = True
83
+ primary: Dataset, reference: Optional[Dataset] = None, wait_for_boot: Optional[bool] = True
76
84
  ) -> "Session":
77
- "Launches the phoenix application"
85
+ """
86
+ Launches the phoenix application and returns a session to interact with.
87
+
88
+ Parameters
89
+ ----------
90
+ primary : Dataset required
91
+ The primary dataset to analyze
92
+ reference : Dataset, optional
93
+ The reference dataset to compare against.
94
+ If not provided, drift analysis will not be available.
95
+
96
+ Returns
97
+ -------
98
+ session : Session
99
+ The session object that can be used to view the application
100
+
101
+ Examples
102
+ --------
103
+ >>> import phoenix as px
104
+ >>> # construct a dataset to analyze
105
+ >>> dataset = px.Dataset(...)
106
+ >>> session = px.launch_app(dataset)
107
+ """
78
108
  global _session
79
109
 
80
110
  _session = Session(primary, reference, port=config.port)
81
111
  if wait_for_boot:
82
112
  _wait_for_boot(_session.url)
113
+ print(f"🌍 To view the Phoenix app in your browser, visit {_session.url}")
114
+ print("📺 To view the Phoenix app in a notebook, run `px.active_session().view()`")
115
+ print("📖 For more information on how to use Phoenix, check out https://docs.arize.com/phoenix")
116
+ return _session
117
+
83
118
 
119
+ def active_session() -> Optional["Session"]:
120
+ """
121
+ Returns the active session if one exists, otherwise returns None
122
+ """
84
123
  return _session
85
124
 
86
125
 
87
126
  def close_app() -> None:
88
- "Closes the phoenix application"
127
+ """
128
+ Closes the phoenix application.
129
+ The application server is shut down and will no longer be accessible.
130
+ """
89
131
  global _session
90
132
  if _session is None:
91
133
  print("No active session to close")
@@ -96,7 +138,7 @@ def close_app() -> None:
96
138
 
97
139
 
98
140
  def _get_url(port: int, is_colab: bool) -> str:
99
- """Determines the iframe url based on whether this is in a Colab"""
141
+ """Determines the iframe url based on whether this is in a colab or in a local notebook"""
100
142
  if is_colab:
101
143
  from google.colab.output import eval_js # type: ignore
102
144
 
@@ -1,36 +0,0 @@
1
- import math
2
- from datetime import datetime
3
- from typing import Iterable, cast
4
-
5
- import pandas as pd
6
- import strawberry
7
-
8
- from phoenix.metrics import Metric
9
-
10
- from .TimeSeries import TimeSeries, TimeSeriesDataPoint
11
-
12
-
13
- @strawberry.type
14
- class DataQualityTimeSeries(TimeSeries):
15
- """A time series of data quality metrics"""
16
-
17
- ...
18
-
19
-
20
- def to_gql_timeseries(
21
- df: pd.DataFrame, metric: Metric, timestamps: Iterable[datetime]
22
- ) -> DataQualityTimeSeries:
23
- data = []
24
- for timestamp in timestamps:
25
- try:
26
- row = df.iloc[cast(int, df.index.get_loc(timestamp)), :].to_dict()
27
- except KeyError:
28
- row = {}
29
- value = metric.get_value(row)
30
- data.append(
31
- TimeSeriesDataPoint(
32
- timestamp=timestamp,
33
- value=None if math.isnan(value) else value,
34
- )
35
- )
36
- return DataQualityTimeSeries(data=sorted(data))
@@ -1,10 +0,0 @@
1
- import strawberry
2
-
3
- from .TimeSeries import TimeSeries
4
-
5
-
6
- @strawberry.type
7
- class DriftTimeSeries(TimeSeries):
8
- """A time series of drift metrics"""
9
-
10
- ...