Skip to content

Commit

Permalink
maint: move from deploy_rsconnect to deploy_connect (#226)
Browse files Browse the repository at this point in the history
* add deploy_connect

* use deploy_connect in tests
  • Loading branch information
isabelizimm authored Dec 10, 2024
1 parent a466e36 commit fed271a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
3 changes: 2 additions & 1 deletion vetiver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""vetiver - Python parallel to R vetiver package"""

# Change to import.metadata when minimum python>=3.8
from importlib_metadata import version as _version

Expand All @@ -22,7 +23,7 @@
from .handlers.xgboost import XGBoostHandler # noqa
from .handlers.spacy import SpacyHandler # noqa
from .helpers import api_data_to_frame # noqa
from .rsconnect import deploy_rsconnect # noqa
from .rsconnect import deploy_connect, deploy_rsconnect # noqa
from .monitor import compute_metrics, pin_metrics, plot_metrics, _rolling_df # noqa
from .templates import model_card, monitoring_dashboard # noqa
from .types import create_prototype, Prototype # noqa
Expand Down
42 changes: 40 additions & 2 deletions vetiver/rsconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import shutil
import tempfile
import typing
import warnings

from rsconnect.actions import deploy_python_fastapi
from rsconnect.api import RSConnectServer as ConnectServer

from .write_fastapi import write_app


def deploy_rsconnect(
def deploy_connect(
connect_server: ConnectServer,
board,
pin_name: str,
Expand Down Expand Up @@ -68,7 +69,7 @@ def deploy_rsconnect(
)
# Deploy model, which should already be pinned on Posit Connect
vetiver.deploy_rsconnect(
vetiver.deploy_connect(
connect_server = connect_server,
board = board,
pin_name = "my_model"
Expand Down Expand Up @@ -116,3 +117,40 @@ def deploy_rsconnect(
log_callback=log_callback,
image=image,
)


def deploy_rsconnect(
connect_server: ConnectServer,
board,
pin_name: str,
version: str = None,
extra_files: typing.List[str] = None,
new: bool = False,
app_id: int = None,
title: str = None,
python: str = None,
force_generate: bool = False,
log_callback: typing.Callable = None,
image: str = None,
):
"""Deprecated. Use `deploy_connect` instead."""

warnings.warn(
"deploy_rsconnect is deprecated and will be removed in a future version. "
"Use deploy_connect instead."
)

deploy_connect(
connect_server=connect_server,
board=board,
pin_name=pin_name,
version=version,
extra_files=extra_files,
new=new,
app_id=app_id,
title=title,
python=python,
force_generate=force_generate,
log_callback=log_callback,
image=image,
)
4 changes: 2 additions & 2 deletions vetiver/tests/test_rsconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def test_deploy(rsc_short):

v = vetiver.VetiverModel(model=model, prototype_data=X_df, model_name="susan/model")

board = pins.board_rsconnect(
board = pins.board_connect(
server_url=RSC_SERVER_URL, api_key=get_key("susan"), allow_pickle_read=True
)

vetiver.vetiver_pin_write(board=board, model=v)
connect_server = RSConnectServer(url=RSC_SERVER_URL, api_key=get_key("susan"))
assert isinstance(board.pin_read("susan/model"), sklearn.dummy.DummyRegressor)

vetiver.deploy_rsconnect(
vetiver.deploy_connect(
connect_server=connect_server,
board=board,
pin_name="susan/model",
Expand Down

0 comments on commit fed271a

Please sign in to comment.