Skip to content

Conversation

@jcheng5
Copy link
Contributor

@jcheng5 jcheng5 commented Oct 11, 2023

Currently, rsconnect-python will infer a variety of entrypoints if none is specified by the user, depending on the files in the directory. In priority order, these are:

  • app.py
  • application.py
  • main.py
  • api.py
  • If there's only a single .py file in the directory, use it

To the end of this list, I'd like to add:

  • If there's one and only one file matching one of [app-*.py, app_*.py, *-app.py, *_app.py], use it and append :app (whereas the others assume the attribute is the same as the filename).

I've also made two other changes:

  1. If no entrypoint is detected, don't assume app:app but raise a fatal error.
  2. The actions module had a deprecated get_default_entrypoint implementation that was identical to the bundle one. I now have actions.get_default_entrypoint delegating to bundle.get_default_entrypoint (after raising its deprecation warning).

Intent

Shiny for Python has some upcoming scenarios which will make a single foo-app.py much more common in the future. We'd like to support deploying these without requiring an explicit --entrypoint argument.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

The breaking change is that we would no longer default to app:app if inference fails, but raise an error. I can't think of a case where it's preferable to go through with a whole deployment that's definitely not going to work. (It's definitely not going to work, right?)

Approach

Pretty much copied what was already there.

Automated Tests

I added unit tests that cover both my new file patterns, and some already-existing cases that had not been covered. I also refactored the relevant unit test to make it easier to add more cases.

Directions for Reviewers

In an environment with rsconnect-python and shiny installed:

mkdir testapp
cd testapp
shiny create
mv app.py example-app.py
rsconnect deploy shiny .

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.

@github-actions
Copy link

github-actions bot commented Oct 11, 2023

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4294 2791 65% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/actions.py 34% 🟢
rsconnect/bundle.py 80% 🟢
TOTAL 57% 🟢

updated for commit: 0243728 by action🐍

@jcheng5 jcheng5 merged commit a324989 into master Oct 11, 2023
@jcheng5 jcheng5 deleted the new-app-entrypoints branch October 11, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants