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

Install target + dependencies fixes #32

Merged
merged 3 commits into from
Feb 25, 2024
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
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,24 @@ but realized that it has a wide array of applications and decided to release it.

To get started, install from `pypi`, using your favorite package manager:

```
pip install burr
```bash
pip install "burr[start]"
```

This includes the dependencies for the tracking server (see next step) -- alternatively if you want the core library only then just run `pip install burr`.
Then, run the server and check out the demo projects:

```
burr
```bash
$ burr

2024-02-23 11:43:21.249 | INFO | burr.cli.__main__:run_server:88 - Starting server on port 7241
```

This will open up a browser window with a few demo projects preloaded for you to play with.
This will start a server and open up a browser window with a few demo projects preloaded for you to play with.

Next, see the documentation for [getting started](https://studious-spork-n8kznlw.pages.github.io/getting_started/simple-example.html), and follow the example.
Then read through some of the concepts and write your own application!

# Contributing

We welcome contributors! To get started on developing, see the [developer-facing docs]([documentation](https://studious-spork-n8kznlw.pages.github.io/contributing))_
We welcome contributors! To get started on developing, see the [developer-facing docs](https://studious-spork-n8kznlw.pages.github.io/contributing).
50 changes: 32 additions & 18 deletions burr/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,41 @@
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) -> str:

def _command(command: str, capture_output: bool) -> str:
"""Runs a simple command"""
logger.info(f"Running command: {command}")
if isinstance(command, str):
command = command.split(" ")
try:
output = subprocess.check_output(command, stderr=subprocess.PIPE, shell=False)
return output.decode().strip() # If command is successful, print the output.
except subprocess.CalledProcessError as e:
print(e.stdout.decode())
print(e.stderr.decode())
raise e
if capture_output:
try:
return (
subprocess.check_output(command, stderr=subprocess.PIPE, shell=False)
.decode()
.strip()
)
except subprocess.CalledProcessError as e:
print(e.stdout.decode())
print(e.stderr.decode())
raise e
subprocess.run(command, shell=False, check=True)


def _get_git_root() -> str:
return _command("git rev-parse --show-toplevel")
return _command("git rev-parse --show-toplevel", capture_output=True)


def open_when_ready(check_url: str, open_url: str):
Expand Down Expand Up @@ -60,10 +74,10 @@ def cli():

def _build_ui():
cmd = "npm run build --prefix telemetry/ui"
_command(cmd)
_command(cmd, capture_output=False)
# create a symlink so we can get packages inside it...
cmd = "ln -s telemetry/ui/build burr/tracking/server/build"
_command(cmd)
_command(cmd, capture_output=False)


@cli.command()
Expand Down Expand Up @@ -94,7 +108,7 @@ def run_server(port: int, dev_mode: bool, no_open: bool):
daemon=True,
)
thread.start()
_command(cmd)
_command(cmd, capture_output=False)


@cli.command(help="Publishes the package to a repository")
Expand All @@ -104,14 +118,14 @@ def build_and_publish(prod: bool, no_wipe_dist: bool):
git_root = _get_git_root()
with cd(git_root):
logger.info("Building UI -- this may take a bit...")
# _build_ui()
_build_ui()
logger.info("Built UI!")
if not no_wipe_dist:
logger.info("Wiping dist/ directory for a clean publish.")
shutil.rmtree("dist", ignore_errors=True)
_command("python3 -m build")
_command("python3 -m build", capture_output=False)
repository = "pypi" if prod else "testpypi"
_command(f"python3 -m twine upload --repository {repository} dist/*")
_command(f"python3 -m twine upload --repository {repository} dist/*", capture_output=False)
logger.info(f"Published to {repository}! 🎉")


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
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ tracking = [
"loguru",
]

start = [
"burr[tracking]"
]

# just install everything for developers
developer = [
"burr[streamlit]",
"burr[graphviz]",
"burr[tracking]",
"burr[tests]",
"burr[documentation]",
"loguru", # I love loguru TBH, but not for any prod stuff
"build",
"twine",
"pre-commit",
Expand Down
Loading