Skip to content
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

Mark workflows API functions as deprecated #749

Merged
merged 12 commits into from
Jan 2, 2025
21 changes: 14 additions & 7 deletions dapr/aio/clients/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,7 @@ async def start_workflow(
send_raw_bytes: bool = False,
) -> StartWorkflowResponse:
"""Starts a workflow.
Deprecated: use dapr-ext-workflow instead
elena-kolevska marked this conversation as resolved.
Show resolved Hide resolved

Args:
workflow_component (str): the name of the workflow component
Expand All @@ -1430,7 +1431,7 @@ async def start_workflow(
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1470,6 +1471,7 @@ async def start_workflow(

async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflowResponse:
"""Gets information on a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1482,7 +1484,7 @@ async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWo
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1511,6 +1513,7 @@ async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWo

async def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Terminates a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance, e.g.
Expand All @@ -1523,7 +1526,7 @@ async def terminate_workflow(self, instance_id: str, workflow_component: str) ->
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1548,6 +1551,7 @@ async def raise_workflow_event(
send_raw_bytes: bool = False,
) -> DaprResponse:
"""Raises an event on a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1568,7 +1572,7 @@ async def raise_workflow_event(
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1611,6 +1615,7 @@ async def raise_workflow_event(

async def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Pause a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1624,7 +1629,7 @@ async def pause_workflow(self, instance_id: str, workflow_component: str) -> Dap
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1643,6 +1648,7 @@ async def pause_workflow(self, instance_id: str, workflow_component: str) -> Dap

async def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Resumes a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1655,7 +1661,7 @@ async def resume_workflow(self, instance_id: str, workflow_component: str) -> Da
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1674,6 +1680,7 @@ async def resume_workflow(self, instance_id: str, workflow_component: str) -> Da

async def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Purges a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1686,7 +1693,7 @@ async def purge_workflow(self, instance_id: str, workflow_component: str) -> Dap
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down
21 changes: 14 additions & 7 deletions dapr/clients/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ def start_workflow(
send_raw_bytes: bool = False,
) -> StartWorkflowResponse:
"""Starts a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
workflow_component (str): the name of the workflow component
Expand All @@ -1434,7 +1435,7 @@ def start_workflow(
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1470,6 +1471,7 @@ def start_workflow(

def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflowResponse:
"""Gets information on a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1482,7 +1484,7 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1511,6 +1513,7 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow

def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Terminates a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance, e.g.
Expand All @@ -1524,7 +1527,7 @@ def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprR
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1549,6 +1552,7 @@ def raise_workflow_event(
send_raw_bytes: bool = False,
) -> DaprResponse:
"""Raises an event on a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1568,7 +1572,7 @@ def raise_workflow_event(
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1613,6 +1617,7 @@ def raise_workflow_event(

def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Pause a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1626,7 +1631,7 @@ def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1645,6 +1650,7 @@ def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo

def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Resumes a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1657,7 +1663,7 @@ def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResp
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand All @@ -1676,6 +1682,7 @@ def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResp

def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
"""Purges a workflow.
Deprecated: use dapr-ext-workflow instead

Args:
instance_id (str): the ID of the workflow instance,
Expand All @@ -1688,7 +1695,7 @@ def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo
"""
# Warnings and input validation
warn(
'The Workflow API is a Beta version and is subject to change.',
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
UserWarning,
stacklevel=2,
)
Expand Down
6 changes: 3 additions & 3 deletions examples/demo_workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

This document describes how to register a workflow and activities inside it and start running it.
It demonstrates the following APIs:
- **start_workflow**: Start an instance of a workflow
- **get_workflow**: Get information on a single workflow
- **schedule_new_workflow**: Start an instance of a workflow
- **get_workflow_state**: Get information on a single workflow
elena-kolevska marked this conversation as resolved.
Show resolved Hide resolved
- **terminate_workflow**: Terminate or stop a particular instance of a workflow
- **raise_event**: Raise an event on a workflow
- **raise_workflow_event**: Raise an event on a workflow
elena-kolevska marked this conversation as resolved.
Show resolved Hide resolved
- **pause_workflow**: Pauses or suspends a workflow instance that can later be resumed
- **resume_workflow**: Resumes a paused workflow instance
- **purge_workflow**: Removes all metadata related to a specific workflow instance from the state store
Expand Down
5 changes: 4 additions & 1 deletion examples/demo_workflow/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def act_for_child_wf(ctx: WorkflowActivityContext, inp):


def main():
# DEPRECATION NOTICE!
# The workflow methods in the DaprClient are deprecated, instead use the client provided in dapr-ext-workflow
# You can use the examples in https://github.com/dapr/python-sdk/tree/main/examples/workflow
with DaprClient() as d:
workflow_runtime = WorkflowRuntime()
workflow_runtime.register_workflow(hello_world_wf)
Expand Down Expand Up @@ -209,4 +212,4 @@ def main():


if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion examples/demo_workflow/demo_workflow/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dapr-ext-workflow-dev>=0.0.1rc1.dev
dapr-ext-workflow-dev>=0.0.1rc1.dev
2 changes: 2 additions & 0 deletions ext/dapr-ext-workflow/tests/test_workflow_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ def test_client_functions(self):

actual_resume_result = wfClient.resume_workflow(instance_id=mockInstanceId)
assert actual_resume_result == mock_resume_result

# TODO add purge support
elena-kolevska marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion tests/clients/test_dapr_grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def test_unlock_input_validation(self):
# Tests for workflow
#

def test_workflow(self):
def test_workflow_deprecated(self):
dapr = DaprGrpcClient(f'{self.scheme}localhost:{self.grpc_port}')
# Sane parameters
workflow_name = 'test_workflow'
Expand Down
Loading