Skip to content

Commit 0ba1703

Browse files
authored
[maint] auto opening urls, PyPI CI (#211)
* add some quality of life changes * update pyright * allow quiet opening * update docs for 0.2.5 release
1 parent 3f13ed5 commit 0ba1703

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,24 @@ jobs:
152152
- name: Run Tests
153153
shell: bash
154154
run: make typecheck
155+
156+
release-pypi:
157+
name: "Release to pypi"
158+
runs-on: ubuntu-latest
159+
if: github.event_name == 'release'
160+
needs: [test-no-extras, tests, test-rsconnect]
161+
steps:
162+
- uses: actions/checkout@v4
163+
- uses: actions/setup-python@v4
164+
with:
165+
python-version: "3.10"
166+
- name: "Build Package"
167+
run: |
168+
python -m pip install build wheel
169+
python -m build --sdist --wheel
170+
171+
- name: "Deploy to Test PyPI"
172+
uses: pypa/gh-action-pypi-publish@release/v1
173+
with:
174+
user: __token__
175+
password: ${{ secrets.PYPI_API_TOKEN }}

docs/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
For full details, view the [commit logs](https://github.com/rstudio/vetiver-python/commits/).
55

6+
## v0.2.5
7+
## What's Changed
8+
9+
[**Full Changelog**](https://github.com/rstudio/vetiver-python/compare/v0.2.4...v0.2.5)
10+
11+
* MAINT: refactor tests in [GH209](https://github.com/rstudio/vetiver-python/pull/209)
12+
* DOCS: Update link to custom handlers documentation in [GH208](https://github.com/rstudio/vetiver-python/pull/208)
13+
* ENH: add `Field` examples to model prototypes in [GH210](https://github.com/rstudio/vetiver-python/pull/210)
14+
615

716
## v0.2.4
817
## What's Changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include = [
3939
# single character).
4040
ignore = [
4141
#"vetiver/__init__.py",
42-
#"vetiver/attach_pkgs.py",
42+
"vetiver/attach_pkgs.py",
4343
"vetiver/helpers.py",
4444
"vetiver/meta.py",
4545
"vetiver/mock.py",

vetiver/server.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
import json
2+
import logging
13
import re
4+
import webbrowser
5+
from textwrap import dedent
6+
from typing import Callable, List, Union
7+
from urllib.parse import urljoin
8+
from warnings import warn
9+
210
import httpx
3-
import json
11+
import pandas as pd
412
import requests
513
import uvicorn
6-
import logging
7-
import pandas as pd
814
from fastapi import FastAPI, Request
915
from fastapi.exceptions import RequestValidationError
1016
from fastapi.openapi.utils import get_openapi
11-
from fastapi.responses import HTMLResponse, RedirectResponse, PlainTextResponse
12-
from textwrap import dedent
13-
from warnings import warn
14-
from urllib.parse import urljoin
15-
from typing import Callable, List, Union
17+
from fastapi.responses import HTMLResponse, PlainTextResponse, RedirectResponse
1618

19+
from .helpers import api_data_to_frame, response_to_frame
20+
from .meta import VetiverMeta
1721
from .utils import _jupyter_nb, get_workbench_path
1822
from .vetiver_model import VetiverModel
19-
from .meta import VetiverMeta
20-
from .helpers import api_data_to_frame, response_to_frame
2123

2224

2325
class VetiverAPI:
@@ -251,7 +253,7 @@ async def custom_endpoint(input_data: Request):
251253
else:
252254
return predictions
253255

254-
def run(self, port: int = 8000, host: str = "127.0.0.1", **kw):
256+
def run(self, port: int = 8000, host: str = "127.0.0.1", quiet_open=False, **kw):
255257
"""
256258
Start API
257259
@@ -261,6 +263,8 @@ def run(self, port: int = 8000, host: str = "127.0.0.1", **kw):
261263
An integer that indicates the server port that should be listened on.
262264
host : str
263265
A valid IPv4 or IPv6 address, which the application will listen on.
266+
quiet_open : bool
267+
If host is a localhost address, try to automatically open API in browser
264268
265269
Examples
266270
-------
@@ -273,7 +277,13 @@ def run(self, port: int = 8000, host: str = "127.0.0.1", **kw):
273277
"""
274278
_jupyter_nb()
275279
self.workbench_path = get_workbench_path(port)
276-
280+
if port and host:
281+
try:
282+
if host == "127.0.0.1" and not quiet_open:
283+
# quality of life for developing APIs locally
284+
webbrowser.open(f"http://{host}:{port}")
285+
except Exception:
286+
pass
277287
if self.workbench_path:
278288
uvicorn.run(
279289
self.app, port=port, host=host, root_path=self.workbench_path, **kw

0 commit comments

Comments
 (0)