rstudio / vetiver-python

Version, share, deploy, and monitor models.
https://rstudio.github.io/vetiver-python/stable/
MIT License
59 stars 17 forks source link

name cannot be specified with server on RSConnect #110

Closed isabelizimm closed 1 year ago

isabelizimm commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Running demo from https://github.com/sol-eng/bike_predict_python/tree/main/model/01-train-and-deploy-model

Expected behavior Deploy to RSConnect

Traceback

---------------------------------------------------------------------------
RSConnectException                        Traceback (most recent call last)
/usr/home/katie.masiello/bike_predict_python/model/01-train-and-deploy-model/model_training_deployment.ipynb Cell 18' in <cell line: 3>()
      1 # use Vetiver provided RStudio Connect deployment function 
      2 # to deploy the model as a FASTApi
----> 3 deploy_rsconnect(
      4     connect_server=connect_server,
      5     board=board,
      6     pin_name="katie.masiello/bikeshare-rf-python",
      7     python="../../venv/bin/python",
      8     title = "Random Forest model for Bikeshare Python")

File ~/bike_predict_python/venv/lib/python3.10/site-packages/vetiver/rsconnect.py:81, in deploy_rsconnect(connect_server, board, pin_name, version, extra_files, new, app_id, title, python, conda_mode, force_generate, log_callback, image)
     71 tmp_app = temp + "/app.py"
     73 write_app(
     74     board=board,
     75     pin_name=pin_name,
   (...)
     78     overwrite=False,
     79 )
---> 81 deploy_python_fastapi(
     82     connect_server=connect_server,
     83     directory=temp,
     84     extra_files=extra_files,
     85     excludes=None,
     86     entry_point="app:api",
     87     new=new,
     88     app_id=app_id,
     89     title=title,
     90     python=python,
     91     conda_mode=conda_mode,
     92     force_generate=force_generate,
     93     log_callback=log_callback,
     94     image=image,
     95 )

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/actions.py:897, in deploy_python_fastapi(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback, image)
    856 def deploy_python_fastapi(
    857     connect_server: api.RSConnectServer,
    858     directory: str,
   (...)
    869     image: str = None,
    870 ) -> typing.Tuple[str, typing.Union[list, None]]:
    871     """
    872     A function to deploy a Python ASGI API module to RStudio Connect.  Depending on the files involved
    873         and network latency, this may take a bit of time.
   (...)
    895         of log lines.  The log lines value will be None if a log callback was provided.
    896     """
--> 897     return _deploy_by_python_framework(
    898         connect_server,
    899         directory,
    900         extra_files,
    901         excludes,
    902         entry_point,
    903         gather_basic_deployment_info_for_fastapi,
    904         image,
    905         new,
    906         app_id,
    907         title,
    908         python,
    909         conda_mode,
    910         force_generate,
    911         log_callback,
    912     )

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/actions.py:1210, in _deploy_by_python_framework(connect_server, directory, extra_files, excludes, entry_point, gatherer, image, new, app_id, title, python, conda_mode, force_generate, log_callback)
   1201 _, environment = get_python_env_info(
   1202     directory,
   1203     python,
   1204     conda_mode=conda_mode,
   1205     force_generate=force_generate,
   1206 )
   1207 bundle = create_api_deployment_bundle(
   1208     directory, extra_files, excludes, entry_point, app_mode, environment, True, image
   1209 )
-> 1210 return _finalize_deploy(
   1211     connect_server,
   1212     app_store,
   1213     directory,
   1214     app_id,
   1215     app_mode,
   1216     deployment_name,
   1217     deployment_title,
   1218     default_title,
   1219     bundle,
   1220     log_callback,
   1221 )

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/actions.py:769, in _finalize_deploy(connect_server, app_store, file_name, app_id, app_mode, name, title, title_is_default, bundle, log_callback)
    737 def _finalize_deploy(
    738     connect_server: api.RSConnectServer,
    739     app_store: AppStore,
   (...)
    747     log_callback: typing.Callable,
    748 ) -> typing.Tuple[str, typing.Union[list, None]]:
    749     """
    750     A common function to finish up the deploy process once all the data (bundle
    751     included) has been resolved.
   (...)
    767     of log lines.  The log lines value will be None if a log callback was provided.
    768     """
--> 769     app = deploy_bundle(connect_server, app_id, name, title, title_is_default, bundle, None)
    770     app_url, log_lines, _ = spool_deployment_log(connect_server, app, log_callback)
    771     app_store.set(
    772         connect_server.url,
    773         abspath(file_name),
   (...)
    778         app_mode,
    779     )

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/actions.py:1793, in deploy_bundle(remote_server, app_id, name, title, title_is_default, bundle, env_vars)
   1771 def deploy_bundle(
   1772     remote_server: api.TargetableServer,
   1773     app_id: int,
   (...)
   1778     env_vars: typing.List[typing.Tuple[str, str]],
   1779 ) -> typing.Dict[str, typing.Any]:
   1780     """
   1781     Deploys the specified bundle.
   1782 
   (...)
   1791     task that may be queried for deployment progress.
   1792     """
-> 1793     ce = RSConnectExecutor(
   1794         server=remote_server,
   1795         app_id=app_id,
   1796         name=name,
   1797         title=title,
   1798         title_is_default=title_is_default,
   1799         bundle=bundle,
   1800         env_vars=env_vars,
   1801     )
   1802     ce.deploy_bundle()
   1803     return ce.state["deployed_info"]

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/api.py:341, in RSConnectExecutor.__init__(self, name, url, api_key, insecure, cacert, ca_data, cookies, account, token, secret, timeout, logger, **kwargs)
    339 self.reset()
    340 self._d = kwargs
--> 341 self.setup_remote_server(
    342     name=name,
    343     url=url or kwargs.get("server"),
    344     api_key=api_key,
    345     insecure=insecure,
    346     cacert=cacert,
    347     ca_data=ca_data,
    348     account_name=account,
    349     token=token,
    350     secret=secret,
    351 )
    352 self.setup_client(cookies, timeout)
    353 self.logger = logger

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/api.py:390, in RSConnectExecutor.setup_remote_server(self, name, url, api_key, insecure, cacert, ca_data, account_name, token, secret)
    378 def setup_remote_server(
    379     self,
    380     name: str = None,
   (...)
    388     secret: str = None,
    389 ):
--> 390     validation.validate_connection_options(
    391         url=url,
    392         api_key=api_key,
    393         insecure=insecure,
    394         cacert=cacert,
    395         account_name=account_name,
    396         token=token,
    397         secret=secret,
    398         name=name,
    399     )
    401     if cacert and not ca_data:
    402         ca_data = text_type(cacert.read())

File ~/bike_predict_python/venv/lib/python3.10/site-packages/rsconnect/validation.py:21, in validate_connection_options(url, api_key, insecure, cacert, account_name, token, secret, name)
     18 present_options_mutually_exclusive_with_name = _get_present_options(options_mutually_exclusive_with_name)
     20 if name and present_options_mutually_exclusive_with_name:
---> 21     raise RSConnectException(
     22         "-n/--name cannot be specified in conjunction with options {}".format(
     23             ", ".join(present_options_mutually_exclusive_with_name)
     24         )
     25     )
     26 if not name and not url and not shinyapps_options:
     27     raise RSConnectException(
     28         "You must specify one of -n/--name OR -s/--server OR -A/--account, -T/--token, -S/--secret."
     29     )

RSConnectException: -n/--name cannot be specified in conjunction with options -s/--server
isabelizimm commented 1 year ago

Tracking this from upstream package RSConnect here as it crops up when deploying with vetiver when rsconnect-python==1.10

isabelizimm commented 1 year ago

vetiver.deploy_rsconnect() works with rsconnect-python>1.10 🎉