Skip to content

Commit

Permalink
add some quality of life changes
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelizimm committed Apr 18, 2024
1 parent 3f13ed5 commit e9eb10d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,24 @@ jobs:
- name: Run Tests
shell: bash
run: make typecheck

release-pypi:
name: "Release to pypi"
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [test-no-extras, tests, test-rsconnect]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: "Build Package"
run: |
python -m pip install build wheel
python -m build --sdist --wheel
- name: "Deploy to Test PyPI"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
30 changes: 19 additions & 11 deletions vetiver/server.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import json
import logging
import re
import webbrowser
from textwrap import dedent
from typing import Callable, List, Union
from urllib.parse import urljoin
from warnings import warn

import httpx
import json
import pandas as pd
import requests
import uvicorn
import logging
import pandas as pd
from fastapi import FastAPI, Request
from fastapi.exceptions import RequestValidationError
from fastapi.openapi.utils import get_openapi
from fastapi.responses import HTMLResponse, RedirectResponse, PlainTextResponse
from textwrap import dedent
from warnings import warn
from urllib.parse import urljoin
from typing import Callable, List, Union
from fastapi.responses import HTMLResponse, PlainTextResponse, RedirectResponse

from .helpers import api_data_to_frame, response_to_frame
from .meta import VetiverMeta
from .utils import _jupyter_nb, get_workbench_path
from .vetiver_model import VetiverModel
from .meta import VetiverMeta
from .helpers import api_data_to_frame, response_to_frame


class VetiverAPI:
Expand Down Expand Up @@ -273,7 +275,13 @@ def run(self, port: int = 8000, host: str = "127.0.0.1", **kw):
"""
_jupyter_nb()
self.workbench_path = get_workbench_path(port)

if port and host:
try:
if host == "127.0.0.1":
# quality of life for developing APIs locally
webbrowser.open(f"http://{host}:{port}")
except Exception:
pass
if self.workbench_path:
uvicorn.run(
self.app, port=port, host=host, root_path=self.workbench_path, **kw
Expand Down

0 comments on commit e9eb10d

Please sign in to comment.