6.9 KiB
Contributor Onboarding
Thank you for taking the time to contribute to Durable Functions in Python
Table of Contents
- What should I know before I get started?
- Pre-requisites
- Pull Request Change Flow
- Development Setup
- Pre Commit Tasks
- Continuous Integration Guidelines & Conventions
- Getting Help
What should I know before I get started
Pre-requisites
Alternatively you can use a dev container or open in GitHub Codespaces.
- OS
- MacOS (or) Windows10 Ubuntu WSL
- Language Runtimes
- .NET Core 2.0
- >= Python 3.6.x
Note: Some ML libraries may not be compatible with newer Python versions. Make sure the library is compatible with the Python version.
- Editor
- Visual Studio Code
- Python 3 Tools (pip install)
- Azure Tools
- Azure Storage Emulator (or) Create a storage account in Azure
- Azure Functions Core Tools v2.7.x and above.
- Azure Storage Explorer
Pull Request Change flow
The general flow for making a change to the library is:
- 🍴 Fork the repo (add the fork via
git remote add me <clone url here>
- 🌳 Create a branch for your change (generally branch from dev) (
git checkout -b my-change
) - 🛠 Make your change
- ✔️ Test your change
- ⬆️ Push your changes to your fork (
git push me my-change
) - 💌 Open a PR to the dev branch
- 📢 Address feedback and make sure tests pass (yes even if it's an "unrelated" test failure)
- 📦 Rebase your changes into meaningful commits (
git rebase -i HEAD~N
whereN
is commits you want to squash) - :shipit: Rebase and merge (This will be done for you if you don't have contributor access)
- ✂️ Delete your branch (optional)
Development Setup
Visual Studio Code Extensions
The following extensions should be installed if using Visual Studio Code for debugging:
- Python support for Visual Studio Code (Python for VSCode extension)
- Azure Functions Extensions for Visual Studio Code v0.19.1 and above.
- autoDocString to generate documentation strings for Python API definitions.
Python Virtual Environment
- Make sure a Python virtual environment is setup. If you are using VS Code, the Azure Functions Extension project will set one up for you. Alternately, you can set it up through command line as well. Note: Conda based environments are not yet supported in Azure Functions.
Setting up durable-py debugging
-
Git clone your fork and use any starter sample from this folder in your fork and open this folder in your VS Code editor.
-
Initialize this folder as an Azure Functions project using the VS Code Extension using these instructions. This step will create a Python virtual environment if one doesn't exist already.
-
Add a local.settings.json file
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<your connection string>",
"FUNCTIONS_WORKER_RUNTIME": "python"
}
}
- Add a host.json file that looks like this
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
- Optionally, if you want to specify a custom task hub name, say MyTaskHub, you can add that in the host.json file like this:
{
"version": "2.0",
"extensions": {
"durableTask": {
"hubName": "MyTaskHub"
}
},
"extensionBundle": {
...
}
}
- For debugging, install the code using an editable pip install like this, in the VS Code Terminal:
pip install -e $REPOSITORY_ROOT/
where REPOSITORY_ROOT is the root folder of the azure-functions-durable-python repository
- Set breakpoints and click Run -> Start Debugging in VS Code. This should internally start the Azure Function using
func host start
command.
Debugging end-to-end
If you want to debug into the Durable Task or any of the .NET bits, follow instructions below:
- Open the Azure Storage Explorer and connect to the local storage emulator or the storage account you are using.
- Make sure the Durable Python debugging is setup already and the debugger has started the
func
process. - In the VSCode editor for DurableTask, click Debug -> .NET Core Attach Process and search for
func host start
process and attach to it. - Add a breakpoint in both editors and continue debugging.
Testing changes locally (Windows)
Follow all the steps above, use the Azure Storage Emulator for windows to simulate the storage account, and use Visual Studio to debug the .NET Durable Extension.
Pre Commit Tasks
This library uses nox tooling for running unit tests and linting.
Make sure nox is pre-installed:
pip install nox
Running unit tests
- Add your unit tests under ./tests folder
- Run:
nox --sessions tests
Running flake8 and flake8-docstring
Run: nox --sessions lint
This library uses numpy docstring convention for code documentation.
Continuous Integration Guidelines & Conventions
This project uses a combination of Azure DevOps and GitHub Actions for CI/CD.
- For each PR request/merge, a continuous integration pipeline will run internally that performs linting and running unit tests on your PR/merge.
- A GitHub Action will also perform CI tasks against your PR/merge. This is designed to provide more control to the contributor.
- Releases into PyPI will be curated and performed by a CD pipeline internally. See the Getting Help Section to request a release.
Getting help
- Leave comments on your PR and @username for attention
Requesting a release
- If you need a release into PyPI, request it by raising an issue and tagging @anthonychu or @davidmrdavid