Skip to content

Commit

Permalink
fix mimetype encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Apr 2, 2024
1 parent 701e94d commit 60985f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/phoenix/server/api/types/MimeType.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

@strawberry.enum
class MimeType(Enum):
text = trace_schemas.MimeType.TEXT
json = trace_schemas.MimeType.JSON
text = trace_schemas.MimeType.TEXT.value
json = trace_schemas.MimeType.JSON.value

@classmethod
def _missing_(cls, v: Any) -> Optional["MimeType"]:
Expand Down
19 changes: 12 additions & 7 deletions src/phoenix/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
██████╔╝███████║██║ ██║█████╗ ██╔██╗ ██║██║ ╚███╔╝
██╔═══╝ ██╔══██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██╔██╗
██║ ██║ ██║╚██████╔╝███████╗██║ ╚████║██║██╔╝ ██╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ v{0}
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ v{version}
|
| 🌎 Join our Community 🌎
Expand All @@ -63,9 +63,9 @@
| https://docs.arize.com/phoenix
|
| 🚀 Phoenix Server 🚀
| Phoenix UI: http://{1}:{2}
| Phoenix UI: http://{host}:{port}
| Log traces: /v1/traces over HTTP
|
| Storage location: {working_dir}
"""


Expand Down Expand Up @@ -195,7 +195,8 @@ def _load_items(
primary_dataset,
reference_dataset,
)
db = SqliteDatabase(get_working_dir() / "phoenix.db")
working_dir = get_working_dir()
db = SqliteDatabase(working_dir / "phoenix.db")
traces = Traces(db)
if span_store := get_span_store():
Thread(target=load_traces_data_from_store, args=(traces, span_store), daemon=True).start()
Expand Down Expand Up @@ -249,9 +250,13 @@ def _load_items(

# Print information about the server
phoenix_version = pkg_resources.get_distribution("arize-phoenix").version
print(
_WELCOME_MESSAGE.format(phoenix_version, host if host != "0.0.0.0" else "localhost", port)
)
config = {
"version": phoenix_version,
"host": host,
"port": port,
"working_dir": working_dir,
}
print(_WELCOME_MESSAGE.format(**config))

# Start the server
server.run()
5 changes: 2 additions & 3 deletions src/phoenix/trace/otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
EXCEPTION_MESSAGE,
EXCEPTION_STACKTRACE,
EXCEPTION_TYPE,
MimeType,
Span,
SpanContext,
SpanEvent,
Expand Down Expand Up @@ -68,7 +67,7 @@ def decode(otlp_span: otlp.Span) -> Span:

for mime_type in (INPUT_MIME_TYPE, OUTPUT_MIME_TYPE):
if mime_type in attributes:
attributes[mime_type] = MimeType(attributes[mime_type])
attributes[mime_type] = attributes[mime_type]

status_code, status_message = _decode_status(otlp_span.status)
events = [_decode_event(event) for event in otlp_span.events]
Expand Down Expand Up @@ -318,7 +317,7 @@ def encode(span: Span) -> otlp.Span:

for mime_type in (INPUT_MIME_TYPE, OUTPUT_MIME_TYPE):
if mime_type in attributes:
attributes[mime_type] = attributes[mime_type].value
attributes[mime_type] = attributes[mime_type]

for key, value in span.attributes.items():
if value is None:
Expand Down

0 comments on commit 60985f4

Please sign in to comment.