Skip to content

Conversation

dandavison
Copy link
Contributor

No description provided.

@dandavison dandavison force-pushed the standalone-activity branch from a1d3efe to 23df3f8 Compare October 1, 2025 18:13
self._id_or_token = ActivityIDReference(activity_id=id, run_id=run_id)
self.run_id = run_id

# TODO: do we support something like `follow_runs: bool`?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need there's no concept of an execution chain for activities.

handle = await self.start_activity(*args, **kwargs)
return await handle.result()

async def list_activities(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be interesting to see how we can model this to return both workflow and standalone "client" activities.


# - TODO: Overloads for no-param, single-param, multi-param
# - TODO: Support sync and async activity functions
async def start_activity(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need execute_activity but we can leave that for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually execute_activity is already present below.



@dataclass(frozen=True)
class AsyncActivityIDReference:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider deprecating and renaming to WorkflowActivityIDReference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or merging the two reference types where workflow_id becomes an optional field.

"""Handle representing an activity started by a workflow."""

def __init__(
self, client: Client, id_or_token: Union[AsyncActivityIDReference, bytes]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work with any activity IMHO.

self._id_or_token = id_or_token


WorkflowActivityHandle = AsyncActivityHandle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also need pause, reset, etc...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still want AsyncActivityHandle because you can obtain one with a token and can't do anything else with the token but issue completion requests.

"""
raise NotImplementedError

# TODO:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also TODO: all of the async completion methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean heartbeat, complete, fail, and report_cancellation, right? Those are all inherited from _BaseActivityHandle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence whether we want to expose these methods on the activity handle as opposed to having the async completion handle as a separate concept. The use cases are different for the two.

)


# TODO: This name is suboptimal now. We could deprecate it and introduce WorkflowActivityHandle as a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's do that. Which means that you would have to accept a WorkflowActivityHandle where you accept AsyncActivityHandle.


class AsyncActivityHandle:
"""Handle representing an external activity for completion and heartbeat."""
class _BaseActivityHandle:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider just duplicating instead of inheriting but don't have a strong opinion.

@dandavison dandavison force-pushed the standalone-activity branch from 2f29d96 to 519a359 Compare October 2, 2025 15:30
@dandavison dandavison force-pushed the standalone-activity branch from 4760964 to 0904987 Compare October 2, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants