Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #692
Problem
Discovery imports a top-level file under a generated module name. When
workers.pyrunsfrom app import app, Python importsapp.pya second time asapp, so the project ends up with twoApp("demo")objects. The resources register on the second one, and discovery keeps the first.Fix
_module_namereturns the file stem for a top-level file whenimport <stem>resolves to that same file, and_import_moduleimports those names withimportlib.import_module. A sibling'sfrom app import appthen gets the module discovery already imported. The generated name is still used when the stem is not an identifier or belongs to a different module, for example a project file namedjson.py.Tests
In
tests/test_apps/test_discovery.py:test_flat_project_sibling_import_shares_app, parametrized overworkers.pyanda_workers.py(sorting after and beforeapp.py): one app, with its resource. Both cases fail without this change.test_flat_module_named_like_installed_module_keeps_installed_module: a projectjson.pydoes not replace the installedjson. This one passes before and after, and covers the fallback.Live check
The project from #692, deployed to a CPU queue endpoint with
workers=(0, 1)and no jobs sent. Firstrp flash deploy workers.py, thenrp flash deployfrom the project directory:rp flash deployoutputencodeendpoint afterwardsfrom app.py, (no resources)from app.py, encode