From 04a01b757d5fb21e14bc2e08128e920a2bba5625 Mon Sep 17 00:00:00 2001 From: Lucas Rodriguez Date: Wed, 18 Dec 2024 14:26:03 -0600 Subject: [PATCH] chore: fix code formatting Ran `make fmt` Signed-off-by: Lucas Rodriguez --- .github/workflows/main.yml | 24 ++++++++-------- rsconnect/bundle.py | 4 +-- rsconnect/main.py | 55 +++++++++--------------------------- rsconnect/models.py | 4 +-- rsconnect/validation.py | 1 + tests/test_models.py | 3 -- tests/test_shiny_express.py | 1 + tests/testdata/gradio/app.py | 4 ++- 8 files changed, 33 insertions(+), 63 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9908bff3..d6bbfa73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,6 @@ jobs: python-version: ${{ matrix.python-version }} - run: pip install '.[test]' - run: pip freeze - - run: make fmt - run: make lint - run: rsconnect version - run: make test-${{ matrix.python-version }} @@ -62,7 +61,6 @@ jobs: python-version: 3.8.x - run: pip install --pre '.[test]' - run: pip freeze - - run: make fmt - run: make lint - run: rsconnect version - run: make test-3.8 @@ -188,7 +186,7 @@ jobs: run: | pytest tests/test_main_system_caches.py pytest -m 'vetiver' - + test-jupyter: runs-on: ubuntu-latest env: @@ -211,7 +209,7 @@ jobs: - name: Start Connect + rsconnect-jupyter run: | just integration-testing/up - + - name: Run Cypress Tests run: | just integration-testing/up-cypress @@ -235,7 +233,7 @@ jobs: path: integration-testing/cypress/screenshots if-no-files-found: ignore retention-days: 1 - + test-connect: needs: distributions runs-on: ubuntu-latest @@ -265,21 +263,21 @@ jobs: examples sparse-checkout-cone-mode: false token: ${{ secrets.CONNECT_PAT }} - + - name: Delete dotnet to save space run: sudo rm -rf /usr/share/dotnet - + - name: Build docker container-image run: | cd test/connect-rsconnect-python/test/rsconnect-python/ docker compose --profile rsconnect build - + - name: Restore dist uses: actions/download-artifact@v4 with: name: distributions path: dist/ - + - name: Run rsconnect-python Tests env: CONNECT_LICENSE: "${{ secrets.RSC_LICENSE }}" @@ -298,7 +296,7 @@ jobs: docker compose pull connect docker compose up -d connect just ../test/connect-rsconnect-python/test/rsconnect-python/test-rsconnect-python-repo - + # Videos are captured whether the suite fails or passes - name: Save videos uses: actions/upload-artifact@v4 @@ -307,7 +305,7 @@ jobs: name: cypress-videos_${{ matrix.PY_VERSION }}_native path: test/connect-rsconnect-python/cypress/videos if-no-files-found: ignore - + # Screenshots are only captured on failure - name: Save screenshots uses: actions/upload-artifact@v4 @@ -316,5 +314,5 @@ jobs: name: cypress-screenshots_${{ matrix.PY_VERSION }}_native path: test/connect-rsconnect-python/cypress/screenshots if-no-files-found: ignore - - + + diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index f976121a..e9790e84 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -1754,7 +1754,7 @@ def get_python_env_info( logger.debug("Environment: %s" % pformat(environment._asdict())) if override_python_version: - environment = environment._replace(python = override_python_version) + environment = environment._replace(python=override_python_version) return python, environment @@ -2247,7 +2247,7 @@ def create_python_environment( directory: str, force_generate: bool = False, python: Optional[str] = None, - override_python_version: Optional[str] = None + override_python_version: Optional[str] = None, ) -> Environment: module_file = fake_module_file_from_directory(directory) diff --git a/rsconnect/main.py b/rsconnect/main.py index 45eafb06..d0161460 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -893,10 +893,7 @@ def _warn_on_ignored_requirements(directory: str, requirements_file_name: str): @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -1043,10 +1040,7 @@ def deploy_notebook( @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -1093,10 +1087,7 @@ def deploy_voila( output_params(ctx, locals().items()) app_mode = AppModes.JUPYTER_VOILA environment = create_python_environment( - path if isdir(path) else dirname(path), - force_generate, - python, - override_python_version + path if isdir(path) else dirname(path), force_generate, python, override_python_version ) ce = RSConnectExecutor( @@ -1252,10 +1243,7 @@ def deploy_manifest( @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -1613,12 +1601,9 @@ def generate_deploy_python(app_mode: AppMode, alias: str, min_version: str, desc ), ) @click.option( - "--override-python-version", - type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + "--override-python-version", + type=validation.PYTHON_VERSION, + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -1668,10 +1653,7 @@ def deploy_app( entrypoint = validate_entry_point(entrypoint, directory) extra_files_list = validate_extra_files(directory, extra_files) environment = create_python_environment( - directory, - force_generate, - python, - override_python_version=override_python_version + directory, force_generate, python, override_python_version=override_python_version ) if app_mode == AppModes.PYTHON_SHINY: @@ -1740,6 +1722,7 @@ def deploy_app( generate_deploy_python(app_mode=AppModes.PYTHON_SHINY, alias="shiny", min_version="2022.07.0") generate_deploy_python(app_mode=AppModes.PYTHON_GRADIO, alias="gradio", min_version="2024.12.0") + @deploy.command( name="other-content", short_help="Describe deploying other content to Posit Connect.", @@ -1793,10 +1776,7 @@ def write_manifest(): @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -1888,10 +1868,7 @@ def write_manifest_notebook( @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -2020,10 +1997,7 @@ def write_manifest_voila( @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", @@ -2209,10 +2183,7 @@ def generate_write_manifest_python(app_mode: AppMode, alias: str, desc: Optional @click.option( "--override-python-version", type=validation.PYTHON_VERSION, - help=( - "An optional python version to use instead of the version from " - "the detected environment." - ) + help=("An optional python version to use instead of the version from " "the detected environment."), ) @click.option( "--force-generate", diff --git a/rsconnect/models.py b/rsconnect/models.py index 8c4ef452..bfaf5a2e 100644 --- a/rsconnect/models.py +++ b/rsconnect/models.py @@ -117,7 +117,7 @@ class AppModes: STATIC_QUARTO, PYTHON_SHINY, JUPYTER_VOILA, - PYTHON_GRADIO + PYTHON_GRADIO, ] Modes = Literal[ @@ -138,7 +138,7 @@ class AppModes: "quarto-static", "python-shiny", "jupyter-voila", - "python-gradio" + "python-gradio", ] _cloud_to_connect_modes = { diff --git a/rsconnect/validation.py b/rsconnect/validation.py index 72d3bf7a..8c5f455d 100644 --- a/rsconnect/validation.py +++ b/rsconnect/validation.py @@ -142,4 +142,5 @@ def convert(self, value: str, param: Optional[click.Parameter], ctx: Optional[cl except (AttributeError, ValueError): self.fail(f"{value!r} is not a valid python version; expected 3.x or 3.x.y", param, ctx) + PYTHON_VERSION = PythonVersionParamType() diff --git a/tests/test_models.py b/tests/test_models.py index 9c511fec..2755dac7 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -90,7 +90,6 @@ def test_glob_matcher(self): ("dir", "file", False), ("*.txt", "file.txt", True), ("*.txt", "file.csv", False), - ("dir", "dir/file", False), ("dir/*", "file", False), ("dir/*", "dir/file", True), @@ -99,7 +98,6 @@ def test_glob_matcher(self): ("dir/*.txt", "dir/file", False), ("dir/*.txt", "dir/file.txt", True), ("dir/*.txt", "dir/.txt", True), - # recursive wildcard pattern using "/" (input paths using OS separator) ("dir/**/*", "dirfile.txt", False), ("dir/**/*", os.path.join("dirother", "a.txt"), False), @@ -110,7 +108,6 @@ def test_glob_matcher(self): ("dir/**/*.txt", os.path.join("dir", "a.csv"), False), ("dir/**/*.txt", os.path.join("dir", "sub", "a.txt"), True), ("dir/**/*.txt", os.path.join("dir", "sub", "a.csv"), False), - # recursive wildcards using OS path separator. (os.path.join("dir", "**", "*.txt"), os.path.join("dir", "a.txt"), True), (os.path.join("dir", "**", "*.txt"), os.path.join("dir", "sub", "a.txt"), True), diff --git a/tests/test_shiny_express.py b/tests/test_shiny_express.py index 7f7f85d2..b3a55970 100644 --- a/tests/test_shiny_express.py +++ b/tests/test_shiny_express.py @@ -2,6 +2,7 @@ from rsconnect import shiny_express as express + def test_is_express_app(tmp_path: Path): tmp_file = str(tmp_path / "app.py") diff --git a/tests/testdata/gradio/app.py b/tests/testdata/gradio/app.py index d4eb3f69..f5d21ec6 100644 --- a/tests/testdata/gradio/app.py +++ b/tests/testdata/gradio/app.py @@ -1,12 +1,14 @@ import gradio as gr + def greet(name, intensity): return "Hello, " + name + "!" * int(intensity) + demo = gr.Interface( fn=greet, inputs=["text", "slider"], outputs=["text"], ) -demo.launch(auth = ("username", "password")) +demo.launch(auth=("username", "password"))