diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f0bea62..7cb8876 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 }} diff --git a/docs/changelog.md b/docs/changelog.md index cfdeac9..b9f1b3b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,15 @@ For full details, view the [commit logs](https://github.com/rstudio/vetiver-python/commits/). +## v0.2.5 +## What's Changed + +[**Full Changelog**](https://github.com/rstudio/vetiver-python/compare/v0.2.4...v0.2.5) + +* MAINT: refactor tests in [GH209](https://github.com/rstudio/vetiver-python/pull/209) +* DOCS: Update link to custom handlers documentation in [GH208](https://github.com/rstudio/vetiver-python/pull/208) +* ENH: add `Field` examples to model prototypes in [GH210](https://github.com/rstudio/vetiver-python/pull/210) + ## v0.2.4 ## What's Changed diff --git a/pyproject.toml b/pyproject.toml index 5d88170..97ecad2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ include = [ # single character). ignore = [ #"vetiver/__init__.py", - #"vetiver/attach_pkgs.py", + "vetiver/attach_pkgs.py", "vetiver/helpers.py", "vetiver/meta.py", "vetiver/mock.py", diff --git a/vetiver/server.py b/vetiver/server.py index 950d367..de71e4b 100644 --- a/vetiver/server.py +++ b/vetiver/server.py @@ -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: @@ -251,7 +253,7 @@ async def custom_endpoint(input_data: Request): else: return predictions - def run(self, port: int = 8000, host: str = "127.0.0.1", **kw): + def run(self, port: int = 8000, host: str = "127.0.0.1", quiet_open=False, **kw): """ Start API @@ -261,6 +263,8 @@ def run(self, port: int = 8000, host: str = "127.0.0.1", **kw): An integer that indicates the server port that should be listened on. host : str A valid IPv4 or IPv6 address, which the application will listen on. + quiet_open : bool + If host is a localhost address, try to automatically open API in browser Examples ------- @@ -273,7 +277,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" and not quiet_open: + # 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