rsconnect-python
rsconnect-python copied to clipboard
Add support for git deployments
This PR adds support for deploying a new git-backed content item using rsconnect-python.
Intent
This is based on @colearendt 's PR. I moved it to a local branch (for CI), updated it to work the the executor, added title/env var support, and added documentation.
Type of Change
- [ ] Bug Fix
- [x] New Feature
- [ ] Breaking Change
Automated Tests
Needs tests.
Directions for Reviewers
Run something like
rsconnect deploy git -r https://github.com/rstudio/rsc-hello-world-content -d square-plot
See a new git-backed content item in Connect. You can also use --title, and -E to specify environment variables as for other content types.
Checklist
- [x] I have updated CHANGELOG.md to cover notable changes.
- [ ] I have updated all related GitHub issues to reflect their current state.
☂️ Python Coverage
current status: ✅
Overall Coverage
| Lines | Covered | Coverage | Threshold | Status |
|---|---|---|---|---|
| 4273 | 2788 | 65% | 0% | 🟢 |
New Files
No new covered files...
Modified Files
| File | Coverage | Status |
|---|---|---|
| rsconnect/api.py | 67% | 🟢 |
| rsconnect/main.py | 56% | 🟢 |
| TOTAL | 61% | 🟢 |
updated for commit:
85d17b4by action🐍
Looks like the formatting is off? Is this perhaps the same thing as we saw with the
condaremoval PR?
It seems better now that your PR has merged.
rsconnect deploy git --help:
Can we get some more context around these new flags:
-r, --repository TEXT [required]
-b, --branch TEXT
-d, --subdirectory TEXT
Something like...:
-r, --repository TEXT [required] URL to the root of the repository being deployed
-b, --branch TEXT name of the branch being deployed
-d, --subdirectory TEXT subdirectory of the content being deployed
If a -t isn't included, is there a way we can imply the title based on the directory?
In Connect the title is just Unknown. It's doubly bad because the metrics page then just has a blank title for the app:
I beleive the Metrics page uses the name field from the API but most (all?) other deploy methods copy the title into the name field so it's never null.
If you try to rsconnect deploy git to shinyapps.io you get an internal error:
-> rsconnect deploy git -r https://github.com/rstudio/rsc-hello-world-content -d python3/python-shiny -b master -n pxb42b-kevin-gartland
Validating server... [OK]
Deploying git repository ... [ERROR]: 'PositClient' object has no attribute 'deploy_git'
Traceback (most recent call last):
File "/Users/kgartland/.pyenv/versions/3.11.6/envs/fastapi/lib/python3.11/site-packages/rsconnect/main.py", line 94, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/kgartland/.pyenv/versions/3.11.6/envs/fastapi/lib/python3.11/site-packages/rsconnect/main.py", line 1444, in deploy_git
ce.validate_server().deploy_git().emit_task_log()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kgartland/.pyenv/versions/3.11.6/envs/fastapi/lib/python3.11/site-packages/rsconnect/log.py", line 189, in wrapper
result = method(self, *args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kgartland/.pyenv/versions/3.11.6/envs/fastapi/lib/python3.11/site-packages/rsconnect/api.py", line 790, in deploy_git
result = self.client.deploy_git(app_name, repository, branch, subdirectory, title, env_vars)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PositClient' object has no attribute 'deploy_git'
Internal error: 'PositClient' object has no attribute 'deploy_git'
Should we add support for shinyapps.io here, or just catch the error and display a helpful message?
If you try to deploy to Connect where Git is disabled, this error is thrown:
(fastapi) [03:13:39 kgartland ~/work/rsconnect-python] (add-git)-> rsconnect deploy git -r https://github.com/rstudio/rsc-hello-world-content -d python3/python-bokeh -b kg-force-updates -n ldap
Validating server... [OK]
Deploying git repository ... [ERROR]: Received an unexpected response from Posit Connect (calling /rsc/dev-ldap/__api__/applications/b4c58613-e221-471d-ba3d-ffd4cb443262/repo): 404 Not Found
Error: Received an unexpected response from Posit Connect (calling /rsc/dev-ldap/__api__/applications/b4c58613-e221-471d-ba3d-ffd4cb443262/repo): 404 Not Found
Can we we detect if Git is enabled/installed on Connect and throw a friendly error here?