Comments (5)
Hi, @Goldziher Do you have durable functions app that can help me check the logs or any samples that can help me reproduce at my local end?
from azure-functions-durable-python.
Hi, @Goldziher Do you have durable functions app that can help me check the logs or any samples that can help me reproduce at my local end?
I'm afraid only closed source
from azure-functions-durable-python.
No worries. Can you help me specify the scenario using with context.signal_entity
? Like calling this in a sub-orchestrator and thus make it never finish.
from azure-functions-durable-python.
No worries. Can you help me specify the scenario using with
context.signal_entity
? Like calling this in a sub-orchestrator and thus make it never finish.
Certainly. I'll post some snippets later
from azure-functions-durable-python.
Ok, here is some code that works as is, but if you change call_activity
to signal_activity
it blocks indefinitely:
def file_download_orchestrator(
context: DurableOrchestrationContext,
) -> Generator[TaskBase, None, NotificationAttachment | None]:
"""This is a sub-orchestrator function that downloads a file from Google Drive, saves it to blob storage and updates
the state of the durable entity.
Args:
context: The durable orchestration context.
Returns:
A generator.
"""
directory_path, file_datum = cast(tuple[str, FileData], context.get_input())
# 1. download file
file_blob_or_error = cast(
FileBlob | NotificationAttachment,
(yield context.call_activity(FILE_DOWNLOAD_ACTIVITY, (directory_path, file_datum))),
)
if not all(k in file_blob_or_error for k in FileBlob.__annotations__):
logger.warning("File %s download failed. Skipping file persistence and state update.", file_datum["id"])
return cast(NotificationAttachment, file_blob_or_error)
file_blob = cast(FileBlob, file_blob_or_error)
# 2. save file to blob storage
yield context.call_activity(SAVE_BLOB_DATA_ACTIVITY, file_blob)
# 3. update state
# note: we are using context.call_entity rather than context.signal_entity, because signal_entity causes blocking
yield context.signal_entity(
EntityId(STORE_HANDLER_ENTITY, file_blob["drive_id"]),
EntityStateOperation.SET.value,
(file_blob["file_id"], file_blob["modified_time"]),
)
logger.info("File %s was downloaded and persisted successfully", file_blob["file_id"])
return None
And this is the entity handler:
from enum import StrEnum
from typing import cast
from azure.durable_functions import DurableEntityContext
class EntityStateOperation(StrEnum):
"""An enum for the durable entity state operations."""
GET = "get"
DEL = "del"
SET = "set"
def store_handler(context: DurableEntityContext) -> None:
"""Handler for the durable entity. A durable entity is created for each drive ID.
Args:
context: The durable entity context, injected by the runtime.
Returns:
None
"""
state = context.get_state(dict)
match context.operation_name:
case EntityStateOperation.GET.value:
context.set_result(state)
case EntityStateOperation.DEL.value:
state.pop(cast(str, context.get_input()), None)
context.set_state(state)
case EntityStateOperation.SET.value:
file_id, modified_date = cast(tuple[str, int], context.get_input())
context.set_state({**state, file_id: modified_date})
case _:
# this should never happen
raise ValueError(f"Invalid operation: {context.operation_name}")
from azure-functions-durable-python.
Related Issues (20)
- Known regression: Activity input fails to deserialize when the input is an array
- Add call_activity_with_retry to DurableOrchestrationContext class
- Object of type generator is not JSON serializable error in orchestrator function
- Please support the underscore character as a binding name
- [SURVEY] Share your experience to influence what Durable works on next!
- Ability to access 'classic' Azure Function Context, so that I can trace against the same operation_Id
- Dependency injection in Python Azure Functions HOT 1
- Errors in Activity Functions cannot be handled using try...except HOT 2
- Parameter names using snake_case cause failure HOT 6
- Typing function parameters for activities etc. causes failure HOT 2
- get_status(instance_id) - runtime_status is not up to date HOT 4
- Error "ImportError: cannot import name 'packaging' from 'pkg_resources'" HOT 2
- To fix MEND issue by updating the requirements.txt HOT 1
- Known issue with hosting Durable Functions app on preview Flex Consumption plan
- Single event notification is being yielded every time with `wait_for_external_event` HOT 2
- yield on `task_all` can return None HOT 2
- Eternal orchestration doesn't get cleaned up HOT 2
- Enable Unit Testing of Durable Functions
- Functions silently failing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-durable-python.