Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2815 launch app with persist #2829

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
afd368d
feat(persistence): sql persistence
mikeldking Apr 1, 2024
fad0009
refactor: sqlite3 proof of concept (#2740)
RogerHYang Apr 2, 2024
d05454b
refactor: sqlite with SQLAlchemy (#2747)
RogerHYang Apr 3, 2024
8f79e29
initialize alembic
mikeldking Apr 4, 2024
4272f5c
make alembic path to DB dynamic
mikeldking Apr 4, 2024
2dbe17f
move migrations over
mikeldking Apr 4, 2024
595400f
remove init_db
mikeldking Apr 4, 2024
3ef525d
finish out the migration
mikeldking Apr 4, 2024
8c10e46
WIP'
mikeldking Apr 4, 2024
ca5a23d
make it work
mikeldking Apr 4, 2024
fdf2507
add contraints naming conventions
mikeldking Apr 4, 2024
27a87e8
Update src/phoenix/db/migrate.py
mikeldking Apr 4, 2024
5f26302
Update src/phoenix/db/migrate.py
mikeldking Apr 4, 2024
a4d4c88
restore log level
mikeldking Apr 4, 2024
b56820d
Merge pull request #2748 from Arize-ai/migrate
mikeldking Apr 4, 2024
30b2ab0
refactor: sqlite async session for graphql api (#2784)
RogerHYang Apr 5, 2024
a2657d4
feat(experimental): postgres support
mikeldking Apr 6, 2024
5299634
WIP
mikeldking Apr 8, 2024
058b1fe
WIP
mikeldking Apr 8, 2024
3b36473
postgres support
mikeldking Apr 8, 2024
c4b7089
add pg support
mikeldking Apr 8, 2024
f977bf5
Cleanup
mikeldking Apr 8, 2024
b8b01f8
remove hardcoded db
mikeldking Apr 8, 2024
46521ef
make url preserve password etc.
mikeldking Apr 8, 2024
80048d9
Merge pull request #2796 from Arize-ai/2793-postgres
mikeldking Apr 8, 2024
b6d508d
fix: fix docker build for sql
mikeldking Apr 8, 2024
399a9f6
Merge pull request #2812 from Arize-ai/fix-sql-docker-build
mikeldking Apr 8, 2024
9ce841e
feat(persistence): bulk inserter for spans (#2808)
RogerHYang Apr 8, 2024
7f907f0
add a reset
mikeldking Apr 8, 2024
9d53d12
mount sqlite
mikeldking Apr 8, 2024
d0cfc8e
WIP
mikeldking Apr 8, 2024
6a8d40a
run async as task
mikeldking Apr 9, 2024
1c60e75
feat: use non-memory sqlite in the notebook
mikeldking Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Python CI

on:
push:
branches: [main]
branches: [main, sql]
pull_request:
paths:
- "src/**"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COPY ./ /phoenix/
COPY --from=frontend-builder /phoenix/src/phoenix/server/static/ /phoenix/src/phoenix/server/static/
# Delete symbolic links used during development.
RUN find src/ -xtype l -delete
RUN pip install --target ./env .[container]
RUN pip install --target ./env ".[container, pg]"

# The production image is distroless, meaning that it is a minimal image that
# contains only the necessary dependencies to run the application. This is
Expand Down
4 changes: 2 additions & 2 deletions app/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ type Project implements Node {
endTime: DateTime
recordCount(timeRange: TimeRange): Int!
traceCount(timeRange: TimeRange): Int!
tokenCountTotal: Int!
tokenCountTotal(timeRange: TimeRange): Int!
latencyMsP50: Float
latencyMsP99: Float
trace(traceId: ID!): Trace
spans(timeRange: TimeRange, traceIds: [ID!], first: Int = 50, last: Int, after: String, before: String, sort: SpanSort, rootSpansOnly: Boolean, filterCondition: String): SpanConnection!
spans(timeRange: TimeRange, first: Int = 50, last: Int, after: String, before: String, sort: SpanSort, rootSpansOnly: Boolean, filterCondition: String): SpanConnection!

"""
Names of all available evaluations for traces. (The list contains no duplicates.)
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"respx",
"rgba",
"seafoam",
"sqlalchemy",
"Starlette",
"templating",
"tensorboard",
"testset",
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ dependencies = [
"openinference-instrumentation-langchain>=0.1.12",
"openinference-instrumentation-llama-index>=1.2.0",
"openinference-instrumentation-openai>=0.1.4",
"sqlalchemy>=2, <3",
"alembic>=1.3.0, <2",
"aiosqlite",
]
dynamic = ["version"]

Expand Down Expand Up @@ -86,6 +89,11 @@ llama-index = [
"llama-index-callbacks-arize-phoenix>=0.1.2",
"openinference-instrumentation-llama-index>=1.2.0",
]

pg = [
"asyncpg",
]

container = [
"prometheus-client",
]
Expand Down
10 changes: 9 additions & 1 deletion src/phoenix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
from .datasets.schema import EmbeddingColumnNames, RetrievalEmbeddingColumnNames, Schema
from .session.client import Client
from .session.evaluation import log_evaluations
from .session.session import NotebookEnvironment, Session, active_session, close_app, launch_app
from .session.session import (
NotebookEnvironment,
Session,
active_session,
close_app,
launch_app,
reset_all,
)
from .trace.fixtures import load_example_traces
from .trace.trace_dataset import TraceDataset
from .version import __version__
Expand Down Expand Up @@ -41,6 +48,7 @@
"active_session",
"close_app",
"launch_app",
"reset_all",
"Session",
"load_example_traces",
"TraceDataset",
Expand Down
12 changes: 12 additions & 0 deletions src/phoenix/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"""
The project name to use when logging traces and evals. defaults to 'default'.
"""
ENV_PHOENIX_SQL_DATABASE = "__DANGEROUS__PHOENIX_SQL_DATABASE"
"""
The database URL to use when logging traces and evals.
"""
ENV_SPAN_STORAGE_TYPE = "__DANGEROUS__PHOENIX_SPAN_STORAGE_TYPE"
"""
**EXPERIMENTAL**
Expand Down Expand Up @@ -152,6 +156,14 @@ def get_env_span_storage_type() -> Optional["SpanStorageType"]:
)


def get_env_database_connection_str() -> str:
env_url = os.getenv(ENV_PHOENIX_SQL_DATABASE)
if env_url is None:
working_dir = get_working_dir()
return f"sqlite:///{working_dir}/phoenix.db"
return env_url


class SpanStorageType(Enum):
TEXT_FILES = "text-files"

Expand Down
3 changes: 3 additions & 0 deletions src/phoenix/db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .migrate import migrate

__all__ = ["migrate"]
119 changes: 119 additions & 0 deletions src/phoenix/db/alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
# Note this is overridden in .migrate during programatic migrations
script_location = migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .

# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python>=3.9 or backports.zoneinfo library.
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =

# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; This defaults
# to migrations/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions

# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.

# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

# NB: This is commented out intentionally as it is dynamic
# See migrations/env.py
# sqlalchemy.url = driver://user:pass@localhost/dbname


[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples

# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME

# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
# hooks = ruff
# ruff.type = exec
# ruff.executable = %(here)s/.venv/bin/ruff
# ruff.options = --fix REVISION_SCRIPT_FILENAME

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = WARN
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
Loading
Loading