|
8 | 8 | import click |
9 | 9 | from os.path import abspath, dirname, exists, isdir, join |
10 | 10 | from functools import wraps |
| 11 | +from typing import Optional |
11 | 12 |
|
12 | 13 | from rsconnect.certificates import read_certificate_file |
13 | 14 |
|
|
65 | 66 | from .log import logger, LogOutputFormat |
66 | 67 | from .metadata import ServerStore, AppStore |
67 | 68 | from .models import ( |
| 69 | + AppMode, |
68 | 70 | AppModes, |
69 | 71 | BuildStatus, |
70 | 72 | ContentGuidWithBundleParamType, |
@@ -1281,18 +1283,22 @@ def deploy_html( |
1281 | 1283 | ) |
1282 | 1284 |
|
1283 | 1285 |
|
1284 | | -def generate_deploy_python(app_mode, alias, min_version): |
| 1286 | +def generate_deploy_python(app_mode: AppMode, alias: str, min_version: str, desc: Optional[str] = None): |
| 1287 | + |
| 1288 | + if desc is None: |
| 1289 | + desc = app_mode.desc() |
| 1290 | + |
1285 | 1291 | # noinspection SpellCheckingInspection |
1286 | 1292 | @deploy.command( |
1287 | 1293 | name=alias, |
1288 | 1294 | short_help="Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io.".format( |
1289 | | - desc=app_mode.desc(), |
| 1295 | + desc=desc, |
1290 | 1296 | version=min_version, |
1291 | 1297 | ), |
1292 | 1298 | help=( |
1293 | 1299 | "Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). " |
1294 | 1300 | 'The "directory" argument must refer to an existing directory that contains the application code.' |
1295 | | - ).format(desc=app_mode.desc()), |
| 1301 | + ).format(desc=desc), |
1296 | 1302 | no_args_is_help=True, |
1297 | 1303 | ) |
1298 | 1304 | @server_args |
@@ -1407,14 +1413,13 @@ def deploy_app( |
1407 | 1413 | return deploy_app |
1408 | 1414 |
|
1409 | 1415 |
|
1410 | | -deploy_api = generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="api", min_version="1.8.2") |
1411 | | -# TODO: set fastapi min_version correctly |
1412 | | -# deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0") |
1413 | | -deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0") |
1414 | | -deploy_dash_app = generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2") |
1415 | | -deploy_streamlit_app = generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4") |
1416 | | -deploy_bokeh_app = generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4") |
1417 | | -deploy_shiny = generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0") |
| 1416 | +generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="api", min_version="1.8.2") |
| 1417 | +generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="flask", min_version="1.8.2", desc="Flask API") |
| 1418 | +generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0") |
| 1419 | +generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2") |
| 1420 | +generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4") |
| 1421 | +generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4") |
| 1422 | +generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0") |
1418 | 1423 |
|
1419 | 1424 |
|
1420 | 1425 | @deploy.command( |
@@ -1759,24 +1764,27 @@ def write_manifest_quarto( |
1759 | 1764 | ) |
1760 | 1765 |
|
1761 | 1766 |
|
1762 | | -def generate_write_manifest_python(app_mode, alias): |
| 1767 | +def generate_write_manifest_python(app_mode, alias, desc: Optional[str] = None): |
| 1768 | + if desc is None: |
| 1769 | + desc = app_mode.desc() |
| 1770 | + |
1763 | 1771 | # noinspection SpellCheckingInspection |
1764 | 1772 | @write_manifest.command( |
1765 | 1773 | name=alias, |
1766 | | - short_help="Create a manifest.json file for a {desc}.".format(desc=app_mode.desc()), |
| 1774 | + short_help="Create a manifest.json file for a {desc}.".format(desc=desc), |
1767 | 1775 | help=( |
1768 | 1776 | "Create a manifest.json file for a {desc} for later deployment. This will create an " |
1769 | 1777 | 'environment file ("requirements.txt") if one does not exist. All files ' |
1770 | 1778 | "are created in the same directory as the API code." |
1771 | | - ).format(desc=app_mode.desc()), |
| 1779 | + ).format(desc=desc), |
1772 | 1780 | ) |
1773 | 1781 | @click.option("--overwrite", "-o", is_flag=True, help="Overwrite manifest.json, if it exists.") |
1774 | 1782 | @click.option( |
1775 | 1783 | "--entrypoint", |
1776 | 1784 | "-e", |
1777 | 1785 | help=( |
1778 | 1786 | "The module and executable object which serves as the entry point for the {desc} (defaults to app)" |
1779 | | - ).format(desc=app_mode.desc()), |
| 1787 | + ).format(desc=desc), |
1780 | 1788 | ) |
1781 | 1789 | @click.option( |
1782 | 1790 | "--exclude", |
@@ -1850,12 +1858,13 @@ def manifest_writer( |
1850 | 1858 | return manifest_writer |
1851 | 1859 |
|
1852 | 1860 |
|
1853 | | -write_manifest_api = generate_write_manifest_python(AppModes.PYTHON_API, alias="api") |
1854 | | -write_manifest_fastapi = generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="fastapi") |
1855 | | -write_manifest_dash = generate_write_manifest_python(AppModes.DASH_APP, alias="dash") |
1856 | | -write_manifest_streamlit = generate_write_manifest_python(AppModes.STREAMLIT_APP, alias="streamlit") |
1857 | | -write_manifest_bokeh = generate_write_manifest_python(AppModes.BOKEH_APP, alias="bokeh") |
1858 | | -write_manifest_shiny = generate_write_manifest_python(AppModes.PYTHON_SHINY, alias="shiny") |
| 1861 | +generate_write_manifest_python(AppModes.BOKEH_APP, alias="bokeh") |
| 1862 | +generate_write_manifest_python(AppModes.DASH_APP, alias="dash") |
| 1863 | +generate_write_manifest_python(AppModes.PYTHON_API, alias="api") |
| 1864 | +generate_write_manifest_python(AppModes.PYTHON_API, alias="flask", desc="Flask API") |
| 1865 | +generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="fastapi") |
| 1866 | +generate_write_manifest_python(AppModes.PYTHON_SHINY, alias="shiny") |
| 1867 | +generate_write_manifest_python(AppModes.STREAMLIT_APP, alias="streamlit") |
1859 | 1868 |
|
1860 | 1869 |
|
1861 | 1870 | # noinspection SpellCheckingInspection |
|
0 commit comments