Skip to content

Commit 7b072f9

Browse files
priyaananthasankarscgbearShervyna Ruanasedighianthonychu
authored
Promote to master (#99)
* Docstring cont Orchestration state docstrings added * Docstring cont. Doc strings for the retry options * run flake8 only in azure/folder * demo sample for function chaining with docstring and json changes * pep8 naming add some pep8 naming to the exposed APIs * Ignore hardcoded string tests Need to decide whether we keep them or refactor to use ContextBuilder Tests are redundant with orchestrator tests as is * Work through regression bugs after renaming * Remove redundant tests * Docstrings for several api level objects OchrestrationState, Task, TaskSet, clean up some excess docstrings * Package docstrings docstrings defined for actions, history, utils and tasks packages * task_utility docstrings * ActivityType docstrings Contains refactoring to conform to python naming conventions to * Doc strings for Actions Call Activity and CallActivity with Retry * Doc Strings History Included refactor for enum naming conventions in python * Final docstring bits docstrings for tasks and json utilities * add waitforexternalevent basic files * fix bugs to make waitForExternalEvent working * add waitforexternalevent samples * remove explicit binding_info imp defined in conftest as a fixture, explicit import not required. * demo sample for function chaining with docstring and json changes * demo sample for function chaining with docstring and json changes * added dev pipeline status in README * minor fixes(variable name, delete comment) * flake8 fixes * add docstrings * implement task_any function * change pip install library and add docstrings to samples * change pip install library and add docstrings to samples * unittest for waitforexternalevents * fix bugs after merging dev * fix flake8 * Base implementation of tests test initial call test get activity and build of task set * parrot values success * test full complete flow * test failed scenario add missing bits in task_all to account for a failed task * docstring to numpy format * minor changes (rename, remove logging) * unittest for task_any, added tasks_test_utils * add class __eq__ function for Waitforexternalevent actions * add samples readme doc * fix flake8 * Refactoring HistoryEvent Get rid of all of those hardcoded property value references * add docstrings for HistoryEvent class * Refactor json conversion refactor the classes that are parsing json strings to remove all of the hardcoded property names also allows for the classes dangle additional attributes that may be present but not explicitly used for construction * simple Fan out fan in sample * Fix flake errors * Remove local debugging bits * remove state in task_any * add handle faulted task_any case +unittest * Undo De Morgan's Law cause it's really hard to read * replace filters with list comprehension more concise/readable * Add documentation for tracking API implementation * move datetime format string to azure package * replace filter with list comprehension more concise method * remove extra zimezone from format causing parsing warnings * Push context initialization our of handle method have this dependency injected instead of built within * able to pass in tasksets to task_any and task_all * update unittest for adding timestamp to taskset, add unittest for passing taskset to task_any as args * fix bugs in task_all(when all tasks fail), and fix unittest for that scenario * fix flake8 * test from orchestrator level(draft) * Remove IFunctionContext abstraction unneeded layer of abstraction with a DUCK typing language like Python * Starting of schema validation bits * createCheckStatusResponse() * wire up schema validation into the orchestrator tests * Test commit * fix flake 8 issues * fix pytest, remove task_any_tests from orchestrator level * fix flake8 * implement raise_event api, fix docstring * add unittest, create separate methods, fix naming style, handle placeholder in url validation * Fan Out Fan In sample uses tensorflow to predict whether images from bing are dogs or cats * fix flake8 * add aiohttp to requirement.txt and setup.py * add async await to start_new and raise_event api, flake8 * update api_implementation_status * fix variable naming style in docstring * update sample for external events, update readme in sample/external_events * Refactoring and docstrings removed the get generation data function. With the configurability, we can increase the volume of images to simulate the high CPU scenario. No need to fake it now. refactored some of the larger, multi task functions to create better readability added some docstrings on the functions to aid in understanding what is going on without the visual aid of powerpoint * Continue as new implementation * new_guid implementation * Fix flake8 issues * update sample to simple version * add func.httpresponse in durableorchestratorClient.py * update docstring for createcheckstatusresponse api * fix flake8 * update sample for create_check_status_response fixes * update pytest for the changes in createcheckstatusresponse api, add azure-function to requirement.txt for pytest * Implementation of call_http * Remove traceback print statement * remove url validator * Updates from demo feedback rename guid to uuid attach additional context attributes to an attribute of the durable context, not directly to the durable context * Fix flake8 * copy paste error giving a more descriptive orchestrator name * remove abcd from sample * Update API_IMPLEMENTATION_STATUS.md Sprint 7 update * Unit tests for call_http found a couple of bugs with these * merged shervyna changes * Fix the squiggles mostly formatting/inspection surpession * Move iAction moving and renaming IAction to Action * Update actions to implement action base class * remove the squiggles some minor formatting updates * Fix format of docstring * update to use rpc_base_url for start new and raise event urls * minor updates docstring on new function add Action to __init__ for actions module * flake8 bits * Add action_type property of base class * update docstrings per convention * docstring convention updates made sure docstrings conformed to the same format and indentions * Base class implementations for get_status * refactor massive string into a Dict[str, Any] object makes for a more readable bit of code * Move duplicate test rpc url constants to centralized location * adding updated contributing and getting started guides * get_status implementation includes refactoring of aiohttp calls to be able to test the rest of the bits without this server requirement tests for GetStatusOptions included base test for get_status_success * test for DurableOrchestrationStatus parsing * Add non ok message tests * add raises exception test * get_status_by and get_status_all implementation * flake8 fixes * fix docstring for get_status_by parameters copy paste error * addig nox to the project - updated requirements file * Updated noxfile to include flake, move getting started to investigations folder * typo in the commit from Jscript to python * PR recommendations remove PyCharm # noinspection tags move get and post async functions to util module replace abc123 stand-in test value with a uuid stand-in * add docstrings for new public functions * Continued Client API implementation purge_instance_history purge_instance_history_by terminate wait_for_completion_or_create_check_status_response * bug fixed for retry function. * refactor tests remove the redundant function declarations * unit tests for purge history and terminate * unit tests for wait or create check response includes bug fixes found from tests * update implementation status with features included in branch * update name match the name of the class under test * change to use asynio sleep don't want a blocking sleep call here * Use azure-functions>=1.2.0 * Make DurableOrchestrationContext available for import * Update start_new type hints to return str * Add get_input to DurableOrchestrationContext * Allow passing OrchestrationContext to create - maintain backwards compatibility when JSON body is passed * Change str to Awaitable[str] * Add get_input tests, get_input always returns str * Fix flake8 errors * add furl to setup.py * Fix merge error * # This is a combination of 3 commits. (#58) Fix samples to use the latest func.OrchestrationContext annotation Use new syntax to replace main endpoint Fix old python_durable_bindings samples * Replace badge with the new Azure Functions Python pipeline * edited contributor guide * furl is required for this project - added it to the requirements.doc * fixed pytest-asyncio in requirements.txt * fixed pytest-asyncio in requirements.txt * fixed pytest-asyncio in requirements.txt * Remove static method tag (#72) Remove static method tag (#72): residual bits left over from when a part of the client class. Causing failures in current state. Also removing unnecessary wrapper of http helper calls * Remove furl from RpcManagementOptions only durable class that is requiring this package, and is only using it to construct a url query string. Lighter requirements list to just use string joining * release artifacts * Added DateUtil and Furl to install_requires * changelog and setup.py changes * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * tested version of pipeline yaml * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipeline * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * setup.py CD testing * setup.py CD testing * PyPI testing * added info logging to the external event sample * Correctness and documentation of the samples (#85) * validated all samples except tensorflow * deleted non-samples, tested tensorflow sample, added types and comments * new readmes for fan-out-fan-in and function-chaining * renamed some functions so they are easier to reason about * disable aiohttp's input validation... potentially unsafe. ExternalEvents now shows no warnings! * Fixed Contributor Guide Issues * Fixed Contributor Guide Issues * Input value not required for start_new * input values not required for start_new * Add limitations, link to quickstart, update samples * Update example * Add link * Update words * Add versions * Update links Co-authored-by: Shawn Gaul <shgaul@microsoft.com> Co-authored-by: Shervyna Ruan <HsuanWei.Ruan@microsoft.com> Co-authored-by: Shawn Gaul <shawn.gaul@gmail.com> Co-authored-by: asedighi <sediga@alum.rpi.edu> Co-authored-by: Anthony <antchu@microsoft.com> Co-authored-by: Anthony Chu <anthony@anthonychu.ca> Co-authored-by: Hanzhang Zeng (Roger) <48038149+Hazhzeng@users.noreply.github.com> Co-authored-by: Hanzhang Zeng (Roger) <hazeng@microsoft.com> Co-authored-by: David Justo <david.justo.1996@gmail.com>
1 parent 022b514 commit 7b072f9

File tree

176 files changed

+6838
-6635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+6838
-6635
lines changed

.flake8

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
# delete D100 for docstring checks, promotes redundant documentation of what's in class docstring
3+
# W503 contradicts with pep8 and will soon be fixed by flake8
4+
ignore = W503, D100
5+
max-line-length = 99
6+
docstring-convention = numpy
7+
exclude =
8+
__pycache__,
9+
azure/durable_functions/grpc/protobuf/

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## 1.0.0b3-b4
6+
- Release to test CD pipeline with push to PyPI
7+
8+
## 1.0.0b2
9+
10+
### Fixed
11+
- [Remove staticmethod definitions](https://github.com/Azure/azure-functions-durable-python/issues/65)
12+
13+
## 1.0.0b1
14+
15+
### Added
16+
17+
The following orchestration patterns are added:
18+
19+
- Function Chaining
20+
- Fan In Fan Out
21+
- Async HTTP APIs
22+
- Human Interaction
23+
24+
#### API Parity
25+
- CallActivity
26+
- CallActivityWithRetry
27+
- Task.all
28+
- Task.any
29+
- waitForExternalEvent
30+
- continueAsNew
31+
- callHttp
32+
- currentUtcDateTime
33+
- newUuid
34+
- createCheckStatusResponse
35+
- getStatus
36+
- getStatusAll
37+
- getStatusBy
38+
- purgeInstanceHistory
39+
- purgeInstanceHistoryBy
40+
- raiseEvent
41+
- startNew
42+
- terminate
43+
- waitForCompletionOrCreateCheckStatusResponse
44+
45+
### Changed
46+
N/A
47+
48+
### Fixed
49+
N/A
50+
51+
### Removed
52+
N/A

CONTRIBUTING.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Contributor Onboarding
2+
Thank you for taking the time to contribute to Durable Functions in [Python](https://www.python.org/)
3+
4+
## Table of Contents
5+
6+
- [What should I know before I get started?](#what-should-i-know-before-i-get-started)
7+
- [Pre-requisites](#pre-requisites)
8+
- [Pull Request Change Flow](#pull-request-change-flow)
9+
- [Development Setup](#development-setup)
10+
- [Pre Commit Tasks](#pre-commit-tasks)
11+
- [Continuous Integration Guidelines & Conventions](#continuous-integration-guidelines-&-conventions)
12+
- [Getting Help](#getting-help)
13+
14+
## What should I know before I get started
15+
- [Durable Functions Overview](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview)
16+
- [Durable Functions Application Patterns](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#application-patterns)
17+
- [Azure Functions Python Overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli?tabs=bash%2Cbrowser&pivots=programming-language-python)
18+
19+
## Pre-requisites
20+
21+
- OS
22+
- MacOS (or) Windows10 Ubuntu WSL
23+
- Language Runtimes
24+
- .NET Core 2.0
25+
- \>= Python 3.6.x
26+
27+
Note: Some ML libraries may not be compatible with newer Python versions. Make sure the library is compatible with the Python version.
28+
29+
- Editor
30+
- Visual Studio Code
31+
- Python 3 Tools (pip install)
32+
- [pytest](https://docs.pytest.org/en/latest/)
33+
- [nox](https://nox.thea.codes/en/stable/)
34+
- Azure Tools
35+
- [Azure Storage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator) (or) [Create a storage account in Azure](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal)
36+
- [Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools) v2.7.x and above.
37+
- [Azure Storage Explorer](https://azure.microsoft.com/en-us/features/storage-explorer/)
38+
39+
40+
## Pull Request Change flow
41+
42+
The general flow for making a change to the library is:
43+
44+
1. 🍴 Fork the repo (add the fork via `git remote add me <clone url here>`
45+
2. 🌳 Create a branch for your change (generally branch from dev) (`git checkout -b my-change`)
46+
3. 🛠 Make your change
47+
4. ✔️ Test your change
48+
5. ⬆️ Push your changes to your fork (`git push me my-change`)
49+
6. 💌 Open a PR to the dev branch
50+
7. 📢 Address feedback and make sure tests pass (yes even if it's an "unrelated" test failure)
51+
8. 📦 [Rebase](https://git-scm.com/docs/git-rebase) your changes into meaningful commits (`git rebase -i HEAD~N` where `N` is commits you want to squash)
52+
9. :shipit: Rebase and merge (This will be done for you if you don't have contributor access)
53+
10. ✂️ Delete your branch (optional)
54+
55+
## Development Setup
56+
57+
### Visual Studio Code Extensions
58+
59+
The following extensions should be installed if using Visual Studio Code for debugging:
60+
61+
- Python support for Visual Studio Code (Python for VSCode extension)
62+
- Azure Functions Extensions for Visual Studio Code v0.19.1 and above.
63+
- autoDocString to generate documentation strings for Python API definitions.
64+
65+
### Python Virtual Environment
66+
67+
- 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.
68+
Note: Conda based environments are not yet supported in Azure Functions.
69+
70+
### Setting up durable-py debugging
71+
72+
73+
1. Git clone your fork and use any starter sample from this [folder] in your fork (https://github.com/Azure/azure-functions-durable-python/tree/dev/samples/) and open this folder in your VS Code editor.
74+
75+
2. Initialize this folder as an Azure Functions project using the VS Code Extension using these [instructions](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code?pivots=programming-language-python). This step will create a Python virtual environment if one doesn't exist already.
76+
77+
3. Add a local.settings.json file
78+
79+
```
80+
{
81+
"IsEncrypted": false,
82+
"Values": {
83+
"AzureWebJobsStorage": "<your connection string>",
84+
"FUNCTIONS_WORKER_RUNTIME": "python"
85+
}
86+
}
87+
```
88+
89+
4. Add a host.json file that looks like this
90+
91+
```
92+
{
93+
"version": "2.0",
94+
"extensionBundle": {
95+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
96+
"version": "[1.*, 2.0.0)"
97+
}
98+
}
99+
```
100+
101+
5. Optionally, if you want to specify a custom task hub name, say MyTaskHub, you can add that in the host.json file like this:
102+
103+
```
104+
{
105+
"version": "2.0",
106+
"extensions": {
107+
"durableTask": {
108+
"hubName": "MyTaskHub"
109+
}
110+
},
111+
"extensionBundle": {
112+
...
113+
}
114+
}
115+
```
116+
117+
6. For debugging, install the code using an editable pip install like this, in the VS Code Terminal:
118+
119+
```
120+
pip install -e $REPOSITORY_ROOT/
121+
```
122+
where REPOSITORY_ROOT is the root folder of the azure-functions-durable-python repository
123+
124+
7. Set breakpoints and click Run -> Start Debugging in VS Code. This should internally start the Azure Function using `func host start` command.
125+
126+
### Debugging end-to-end
127+
128+
If you want to debug into the Durable Task or any of the .NET bits, follow instructions below:
129+
130+
1. Open the Azure Storage Explorer and connect to the local storage emulator or the storage account you are using.
131+
2. Make sure the Durable Python debugging is setup already and the debugger has started the `func` process.
132+
3. In the VSCode editor for DurableTask, click Debug -> .NET Core Attach Process and search for `func host start` process and attach to it.
133+
4. Add a breakpoint in both editors and continue debugging.
134+
135+
## Testing changes locally (Windows)
136+
137+
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.
138+
139+
## Pre Commit Tasks
140+
141+
This library uses nox tooling for running unit tests and linting.
142+
143+
Make sure nox is pre-installed:
144+
`pip install nox`
145+
146+
### Running unit tests
147+
148+
1. Add your unit tests under ./tests folder
149+
2. Run: `nox --sessions tests`
150+
151+
### Running flake8 and flake8-docstring
152+
153+
Run: `nox --sessions lint`
154+
155+
This library uses [numpy docstring convention](https://numpydoc.readthedocs.io/en/latest/format.html) for code documentation.
156+
157+
158+
## Continuous Integration Guidelines & Conventions
159+
160+
This project uses a combination of Azure DevOps and GitHub Actions for CI/CD.
161+
162+
- For each PR request/merge, a continuous integration pipeline will run internally that performs linting and running unit tests on your PR/merge.
163+
- A GitHub Action will also perform CI tasks against your PR/merge. This is designed to provide more control to the contributor.
164+
- Releases into PyPI will be curated and performed by a CD pipeline internally. See the Getting Help Section to request a release.
165+
166+
## Getting help
167+
168+
- Leave comments on your PR and @username for attention
169+
170+
### Requesting a release
171+
- If you need a release into PyPI, request it by raising an issue and tagging @anthonychu or @davidmrdavid
172+
173+

README.md

Lines changed: 32 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
|Branch|Status|
22
|---|---|
3-
|master|[![Build Status](https://csefy19.visualstudio.com/Durable%20Functions%20Python%20OSS/_apis/build/status/Azure.azure-functions-durable-python?branchName=master)](https://csefy19.visualstudio.com/Durable%20Functions%20Python%20OSS/_build/latest?definitionId=39&branchName=master)|
3+
|master|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions%20Python/_apis/build/status/Azure%20Functions%20Durable%20Python?branchName=master)](https://azfunc.visualstudio.com/Azure%20Functions%20Python/_build/latest?definitionId=44&branchName=master)|
4+
|dev|[![Build Status](https://azfunc.visualstudio.com/Azure%20Functions%20Python/_apis/build/status/Azure%20Functions%20Durable%20Python?branchName=dev)](https://azfunc.visualstudio.com/Azure%20Functions%20Python/_build/latest?definitionId=44&branchName=dev)|
45

56
# Durable Functions for Python
67

7-
The `azure-functions-durable` [pip](https://pypi.org/project/azure-functions-durable/) package allows you to write [Durable Functions](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview) for Python(https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python). Durable Functions is an extension of [Azure Functions](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) that lets you write stateful functions and workflows in a serverless environment. The extension manages state, checkpoints, and restarts for you. Durable Functions' advantages include:
8+
The `azure-functions-durable` [pip](https://pypi.org/project/azure-functions-durable/) package allows you to write [Durable Functions](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview) for [Python](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python). Durable Functions is an extension of [Azure Functions](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) that lets you write stateful functions and workflows in a serverless environment. The extension manages state, checkpoints, and restarts for you. Durable Functions' advantages include:
89

910
* Define workflows in code. No JSON schemas or designers are needed.
1011
* Call other functions synchronously and asynchronously. Output from called functions can be saved to local variables.
@@ -24,81 +25,53 @@ A durable function, or _orchestration_, is a solution made up of different types
2425

2526
Durable Functions' function types and features are documented in-depth [here.](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-types-features-overview)
2627

27-
## Getting Started
28-
29-
You can follow the instructions below to get started with a function chaining example, or follow the general checklist below:
28+
## Current limitations
3029

31-
1. Install prerequisites:
32-
- [Azure Functions Core Tools version 2.x](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#install-the-azure-functions-core-tools)
33-
- [Azure Storage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator) (Windows) or an actual Azure storage account (Mac or Linux)
34-
- Python 3.6 or later
30+
We're actively working on Python support for Durable Functions and we expect a Public Preview announcement in Q2 CY2020. The following are the current known limitations.
3531

36-
2. [Create an Azure Functions app.](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python)
32+
### Functionality
3733

38-
3. Install the Durable Functions extension
34+
* `DurableOrchestrationContext.create_timer()` is not yet supported (coming soon [#35](https://github.com/Azure/azure-functions-durable-python/issues/35))
35+
* Sub-orchestrations are not yet supported (planned [#62](https://github.com/Azure/azure-functions-durable-python/issues/62))
36+
* Durable Entities are not yet supported (not yet planned [#96](https://github.com/Azure/azure-functions-durable-python/issues/96))
3937

40-
Run this command from the root folder of your Azure Functions app:
41-
```bash
42-
func extensions install -p Microsoft.Azure.WebJobs.Extensions.DurableTask -v 1.8.3
43-
```
38+
### Tooling
4439

45-
**durable-functions requires Microsoft.Azure.WebJobs.Extensions.DurableTask 1.7.0 or greater.**
40+
* Python Durable Functions requires updated versions of Azure Functions Core Tools that includes Python worker [1.1.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/1.1.0), templates ([bundle-1.2.0](https://github.com/Azure/azure-functions-templates/releases/tag/bundle-1.2.0)), and extension bundles ([1.2.0](https://github.com/Azure/azure-functions-extension-bundles/releases/tag/1.2.0)) that are not yet released (ETA May 2020). Use the VS Code dev container in the [Getting Started](#getting-started) section to access a development environment with the required versions of the tools installed.
4641

47-
4. Install the `azure-durable-functions` pip package at the root of your function app:
42+
### Deployment
4843

49-
Create and activate virtual environment
50-
```
51-
python3 -m venv env
52-
source env/bin/activate
53-
```
44+
* Python Durable Functions requires an updated version of the Azure Functions Python language worker ([1.1.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/1.1.0)) that is not yet available in Azure. Deploy your Python Durable Functions apps in containers (requires Premium or App Service plans). (Linux consumption plan support ETA May 2020)
5445

55-
```bash
56-
pip install azure-durable-functions
57-
```
58-
59-
5. Write an activity function ([see sample](./samples/python_durable_bindings/DurableActivity)):
60-
```python
61-
def main(name: str) -> str:
62-
logging.info(f"Activity Triggered: {name}")
63-
# your code here
64-
```
46+
## Getting Started
6547

66-
6. Write an orchestrator function ([see sample](./samples/python_durable_bindings/DurableOrchestrationTrigger)):
48+
Follow these instructions to get started with Durable Functions in Python:
6749

68-
```python
69-
def main(context: str):
70-
orchestrate = df.Orchestrator.create(generator_function)
71-
result = orchestrate(context)
72-
return result
73-
```
50+
**🚀 [Python Durable Functions quickstart](https://aka.ms/pythondurable)**
7451

75-
**Note:** Orchestrator functions must follow certain [code constraints.](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-checkpointing-and-replay#orchestrator-code-constraints)
52+
## Samples
7653

77-
7. Write your client function ([see sample](./samples/DurableOrchestrationClient/)):
54+
Take a look at this project's [samples directory](./samples/):
7855

79-
TBD
56+
* [Function Chaining](./samples/function_chaining)
57+
* [Fan-out/Fan-in - Simple](./samples/fan_out_fan_in)
58+
* [Fan-out/Fan-in - TensorFlow](./samples/fan_out_fan_in_tensorflow)
59+
* [External Events - Human Interaction & Timeouts](./samples/external_events)
8060

81-
**Note:** Client functions are started by a trigger binding available in the Azure Functions 2.x major version. [Read more about trigger bindings and 2.x-supported bindings.](https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#overview)
61+
### Orchestrator example
8262

83-
## Samples
63+
```python
64+
import azure.durable_functions as df
8465

85-
The [Durable Functions samples](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-install) demonstrate several common use cases. They are located in the [samples directory.](./samples/) Descriptive documentation is also available:
8666

87-
* [Function Chaining - Hello Sequence](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-sequence)
88-
* [Fan-out/Fan-in - Cloud Backup](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-cloud-backup)
89-
* [Monitors - Weather Watcher](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-monitor)
90-
* [Human Interaction & Timeouts - Phone Verification](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-phone-verification)
67+
def orchestrator_function(context: df.DurableOrchestrationContext):
68+
task1 = yield context.call_activity("DurableActivity", "One")
69+
task2 = yield context.call_activity("DurableActivity", "Two")
70+
task3 = yield context.call_activity("DurableActivity", "Three")
9171

92-
```python
93-
def generator_function(context):
94-
outputs = []
95-
task1 = yield context.df.callActivity("DurableActivity", "One")
96-
task2 = yield context.df.callActivity("DurableActivity", "Two")
97-
task3 = yield context.df.callActivity("DurableActivity", "Three")
72+
outputs = [task1, task2, task3]
73+
return outputs
9874

99-
outputs.append(task1)
100-
outputs.append(task2)
101-
outputs.append(task3)
10275

103-
return outputs
76+
main = df.Orchestrator.create(orchestrator_function)
10477
```

0 commit comments

Comments
 (0)