Closed SamEdwardes closed 1 year ago
Ah, thank you for this! I do notice that your connect_server
argument is the url, not a Connect Server object (see https://rstudio.github.io/vetiver-python/stable/reference/vetiver.deploy_rsconnect.html#vetiver-deploy-rsconnect). That should solve your error for some versions.
I still think this is a good idea to pin the version due to the other errors you are hitting, but starting at rsconnect-python>=1.11
rather than 1.12.1.
Thank you for taking a look @isabelizimm.
I was putting the wrong value into the connect_server
argument. I found this example to be the most helpful: https://docs.posit.co/connect/user/vetiver/#example.
So I think I was incorrect to say that these versions do not work:
After fixing my code:
import os
import sys
import pins
import vetiver
from vetiver.data import mtcars
from sklearn.linear_model import LinearRegression
from rsconnect.api import RSConnectServer
# Fit a model ------------------------------------------------------------------
lm = LinearRegression().fit(mtcars, mtcars["mpg"])
model_name = "sam.edwardes/mtcars-linear-model3"
v = vetiver.VetiverModel(
lm,
model_name=model_name,
save_ptype=True,
ptype_data=mtcars
)
# Pin model --------------------------------------------------------------------
board = pins.board_rsconnect(
server_url=os.getenv("CONNECT_SERVER"),
api_key=os.getenv("CONNECT_API_KEY"),
allow_pickle_read=True
)
vetiver.vetiver_pin_write(board, v)
# Deploy model -----------------------------------------------------------------
connect_server = RSConnectServer(
url=os.getenv("CONNECT_SERVER"),
api_key=os.getenv("CONNECT_API_KEY")
)
vetiver.deploy_rsconnect(
connect_server=connect_server,
board=board,
pin_name=model_name,
python=sys.executable,
)
After making the code changes, I was able to deploy successfully using:
vetiver==0.1.8
rsconnect-python==1.8.0
So maybe vetiver should just be pinned to require rsconnect-python>=1.8.0
?
TL/DR
I think that vetiver needs to pin a requirement of
rsconnect-python >= 1.12.1
.Reprex rsconnect-python==1.7.1
requirements.txt
train_and_deploy_model.py
Execute the code:
Reprex rsconnect-python>=1.8.0 and rsconnect-python<=1.12.0
requirements.txt
I tested under the following scenarios, they all go the same error:
train_and_deploy_model.py
Execute the code: