Skip to content

Promote to master #130

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

Merged
merged 295 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
295 commits
Select commit Hold shift + click to select a range
6c3cf13
task_utility docstrings
scgbear Jan 21, 2020
1ad001c
ActivityType docstrings
scgbear Jan 21, 2020
c822292
Doc strings for Actions
scgbear Jan 21, 2020
5110546
Doc Strings History
scgbear Jan 21, 2020
a2fa8a2
Final docstring bits
scgbear Jan 21, 2020
e1eaa44
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Jan 21, 2020
ab6bf56
add waitforexternalevent basic files
Jan 22, 2020
d40dae3
fix bugs to make waitForExternalEvent working
Jan 22, 2020
5b129d6
add waitforexternalevent samples
Jan 22, 2020
4857676
remove explicit binding_info imp
scgbear Jan 22, 2020
2f46197
Merge pull request #26 from scgbear/features/function-chaining
priyaananthasankar Jan 22, 2020
d36ba81
demo sample for function chaining with docstring and json changes
priyaananthasankar Jan 22, 2020
d4363e3
Merge branch 'priya_samples' of https://github.com/priyaananthasankar…
priyaananthasankar Jan 22, 2020
f88745e
demo sample for function chaining with docstring and json changes
priyaananthasankar Jan 22, 2020
713f220
Merge branch 'dev' into priya_samples
priyaananthasankar Jan 22, 2020
a48385f
added dev pipeline status in README
priyaananthasankar Jan 22, 2020
b680bf4
Merge branch 'dev' into readme_blurb
priyaananthasankar Jan 22, 2020
e83553f
Merge pull request #32 from priyaananthasankar/readme_blurb
priyaananthasankar Jan 22, 2020
637ac75
minor fixes(variable name, delete comment)
Jan 25, 2020
f17824c
flake8 fixes
Jan 25, 2020
92b44a3
merge dev
Jan 25, 2020
458080e
add docstrings
Jan 25, 2020
18ff4a9
implement task_any function
Jan 25, 2020
45e4320
change pip install library and add docstrings to samples
priyaananthasankar Jan 26, 2020
642cd17
Merge branch 'priya_samples' of https://github.com/priyaananthasankar…
priyaananthasankar Jan 26, 2020
54ce47f
Merge branch 'dev' into priya_samples
priyaananthasankar Jan 26, 2020
14f6808
change pip install library and add docstrings to samples
priyaananthasankar Jan 26, 2020
4fb3b01
Merge branch 'priya_samples' of https://github.com/priyaananthasankar…
priyaananthasankar Jan 26, 2020
b6ce069
Merge pull request #31 from priyaananthasankar/priya_samples
priyaananthasankar Jan 26, 2020
a770cbd
unittest for waitforexternalevents
Jan 27, 2020
1c017c2
fix bugs after merging dev
Jan 27, 2020
6adca1b
fix flake8
Jan 27, 2020
633ba0b
Base implementation of tests
scgbear Jan 27, 2020
9b8c142
parrot values success
scgbear Jan 27, 2020
bffaf51
test full complete flow
scgbear Jan 27, 2020
c742b94
test failed scenario
scgbear Jan 27, 2020
80181a5
docstring to numpy format
Jan 28, 2020
bcfe725
minor changes (rename, remove logging)
Jan 28, 2020
c943314
unittest for task_any, added tasks_test_utils
Jan 28, 2020
fd56235
add class __eq__ function for Waitforexternalevent actions
Jan 28, 2020
d5ccb54
add samples readme doc
Jan 28, 2020
4dd7632
fix flake8
Jan 28, 2020
d36bbd0
Refactoring HistoryEvent
scgbear Jan 28, 2020
48de0a2
add docstrings for HistoryEvent class
scgbear Jan 28, 2020
472eb76
Refactor json conversion
scgbear Jan 28, 2020
6d9ffe4
simple Fan out fan in sample
scgbear Jan 28, 2020
68453cd
Fix flake errors
scgbear Jan 28, 2020
b4f88fc
Remove local debugging bits
scgbear Jan 28, 2020
19e7fcc
remove state in task_any
Jan 29, 2020
1ed87ba
add handle faulted task_any case +unittest
Jan 29, 2020
fb46614
Undo De Morgan's Law
scgbear Jan 29, 2020
f449f62
replace filters with list comprehension
scgbear Jan 29, 2020
cea9b8c
Add documentation for tracking API implementation
scgbear Jan 29, 2020
5008b3b
move datetime format string to azure package
scgbear Jan 29, 2020
e5b1400
replace filter with list comprehension
scgbear Jan 30, 2020
49c80c6
remove extra zimezone from format
scgbear Jan 30, 2020
b3098a9
Push context initialization our of handle method
scgbear Jan 30, 2020
57203eb
Merge pull request #38 from scgbear/documentation/api-implementation-…
priyaananthasankar Jan 31, 2020
e172f6e
able to pass in tasksets to task_any and task_all
Feb 3, 2020
48fe9ff
Merge branch 'dev' into issue/27/waitForExternalEvent
Feb 3, 2020
5a4e3c4
update unittest for adding timestamp to taskset, add unittest for pas…
Feb 3, 2020
d271bd0
fix bugs in task_all(when all tasks fail), and fix unittest for that …
Feb 3, 2020
6ae0d95
fix flake8
Feb 3, 2020
00e8918
test from orchestrator level(draft)
Feb 4, 2020
8ac85af
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Feb 5, 2020
9fb5102
Remove IFunctionContext abstraction
scgbear Feb 5, 2020
1fa68ac
Starting of schema validation bits
scgbear Feb 6, 2020
01c24df
createCheckStatusResponse()
Feb 6, 2020
50d1bbe
wire up schema validation into the orchestrator tests
scgbear Feb 6, 2020
1c4fe49
Test commit
scgbear Feb 7, 2020
56a566a
fix flake 8 issues
scgbear Feb 7, 2020
4de893c
Merge pull request #45 from scgbear/dev
priyaananthasankar Feb 7, 2020
e244a73
merge dev
Feb 7, 2020
48a081b
fix pytest, remove task_any_tests from orchestrator level
Feb 7, 2020
7e1f61c
fix flake8
Feb 7, 2020
0862e00
implement raise_event api, fix docstring
Feb 10, 2020
325219e
Merge pull request #29 from shervyna/issue/27/waitForExternalEvent
priyaananthasankar Feb 11, 2020
40ca24c
add unittest, create separate methods, fix naming style, handle place…
Feb 11, 2020
c87c252
Fan Out Fan In sample
scgbear Feb 11, 2020
92a2090
fix flake8
Feb 12, 2020
4183093
merge dev
Feb 12, 2020
c25eecc
add aiohttp to requirement.txt and setup.py
Feb 12, 2020
d5e28c7
add async await to start_new and raise_event api, flake8
Feb 12, 2020
fd638b3
update api_implementation_status
Feb 12, 2020
ce5f4ee
fix variable naming style in docstring
Feb 12, 2020
8fc7f55
update sample for external events, update readme in sample/external_e…
Feb 12, 2020
bfe9827
Refactoring and docstrings
scgbear Feb 12, 2020
ead107f
Continue as new implementation
scgbear Feb 12, 2020
bb43dd7
new_guid implementation
scgbear Feb 12, 2020
62ad2c5
Fix flake8 issues
scgbear Feb 12, 2020
eea874d
update sample to simple version
Feb 13, 2020
85db5e2
add func.httpresponse in durableorchestratorClient.py
Feb 13, 2020
104f859
update docstring for createcheckstatusresponse api
Feb 13, 2020
27bf076
fix flake8
Feb 13, 2020
93145d4
update sample for create_check_status_response fixes
Feb 13, 2020
64b5f1c
update pytest for the changes in createcheckstatusresponse api, add a…
Feb 13, 2020
b2eace1
Implementation of call_http
scgbear Feb 13, 2020
5f68ba3
Remove traceback print statement
scgbear Feb 13, 2020
5eff795
remove url validator
Feb 14, 2020
6608f34
Updates from demo feedback
scgbear Feb 14, 2020
3230d63
Fix flake8
scgbear Feb 14, 2020
9f27e1f
copy paste error
scgbear Feb 14, 2020
89e3464
remove abcd from sample
Feb 14, 2020
69016eb
Update API_IMPLEMENTATION_STATUS.md
priyaananthasankar Feb 14, 2020
cbcb47d
Merge pull request #51 from Azure/priyaananthasankar-patch-1
priyaananthasankar Feb 14, 2020
60a42fb
Merge branch 'dev' into samples/high-cpu-fan-out
priyaananthasankar Feb 15, 2020
eae53c4
Merge pull request #46 from scgbear/samples/high-cpu-fan-out
priyaananthasankar Feb 15, 2020
6689767
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Feb 15, 2020
7df1ef7
Merge pull request #50 from scgbear/features/orchestrator-api
priyaananthasankar Feb 15, 2020
2365832
Unit tests for call_http
scgbear Feb 15, 2020
71eddbc
merged shervyna changes
priyaananthasankar Feb 16, 2020
4343d1e
Merge branch 'dev' into shervyna_changes
priyaananthasankar Feb 16, 2020
48ae802
Merge pull request #53 from priyaananthasankar/shervyna_changes
scgbear Feb 18, 2020
812237a
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Feb 18, 2020
558d551
Merge pull request #52 from scgbear/tests/call_http
scgbear Feb 18, 2020
9d2e480
Fix the squiggles
scgbear Feb 19, 2020
90f6691
Move iAction
scgbear Feb 19, 2020
dab93a8
Update actions to implement action base class
scgbear Feb 19, 2020
5926a7e
remove the squiggles
scgbear Feb 19, 2020
42eef99
Fix format of docstring
scgbear Feb 19, 2020
d381f3b
update to use rpc_base_url for start new and raise event urls
scgbear Feb 19, 2020
f5f2c74
minor updates
scgbear Feb 19, 2020
2852c80
flake8 bits
scgbear Feb 19, 2020
d6db7da
Add action_type property of base class
scgbear Feb 19, 2020
516ff60
update docstrings per convention
scgbear Feb 19, 2020
03ee5e3
docstring convention updates
scgbear Feb 19, 2020
12a30cb
Base class implementations for get_status
scgbear Feb 20, 2020
2754dbf
refactor massive string into a Dict[str, Any] object
scgbear Feb 20, 2020
3b598b5
Move duplicate test rpc url constants to centralized location
scgbear Feb 20, 2020
8e22e7b
adding updated contributing and getting started guides
asedighi Feb 20, 2020
17d254c
get_status implementation
scgbear Feb 21, 2020
f1460c3
Merge pull request #55 from scgbear/features/client-api
scgbear Feb 21, 2020
3e71ce2
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Feb 21, 2020
13fae66
test for DurableOrchestrationStatus parsing
scgbear Feb 21, 2020
1424ba4
Add non ok message tests
scgbear Feb 21, 2020
a7b18be
add raises exception test
scgbear Feb 21, 2020
0a110a1
get_status_by and get_status_all implementation
scgbear Feb 21, 2020
05e2602
flake8 fixes
scgbear Feb 21, 2020
3ff041e
fix docstring for get_status_by parameters
scgbear Feb 21, 2020
2288eec
addig nox to the project - updated requirements file
asedighi Feb 21, 2020
d65575c
Updated noxfile to include flake, move getting started to investigations
asedighi Feb 21, 2020
e0b1fa1
typo in the commit from Jscript to python
asedighi Feb 24, 2020
49baa84
PR recommendations
scgbear Feb 25, 2020
45e5f28
add docstrings for new public functions
scgbear Feb 25, 2020
671cae3
Continued Client API implementation
scgbear Feb 25, 2020
d76764a
bug fixed for retry function.
asedighi Feb 25, 2020
4e19ac5
refactor tests
scgbear Feb 26, 2020
c04154c
unit tests for purge history and terminate
scgbear Feb 26, 2020
03ba160
unit tests for wait or create check response
scgbear Feb 26, 2020
95b67f1
update implementation status with features included in branch
scgbear Feb 26, 2020
43e6cd1
update name match the name of the class under test
scgbear Feb 26, 2020
c7748d7
change to use asynio sleep
scgbear Feb 27, 2020
9628393
Use azure-functions>=1.2.0
anthonychu Mar 1, 2020
8d32b82
Make DurableOrchestrationContext available for import
anthonychu Mar 1, 2020
344f540
Update start_new type hints to return str
anthonychu Mar 1, 2020
f3ff50f
Add get_input to DurableOrchestrationContext
anthonychu Mar 1, 2020
7165442
Allow passing OrchestrationContext to create
anthonychu Mar 1, 2020
966e3cc
Change str to Awaitable[str]
anthonychu Mar 2, 2020
d620a20
Add get_input tests, get_input always returns str
anthonychu Mar 3, 2020
68cd452
Fix flake8 errors
anthonychu Mar 3, 2020
de04569
Merge pull request #60 from anthonychu/anthony-20200301
anthonychu Mar 3, 2020
c659f93
add furl to setup.py
scgbear Mar 4, 2020
7c2d7dc
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Mar 4, 2020
66b12cd
Fix merge error
scgbear Mar 4, 2020
61fac3b
# This is a combination of 3 commits. (#58)
Hazhzeng Mar 4, 2020
1d1a079
Merge branch 'dev' into features/client-api
scgbear Mar 5, 2020
3f4a34c
Replace badge with the new Azure Functions Python pipeline
Mar 5, 2020
06f6482
Merge pull request #61 from Azure/hazeng/new-pipeline
scgbear Mar 6, 2020
8ce1a42
Merge branch 'dev' of github.com:Azure/azure-functions-durable-python…
scgbear Mar 6, 2020
4b9169b
Merge pull request #56 from scgbear/features/client-api
priyaananthasankar Mar 9, 2020
6b5151b
edited contributor guide
priyaananthasankar Mar 11, 2020
3ded407
Merge branch 'art_2' into dev
asedighi Mar 11, 2020
c4c9bf6
resolved conflict for requirements.txt
asedighi Mar 11, 2020
4398525
furl is required for this project - added it to the requirements.doc
asedighi Mar 11, 2020
8cfe2c2
Merge pull request #64 from asedighi/dev
priyaananthasankar Mar 11, 2020
42471d3
Merge branch 'dev' into pr57
priyaananthasankar Mar 11, 2020
5e0f3b1
Merge pull request #63 from priyaananthasankar/pr57
priyaananthasankar Mar 11, 2020
1e9eb23
fixed pytest-asyncio in requirements.txt
priyaananthasankar Mar 11, 2020
c8dbba2
fixed pytest-asyncio in requirements.txt
priyaananthasankar Mar 12, 2020
c7468e7
fixed pytest-asyncio in requirements.txt
priyaananthasankar Mar 12, 2020
452cebd
Merge pull request #66 from priyaananthasankar/priya_pytest_asyncio
priyaananthasankar Mar 12, 2020
2c6b2f3
Remove static method tag (#72)
scgbear Mar 13, 2020
eb0b696
Remove furl from RpcManagementOptions
scgbear Mar 13, 2020
4a1c89d
release artifacts
priyaananthasankar Mar 13, 2020
e4229da
Merge pull request #74 from scgbear/refactor/remove-furl
priyaananthasankar Mar 13, 2020
7b0e38a
Merge branch 'dev' into priya_release_branch
priyaananthasankar Mar 13, 2020
5777d7d
Merge pull request #75 from priyaananthasankar/priya_release_branch
priyaananthasankar Mar 13, 2020
148c10c
Added DateUtil and Furl to install_requires
priyaananthasankar Mar 13, 2020
92c4035
Merge pull request #76 from priyaananthasankar/priya_release_branch
priyaananthasankar Mar 13, 2020
e64b260
changelog and setup.py changes
priyaananthasankar Mar 13, 2020
fcdb726
Merge pull request #79 from priyaananthasankar/priya_release_branch
priyaananthasankar Mar 14, 2020
0a21906
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
1485284
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
ecff33a
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
3041f5d
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
385125c
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
995dae3
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
081bab4
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
a18dc60
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 17, 2020
6db87e8
tested version of pipeline yaml
asedighi Mar 17, 2020
23c850f
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 18, 2020
7461265
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 18, 2020
5942d49
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 18, 2020
7241037
Update azure-pipelines.yml for Azure Pipeline
asedighi Mar 19, 2020
333a2cb
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
5a2082c
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
7cfda0e
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
de4a6d1
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
5975b4d
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
65c1afa
Update azure-pipelines.yml for Azure Pipelines
asedighi Mar 19, 2020
71686a7
Merge pull request #81 from Azure/art-testing-azure-pipelines
priyaananthasankar Mar 19, 2020
cd0d988
setup.py CD testing
priyaananthasankar Mar 19, 2020
ddc2282
setup.py CD testing
priyaananthasankar Mar 19, 2020
e6c5dcb
Merge branch 'dev' into pipeline_test
priyaananthasankar Mar 19, 2020
88e7c6b
Merge pull request #83 from priyaananthasankar/pipeline_test
priyaananthasankar Mar 19, 2020
5b110d4
PyPI testing
priyaananthasankar Mar 19, 2020
d345ec5
Merge pull request #84 from priyaananthasankar/pipeline_test
priyaananthasankar Mar 19, 2020
fb65791
added info logging to the external event sample
asedighi Mar 24, 2020
4cc93fa
Merge pull request #88 from asedighi/logging-telemetary-addition
priyaananthasankar Mar 24, 2020
d01677a
Correctness and documentation of the samples (#85)
davidmrdavid Mar 25, 2020
121f3a2
Fixed Contributor Guide Issues
priyaananthasankar Mar 26, 2020
9e0f4aa
Fixed Contributor Guide Issues
priyaananthasankar Mar 27, 2020
bc6e44f
Merge branch 'dev' into priya_contribguide_issues
priyaananthasankar Mar 27, 2020
366aab0
Input value not required for start_new
davidmrdavid Mar 27, 2020
54368cb
Merge branch 'dev' into priya_contribguide_issues
priyaananthasankar Mar 27, 2020
77bca2d
Merge pull request #92 from priyaananthasankar/priya_contribguide_issues
priyaananthasankar Mar 27, 2020
c440e95
Add limitations, link to quickstart, update samples
anthonychu Mar 29, 2020
fe24892
Update example
anthonychu Mar 29, 2020
ec87389
Add link
anthonychu Mar 29, 2020
a2de756
Update words
anthonychu Mar 29, 2020
7ad7af3
Add versions
anthonychu Mar 29, 2020
15ca68d
Update links
anthonychu Mar 30, 2020
6814730
Merge pull request #97 from anthonychu/20200328-update-readme-devcont…
priyaananthasankar Mar 30, 2020
6592177
versioning-via-tags is enabled (#101)
davidmrdavid Mar 30, 2020
1f16145
updated readme for external events (#103)
asedighi Apr 1, 2020
d271980
Readme file for FanOutFanIn (#104)
priyaananthasankar Apr 4, 2020
fcac54e
Add activity trigger return type sample (#105)
Hazhzeng Apr 10, 2020
4639b78
misc contributions (#108)
davidmrdavid Apr 14, 2020
bc0b459
Set Custom Status (#110)
priyaananthasankar Apr 27, 2020
5c81db9
Enabled nox to recognize docstring formatting errors (#122)
davidmrdavid Jun 10, 2020
5893abe
enables trivial orchestrators (#121)
davidmrdavid Jun 10, 2020
53be9b6
removed grpc folder (#120)
davidmrdavid Jun 10, 2020
57c57da
[WIP] Semi-automatic type-serialization (#109)
davidmrdavid Jun 10, 2020
c7c710b
Promote to master (#99) (#126)
davidmrdavid Jun 10, 2020
87fb580
Promote to master (#99) (#127)
davidmrdavid Jun 10, 2020
3dcbc08
Merge branch 'master' into dev
davidmrdavid Jun 10, 2020
ceba652
Monitoring Feature (#119)
priyaananthasankar Jun 18, 2020
e2f1041
updated CHANGELOG (#128)
davidmrdavid Jun 18, 2020
9e560c7
Changelog includes links (#129)
davidmrdavid Jun 18, 2020
be50bbe
merged master
davidmrdavid Jun 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file.

## 1.0.0b6

- [Create timer](https://github.com/Azure/azure-functions-durable-python/issues/35) functionality available

## 1.0.0b5

- [Object serialization](https://github.com/Azure/azure-functions-durable-python/issues/90) made available
- [Can set custom status](https://github.com/Azure/azure-functions-durable-python/issues/117) of orchestration

## 1.0.0b3-b4
- Release to test CD pipeline with push to PyPI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..models.Task import Task
from ..models.TokenSource import TokenSource
from ..tasks import call_activity_task, task_all, task_any, call_activity_with_retry_task, \
wait_for_external_event_task, continue_as_new, new_uuid, call_http
wait_for_external_event_task, continue_as_new, new_uuid, call_http, create_timer_task
from azure.functions._durable_functions import _deserialize_custom_object


Expand Down Expand Up @@ -51,6 +51,7 @@ def __init__(self,
self.continue_as_new = lambda i: continue_as_new(input_=i)
self.task_any = lambda t: task_any(tasks=t)
self.task_all = lambda t: task_all(tasks=t)
self.create_timer = lambda d: create_timer_task(state=self.histories, fire_at=d)
self.decision_started_event: HistoryEvent = \
[e_ for e_ in self.histories
if e_.event_type == HistoryEventType.ORCHESTRATOR_STARTED][0]
Expand Down
42 changes: 42 additions & 0 deletions azure/durable_functions/models/actions/CreateTimerAction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from typing import Any, Dict

from .ActionType import ActionType
from ..utils.json_utils import add_attrib, add_datetime_attrib
import datetime


class CreateTimerAction:
"""Defines the structure of the Create Timer object.

Returns
-------
Information needed by durable extension to schedule the activity

Raises
------
ValueError
if the event fired is not of valid datetime object
"""

def __init__(self, fire_at: datetime, is_cancelled: bool = False):
self.action_type: ActionType = ActionType.CREATE_TIMER
self.fire_at: datetime = fire_at
self.is_cancelled: bool = is_cancelled

if not isinstance(self.fire_at, datetime.date):
raise ValueError("fireAt: Expected valid datetime object but got ", self.fire_at)

def to_json(self) -> Dict[str, Any]:
"""
Convert object into a json dictionary.

Returns
-------
Dict[str, Any]
The instance of the class converted into a json dictionary
"""
json_dict = {}
add_attrib(json_dict, self, 'action_type', 'actionType')
add_datetime_attrib(json_dict, self, 'fire_at', 'fireAt')
add_attrib(json_dict, self, 'is_cancelled', 'isCanceled')
return json_dict
4 changes: 3 additions & 1 deletion azure/durable_functions/models/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from .CallActivityWithRetryAction import CallActivityWithRetryAction
from .WaitForExternalEventAction import WaitForExternalEventAction
from .CallHttpAction import CallHttpAction
from .CreateTimerAction import CreateTimerAction

__all__ = [
'Action',
'ActionType',
'CallActivityAction',
'CallActivityWithRetryAction',
'CallHttpAction',
'WaitForExternalEventAction'
'WaitForExternalEventAction',
'CreateTimerAction'
]
4 changes: 3 additions & 1 deletion azure/durable_functions/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .continue_as_new import continue_as_new
from .new_uuid import new_uuid
from .call_http import call_http
from .create_timer import create_timer_task

__all__ = [
'call_activity_task',
Expand All @@ -18,5 +19,6 @@
'task_all',
'task_any',
'should_suspend',
'wait_for_external_event_task'
'wait_for_external_event_task',
'create_timer_task'
]
41 changes: 41 additions & 0 deletions azure/durable_functions/tasks/create_timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import List
from ..models.actions.CreateTimerAction import CreateTimerAction
from ..models.history import HistoryEvent
from .task_utilities import find_task_timer_created, find_task_retry_timer_fired, set_processed
import datetime
from .timer_task import TimerTask


def create_timer_task(state: List[HistoryEvent],
fire_at: datetime) -> TimerTask:
"""Durable Timers are used in orchestrator function to implement delays.

Parameters
----------
state : List[HistoryEvent]
The list of history events to search to determine the current state of the activity
fire_at : datetime
The time interval to fire the timer trigger

Returns
-------
TimerTask
A Durable Timer Task that schedules the timer to wake up the activity
"""
new_action = CreateTimerAction(fire_at)

timer_created = find_task_timer_created(state, fire_at)
timer_fired = find_task_retry_timer_fired(state, timer_created)

set_processed([timer_created, timer_fired])

if timer_fired:
return TimerTask(
is_completed=True, action=new_action,
timestamp=timer_fired.timestamp,
id_=timer_fired.event_id)
else:
return TimerTask(
is_completed=False, action=new_action,
timestamp=None,
id_=None)
24 changes: 24 additions & 0 deletions azure/durable_functions/tasks/task_utilities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from ..models.history import HistoryEventType
from ..constants import DATETIME_STRING_FORMAT
from azure.functions._durable_functions import _deserialize_custom_object


Expand Down Expand Up @@ -118,6 +119,29 @@ def find_task_failed(state, scheduled_task):
return tasks[0]


def find_task_timer_created(state, fire_at):
"""Locate the Timer Created Task.

Within the state passed, search for an event that has hasn't been processed,
is a timer created task type,
and has the an event id that is one higher then Scheduled Id of the provided
failed task provided.
"""
if fire_at is None:
return None

tasks = []
for e in state:
if e.event_type == HistoryEventType.TIMER_CREATED and hasattr(e, "FireAt"):
if e.FireAt == fire_at.strftime(DATETIME_STRING_FORMAT):
tasks.append(e)

if len(tasks) == 0:
return None

return tasks[0]


def find_task_retry_timer_created(state, failed_task):
"""Locate the Timer Created Task.

Expand Down
47 changes: 47 additions & 0 deletions azure/durable_functions/tasks/timer_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from ..models.Task import Task


class TimerTask(Task):
"""Represents a pending timer.

All pending timers must be completed or canceled for an orchestration to complete.

Example: Cancel a timer
```
timeout_task = context.df.create_timer(expiration_date)
if not timeout_task.is_completed():
timeout_task.cancel()
```
"""

def __init__(self, action, is_completed, timestamp, id_):
self._action = action
self._is_completed = is_completed
self._timestamp = timestamp
self._id = id_

super().__init__(self._is_completed, False,
self._action, None, self._timestamp, self._id, None)

def is_cancelled(self) -> bool:
"""Check of a timer is cancelled.

Returns
-------
bool
Returns whether a timer has been cancelled or not
"""
return self._action.is_cancelled

def cancel(self):
"""Cancel a timer.

Raises
------
ValueError
Raises an error if the task is already completed and an attempt is made to cancel it
"""
if not self._is_completed:
self._action.is_cancelled = True
else:
raise ValueError("Cannot cancel a completed task.")
5 changes: 5 additions & 0 deletions samples/aml_monitoring/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git*
.vscode
local.settings.json
test
py36
44 changes: 44 additions & 0 deletions samples/aml_monitoring/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
bin
obj
csx
.vs
edge
Publish

*.user
*.suo
*.cscfg
*.Cache
project.lock.json

/packages
/TestResults

/tools/NuGet.exe
/App_Data
/secrets
/data
.secrets
appsettings.json
local.settings.json

node_modules
dist

# Local python packages
.python_packages/

# Python Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
py36
5 changes: 5 additions & 0 deletions samples/aml_monitoring/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions"
]
}
45 changes: 45 additions & 0 deletions samples/aml_monitoring/aml_durable_orchestrator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import logging,json
import azure.durable_functions as df
from datetime import datetime,timedelta

def orchestrator_fn(context: df.DurableOrchestrationContext):
pipeline_endpoint = ""
experiment_name = ""

# Step 1: Kickoff the AML pipeline
input_args= {}
input_args["pipeline_endpoint"] = pipeline_endpoint
input_args["experiment_name"] = experiment_name
input_args["params"] = None
run_id = yield context.call_activity("aml_pipeline",input_args)
polling_interval = 60
expiry_time = context.current_utc_datetime + timedelta(minutes=30)

# Consider continueAsNew - use this in the samples
# while loop explodes the history table on high scale
while context.current_utc_datetime < expiry_time:

# Step 2: Poll the status of the pipeline
poll_args = {}
poll_args["run_id"] = run_id
poll_args["experiment_name"] = experiment_name
job_status = yield context.call_activity("aml_poll_status",poll_args)

# Use native Dictionary fix the generic binding conversion in worker. Can it return a Dict?
activity_status = json.loads(job_status)
if activity_status["status_code"] == 202:
next_check = context.current_utc_datetime + timedelta(minutes=1)

# Set intermediate status for anyone who wants to poll this durable function
context.set_custom_status(activity_status)

yield context.create_timer(next_check)

elif activity_status["status_code"] == 500:
job_completed = True
raise Exception("AML Job Failed/Cancelled...")
else:
job_completed = True
return activity_status

main = df.Orchestrator.create(orchestrator_fn)
11 changes: 11 additions & 0 deletions samples/aml_monitoring/aml_durable_orchestrator/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
],
"disabled": false
}
33 changes: 33 additions & 0 deletions samples/aml_monitoring/aml_pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging,json
import os
import time
from typing import Dict
import requests
import azure.functions as func
from azureml.core.authentication import ServicePrincipalAuthentication

from ..shared.auth_helper import get_access_token


def trigger_aml_endpoint(pipeline_endpoint, experiment_name, parameter_body, retries=3):
aad_token = get_access_token()
response = requests.post(
pipeline_endpoint,
headers=aad_token,
json={"ExperimentName": experiment_name,
"ParameterAssignments": parameter_body})

if response.status_code == 200:
success = True

return json.loads(response.content)

# explicitly typing input_args causes exception
def main(name):
input_args = json.loads(name)
try:
response = trigger_aml_endpoint(input_args["pipeline_endpoint"], input_args["experiment_name"], input_args["params"])
except Exception as exception:
logging.error("Got exception: ", exc_info=True)
return exception
return response["Id"]
Loading