Skip to content

Commit

Permalink
Adds dependency-tracking guards to server/CLI
Browse files Browse the repository at this point in the history
This makes it easier to install dependencies if they were missed.
  • Loading branch information
elijahbenizzy committed Feb 25, 2024
1 parent 3d0b041 commit 0c7e42b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
15 changes: 12 additions & 3 deletions burr/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@
import webbrowser
from contextlib import contextmanager

import click
import requests
from loguru import logger
from burr.integrations.base import require_plugin

try:
import click
import requests
from loguru import logger
except ImportError as e:
require_plugin(
e,
["click", "requests", "loguru"],
"start",
)


def _command(command: str, capture_output: bool) -> str:
Expand Down
2 changes: 1 addition & 1 deletion burr/tracking/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require_plugin(
e,
["pydantic"],
"tracking-client",
"tracking",
)


Expand Down
33 changes: 25 additions & 8 deletions burr/tracking/server/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,37 @@
from importlib.resources import files
from typing import Sequence

import uvicorn
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from starlette.templating import Jinja2Templates

from burr.tracking.server import backend, schema
from burr.tracking.server.schema import ApplicationLogs
from burr.integrations.base import require_plugin

try:
import uvicorn
from fastapi import FastAPI, Request
from fastapi.staticfiles import StaticFiles
from starlette.templating import Jinja2Templates

from burr.tracking.server import backend, schema
from burr.tracking.server.schema import ApplicationLogs
except ImportError as e:
require_plugin(
e,
[
"click",
"fastapi",
"uvicorn",
"pydantic",
"fastapi-pagination",
"aiofiles",
"requests",
"jinja2",
],
"tracking",
)

app = FastAPI()

backend = backend.LocalBackend()

SERVE_STATIC = os.getenv("BURR_SERVE_STATIC", "true").lower() == "true"
print(SERVE_STATIC)


@app.get("/api/v0/projects", response_model=Sequence[schema.Project])
Expand Down

0 comments on commit 0c7e42b

Please sign in to comment.