Skip to content

Commit 2030b95

Browse files
committed
Merge branch 'master' into mm-verify-deployments
2 parents bb003ca + b6cbcbc commit 2030b95

File tree

5 files changed

+73
-29
lines changed

5 files changed

+73
-29
lines changed

.github/workflows/snyk.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e '.[test]'
41+
pip install -r requirements.txt
4242
4343
- uses: snyk/actions/setup@master
4444

45-
- name: Run Snyk (setup.py)
46-
run: snyk monitor --file="setup.py" --package-manager=pip --project-name="setup.py" --org=${{ env.SNYK_ORG }}
47-
4845
- name: Run Snyk (requirements.txt)
4946
run: snyk monitor --file="requirements.txt" --package-manager=pip --project-name="requirements.txt" --org=${{ env.SNYK_ORG }}

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
67
## Unreleased
78

89
### Fixed
@@ -26,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2627
recognized filename patterns, the file patterns `app-*.py`, `app_*.py`, `*-app.py`,
2728
and `*_app.py` are now considered. However, if the directory contains more than
2829
one file matching these new patterns, you must provide rsconnect-python with an
29-
explicit `--entrypoint` argument.
30+
explicit `--entrypoint` argument.\
3031
- Added a new verbose logging level. Specifying `-v` on the command line uses this
3132
new level. Currently this will cause filenames to be logged as they are added to
3233
a bundle. To enable maximum verbosity (debug level), use `-vv`.
@@ -35,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3536
considered successful if there isn't a 5xx code returned (errors like
3637
400 Bad Request or 405 Method Not Allowed because not all apps support `GET /`).
3738
For cases where this is not desired, use the `--no-verify` flag on the command line.
39+
- Added the `deploy flask` command.
40+
- Added the `write-manifest flask` command.
3841

3942
### Changed
4043
- Removing experimental support for Conda. Connect does not support restoring Conda environments.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ rsconnect write-manifest notebook my-notebook.ipynb
270270
You can deploy a variety of APIs and applications using sub-commands of the
271271
`rsconnect deploy` command.
272272

273-
* `api`: WSGI-compliant APIs such as Flask and packages based on Flask
274-
* `fastapi`: ASGI-compliant APIs (FastAPI, Quart, Sanic, and Falcon)
273+
* `api`: WSGI-compliant APIs (e.g., `bottle`, `falcon`, `flask`, `flask-restx`, `flasgger`, `pycnic`).
274+
* `flask`: Flask APIs (_Note: `flask` is an alias of `api`._).
275+
* `fastapi`: ASGI-compliant APIs (e.g, `fastapi`, `quart`, `sanic`, `starlette`)
275276
* `dash`: Python Dash apps
276277
* `streamlit`: Streamlit apps
277278
* `bokeh`: Bokeh server apps

requirements.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file is just for Snyk scanning,
2+
# because it doesn't understand pyproject.toml
3+
# unless it uses Poetry.
4+
# https://github.com/snyk/snyk-python-plugin/issues/147
5+
6+
# build-system.requires
7+
setuptools>=61
8+
setuptools_scm[toml]>=3.4
9+
wheel
10+
11+
# project.dependencies
12+
six>=1.14.0
13+
click>=7.0.0
14+
pip>=10.0.0
15+
semver>=2.0.0,<3.0.0
16+
pyjwt>=2.4.0
17+
black==22.3.0
18+
19+
# project.optional-dependencies.test
20+
coverage
21+
flake8-pyproject
22+
flake8
23+
httpretty
24+
ipykernel
25+
mypy
26+
nbconvert
27+
pytest-cov
28+
pytest-mypy
29+
pytest
30+
setuptools_scm[toml]
31+
twine
32+
types-click
33+
types-Flask
34+
types-six

rsconnect/main.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import click
99
from os.path import abspath, dirname, exists, isdir, join
1010
from functools import wraps
11+
from typing import Optional
1112

1213
from rsconnect.certificates import read_certificate_file
1314

@@ -65,6 +66,7 @@
6566
from .log import logger, LogOutputFormat
6667
from .metadata import ServerStore, AppStore
6768
from .models import (
69+
AppMode,
6870
AppModes,
6971
BuildStatus,
7072
ContentGuidWithBundleParamType,
@@ -1274,18 +1276,22 @@ def deploy_html(
12741276
ce.verify_deployment()
12751277

12761278

1277-
def generate_deploy_python(app_mode, alias, min_version):
1279+
def generate_deploy_python(app_mode: AppMode, alias: str, min_version: str, desc: Optional[str] = None):
1280+
1281+
if desc is None:
1282+
desc = app_mode.desc()
1283+
12781284
# noinspection SpellCheckingInspection
12791285
@deploy.command(
12801286
name=alias,
12811287
short_help="Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io.".format(
1282-
desc=app_mode.desc(),
1288+
desc=desc,
12831289
version=min_version,
12841290
),
12851291
help=(
12861292
"Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). "
12871293
'The "directory" argument must refer to an existing directory that contains the application code.'
1288-
).format(desc=app_mode.desc()),
1294+
).format(desc=desc),
12891295
no_args_is_help=True,
12901296
)
12911297
@server_args
@@ -1297,7 +1303,7 @@ def generate_deploy_python(app_mode, alias, min_version):
12971303
"-e",
12981304
help=(
12991305
"The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1300-
).format(desc=app_mode.desc()),
1306+
).format(desc=desc),
13011307
)
13021308
@click.option(
13031309
"--exclude",
@@ -1395,14 +1401,13 @@ def deploy_app(
13951401
return deploy_app
13961402

13971403

1398-
deploy_api = generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="api", min_version="1.8.2")
1399-
# TODO: set fastapi min_version correctly
1400-
# deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0")
1401-
deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0")
1402-
deploy_dash_app = generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2")
1403-
deploy_streamlit_app = generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4")
1404-
deploy_bokeh_app = generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4")
1405-
deploy_shiny = generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0")
1404+
generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="api", min_version="1.8.2")
1405+
generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="flask", min_version="1.8.2", desc="Flask API")
1406+
generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0")
1407+
generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2")
1408+
generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4")
1409+
generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4")
1410+
generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0")
14061411

14071412

14081413
@deploy.command(
@@ -1734,24 +1739,27 @@ def write_manifest_quarto(
17341739
)
17351740

17361741

1737-
def generate_write_manifest_python(app_mode, alias):
1742+
def generate_write_manifest_python(app_mode, alias, desc: Optional[str] = None):
1743+
if desc is None:
1744+
desc = app_mode.desc()
1745+
17381746
# noinspection SpellCheckingInspection
17391747
@write_manifest.command(
17401748
name=alias,
1741-
short_help="Create a manifest.json file for a {desc}.".format(desc=app_mode.desc()),
1749+
short_help="Create a manifest.json file for a {desc}.".format(desc=desc),
17421750
help=(
17431751
"Create a manifest.json file for a {desc} for later deployment. This will create an "
17441752
'environment file ("requirements.txt") if one does not exist. All files '
17451753
"are created in the same directory as the API code."
1746-
).format(desc=app_mode.desc()),
1754+
).format(desc=desc),
17471755
)
17481756
@click.option("--overwrite", "-o", is_flag=True, help="Overwrite manifest.json, if it exists.")
17491757
@click.option(
17501758
"--entrypoint",
17511759
"-e",
17521760
help=(
17531761
"The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1754-
).format(desc=app_mode.desc()),
1762+
).format(desc=desc),
17551763
)
17561764
@click.option(
17571765
"--exclude",
@@ -1816,12 +1824,13 @@ def manifest_writer(
18161824
return manifest_writer
18171825

18181826

1819-
write_manifest_api = generate_write_manifest_python(AppModes.PYTHON_API, alias="api")
1820-
write_manifest_fastapi = generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="fastapi")
1821-
write_manifest_dash = generate_write_manifest_python(AppModes.DASH_APP, alias="dash")
1822-
write_manifest_streamlit = generate_write_manifest_python(AppModes.STREAMLIT_APP, alias="streamlit")
1823-
write_manifest_bokeh = generate_write_manifest_python(AppModes.BOKEH_APP, alias="bokeh")
1824-
write_manifest_shiny = generate_write_manifest_python(AppModes.PYTHON_SHINY, alias="shiny")
1827+
generate_write_manifest_python(AppModes.BOKEH_APP, alias="bokeh")
1828+
generate_write_manifest_python(AppModes.DASH_APP, alias="dash")
1829+
generate_write_manifest_python(AppModes.PYTHON_API, alias="api")
1830+
generate_write_manifest_python(AppModes.PYTHON_API, alias="flask", desc="Flask API")
1831+
generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="fastapi")
1832+
generate_write_manifest_python(AppModes.PYTHON_SHINY, alias="shiny")
1833+
generate_write_manifest_python(AppModes.STREAMLIT_APP, alias="streamlit")
18251834

18261835

18271836
# noinspection SpellCheckingInspection

0 commit comments

Comments
 (0)