Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
413 changes: 240 additions & 173 deletions burr/tracking/server/run.py

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/concepts/tracking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,25 @@ This will print the URL to access the Burr UI web app.
from google.colab import output
output.serve_kernel_port_as_window(7241) # this will open a new window
output.serve_kernel_port_as_iframe(7241) # this will inline in an iframe

---------------------------------------------
Mount Burr UI inside an existing FastAPI app
---------------------------------------------

You can embed the Burr UI inside an existing FastAPI application using the
``mount_burr_ui`` helper.

Example:

.. code-block:: python

from fastapi import FastAPI
from burr.tracking.server.run import mount_burr_ui

app = FastAPI()

# Mount Burr UI under /burr
mount_burr_ui(app, path="/burr")

This allows you to run the Burr tracking UI alongside your own FastAPI
application in the same server process.
35 changes: 35 additions & 0 deletions examples/fastapi_mount_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import uvicorn
from fastapi import FastAPI

from burr.tracking.server.run import mount_burr_ui

app = FastAPI()

# Mount Burr UI under /burr
mount_burr_ui(app, path="/burr")


@app.get("/")
def root():
return {"message": "Main FastAPI app with Burr UI mounted at /burr"}


if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8003)
153 changes: 153 additions & 0 deletions telemetry/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion telemetry/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { DeepResearcherWithTelemetry } from './examples/DeepResearcher';
const App = () => {
return (
<QueryClientProvider client={new QueryClient()}>
<Router>
<Router basename={window.__BURR_BASE_PATH__ || ''}>
<AppContainer>
<Routes>
<Route path="/" element={<Navigate to="/projects" />} />
Expand Down
8 changes: 7 additions & 1 deletion telemetry/ui/src/api/core/OpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ export type OpenAPIConfig = {
ENCODE_PATH?: ((path: string) => string) | undefined;
};

// When the Burr UI is mounted as a sub-app (e.g. under /burr), the server
// injects window.__BURR_BASE_PATH__ so API calls are correctly prefixed.
const basePath = typeof window !== 'undefined'
? window.__BURR_BASE_PATH__ || ''
: '';

export const OpenAPI: OpenAPIConfig = {
BASE: '',
BASE: basePath,
VERSION: '0.1.0',
WITH_CREDENTIALS: false,
CREDENTIALS: 'include',
Expand Down
Loading
Loading