|
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,19 +1283,28 @@ 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, deprecated: bool = False, desc: Optional[str] = None): |
| 1287 | + |
| 1288 | + if desc is None: |
| 1289 | + desc = app_mode.desc() |
| 1290 | + |
| 1291 | + help=( |
| 1292 | + "Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). " |
| 1293 | + 'The "directory" argument must refer to an existing directory that contains the application code.' |
| 1294 | + ).format(desc=desc) |
| 1295 | + |
| 1296 | + short_help="Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io.".format( |
| 1297 | + desc=desc, |
| 1298 | + version=min_version, |
| 1299 | + ) |
| 1300 | + |
1285 | 1301 | # noinspection SpellCheckingInspection |
1286 | 1302 | @deploy.command( |
1287 | 1303 | name=alias, |
1288 | | - short_help="Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io.".format( |
1289 | | - desc=app_mode.desc(), |
1290 | | - version=min_version, |
1291 | | - ), |
1292 | | - help=( |
1293 | | - "Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). " |
1294 | | - 'The "directory" argument must refer to an existing directory that contains the application code.' |
1295 | | - ).format(desc=app_mode.desc()), |
| 1304 | + short_help=short_help, |
| 1305 | + help=help, |
1296 | 1306 | no_args_is_help=True, |
| 1307 | + deprecated=deprecated, |
1297 | 1308 | ) |
1298 | 1309 | @server_args |
1299 | 1310 | @content_args |
@@ -1407,14 +1418,15 @@ def deploy_app( |
1407 | 1418 | return deploy_app |
1408 | 1419 |
|
1409 | 1420 |
|
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") |
| 1421 | +generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="api", min_version="1.8.2", desc="API Application", deprecated=True) |
| 1422 | +generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="wsgi", min_version="1.8.2", desc="WSGI Application") |
| 1423 | +generate_deploy_python(app_mode=AppModes.PYTHON_API, alias="flask", min_version="1.8.2", desc="Flask Application") |
| 1424 | +generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="asgi", min_version="2021.08.0", desc="ASGI Application") |
| 1425 | +generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0", desc="FastAPI Application") |
| 1426 | +generate_deploy_python(app_mode=AppModes.DASH_APP, alias="dash", min_version="1.8.2") |
| 1427 | +generate_deploy_python(app_mode=AppModes.STREAMLIT_APP, alias="streamlit", min_version="1.8.4") |
| 1428 | +generate_deploy_python(app_mode=AppModes.BOKEH_APP, alias="bokeh", min_version="1.8.4") |
| 1429 | +generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0") |
1418 | 1430 |
|
1419 | 1431 |
|
1420 | 1432 | @deploy.command( |
@@ -1759,24 +1771,28 @@ def write_manifest_quarto( |
1759 | 1771 | ) |
1760 | 1772 |
|
1761 | 1773 |
|
1762 | | -def generate_write_manifest_python(app_mode, alias): |
| 1774 | +def generate_write_manifest_python(app_mode, alias, desc: Optional[str] = None, deprecated: bool = False): |
| 1775 | + if desc is None: |
| 1776 | + desc = app_mode.desc() |
| 1777 | + |
1763 | 1778 | # noinspection SpellCheckingInspection |
1764 | 1779 | @write_manifest.command( |
1765 | 1780 | name=alias, |
1766 | | - short_help="Create a manifest.json file for a {desc}.".format(desc=app_mode.desc()), |
| 1781 | + short_help="Create a manifest.json file for a {desc}.".format(desc=desc), |
1767 | 1782 | help=( |
1768 | 1783 | "Create a manifest.json file for a {desc} for later deployment. This will create an " |
1769 | 1784 | 'environment file ("requirements.txt") if one does not exist. All files ' |
1770 | 1785 | "are created in the same directory as the API code." |
1771 | | - ).format(desc=app_mode.desc()), |
| 1786 | + ).format(desc=desc), |
| 1787 | + deprecated=deprecated, |
1772 | 1788 | ) |
1773 | 1789 | @click.option("--overwrite", "-o", is_flag=True, help="Overwrite manifest.json, if it exists.") |
1774 | 1790 | @click.option( |
1775 | 1791 | "--entrypoint", |
1776 | 1792 | "-e", |
1777 | 1793 | help=( |
1778 | 1794 | "The module and executable object which serves as the entry point for the {desc} (defaults to app)" |
1779 | | - ).format(desc=app_mode.desc()), |
| 1795 | + ).format(desc=desc), |
1780 | 1796 | ) |
1781 | 1797 | @click.option( |
1782 | 1798 | "--exclude", |
@@ -1850,12 +1866,15 @@ def manifest_writer( |
1850 | 1866 | return manifest_writer |
1851 | 1867 |
|
1852 | 1868 |
|
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") |
| 1869 | +generate_write_manifest_python(AppModes.BOKEH_APP, alias="bokeh") |
| 1870 | +generate_write_manifest_python(AppModes.DASH_APP, alias="dash") |
| 1871 | +generate_write_manifest_python(AppModes.PYTHON_API, alias="api", desc="API Application", deprecated=True) |
| 1872 | +generate_write_manifest_python(AppModes.PYTHON_API, alias="wsgi", desc="WSGI Application") |
| 1873 | +generate_write_manifest_python(AppModes.PYTHON_API, alias="flask", desc="Flask Application") |
| 1874 | +generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="asgi", desc="ASGI Application") |
| 1875 | +generate_write_manifest_python(AppModes.PYTHON_FASTAPI, alias="fastapi", desc="FastAPI Application") |
| 1876 | +generate_write_manifest_python(AppModes.PYTHON_SHINY, alias="shiny") |
| 1877 | +generate_write_manifest_python(AppModes.STREAMLIT_APP, alias="streamlit") |
1859 | 1878 |
|
1860 | 1879 |
|
1861 | 1880 | # noinspection SpellCheckingInspection |
|
0 commit comments