-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: support Python functions runtime for init
& deploy
#4653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…into cf3-dev-py
…nto functions-python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't yet see the full picture, but I'll have faith ^_^
Codecov ReportBase: 56.32% // Head: 56.15% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #4653 +/- ##
==========================================
- Coverage 56.32% 56.15% -0.18%
==========================================
Files 315 315
Lines 21324 21331 +7
Branches 4349 4350 +1
==========================================
- Hits 12011 11978 -33
- Misses 8272 8312 +40
Partials 1041 1041
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
*/ | ||
export async function setup(_setup: unknown, config: Config): Promise<void> { | ||
await config.askWriteProjectFile( | ||
`${Config.DEFAULT_FUNCTIONS_SOURCE}/requirements.txt`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use setup.functions.source
rather than default here & in other spots
import { FirebaseError } from "../../../../error"; | ||
import { Build } from "../../build"; | ||
|
||
export const LATEST_VERSION: runtimes.Runtime = "python310"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI latest is now python311
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supported in GCF? Per https://cloud.google.com/functions/docs/concepts/python-runtime, I dont see python311.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe I jumped the gun I was looking a cs
...envs, | ||
ADMIN_PORT: port.toString(), | ||
}; | ||
const args = ["python3.10", path.join(modulesDir, "private", "serving.py")]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably best not to hardcode here, maybe make an const
config.set("functions.ignore", ["venv", "__pycache__"]); | ||
// Setup VENV. | ||
await runWithVirtualEnv( | ||
["python3.10", "-m", "venv", "venv"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, best not to hardcode python3.10, use a shared const
…nto functions-python
… into functions-python
Add support for loading and serving functions written using the Firebase Functions Python SDK (WIP: https://github.com/firebase/firebase-functions-python) This PR is a fork of #4653 extended with support for emulating Python functions. Python Runtime Delegate implementation is unsurprising but does include some additional wrapper code to make sure all commands (e.g. spinning up the admin server) runs within the virtualenv environment. For now, we hardcode virtual environment `venv` directory exists on the developer's laptop, but we'll later add support for specifying arbitrary directory for specifying virtualenv directory via firebase.json configuration. Another note is that each emulated Python function will bind to a Port instead of Unix Domain Socket (UDS) as done when emulating Node.js function. This is because there is no straightfoward, platform-neutral way to bind python webserver to UDS. Finding large number of open port might have a bit more performance penalty and cause bugs due to race condition (similar to #5418) but it seems that we have no other choice atm.
Description
A first pass at adding Python functions runtime support for
init
anddeploy
.cc @inlined @taeold
Scenarios Tested
Sample Commands
firebase experiments:enable pythonfunctions
firebase init functions
(choose python)firebase deploy --only functions