dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Ability to update schedule memo via Python SDK #189

Open dhiaayachi opened 2 weeks ago

dhiaayachi commented 2 weeks ago

Is your feature request related to a problem? Please describe. Client,create_schedule allows a memo to be created on a schedule. Most schedule fields can be updated by calling ScheduleHandle.update, but it does not seem to allow the update of a memo with ScheduleUpdateInput/ScheduleUpdate. Memos may contain reference information and/or metadata for the schedule that could change depending on other changes to the schedule configuration as a result of the ScheduleHandle.update call. In order to keep the memo consistent with the updated configuration, the ability to update the memo is necessary as well.

Describe the solution you'd like Allow an updated memo object to be passed in the ScheduleHandle.update call in the ScheduleUpdate object.

Describe alternatives you've considered There do not seem to be other ways to track metadata associated with a schedule apart from the memo field, so this seems to be the only solution.

Additional context N/A

dhiaayachi commented 6 days ago

Feature Request: Update Memo for Schedules

This issue proposes adding the ability to update the memo associated with a schedule using the ScheduleHandle.update method.

Problem:

Currently, the Client.create_schedule method allows setting a memo when creating a schedule. However, the ScheduleHandle.update method does not offer a way to modify this memo. This limitation prevents users from keeping the memo consistent with the schedule configuration when updating it using ScheduleHandle.update.

Proposed Solution:

Introduce a new field for the memo in the ScheduleUpdate object. This will allow users to pass an updated memo object to the ScheduleHandle.update method. This change will enable users to update both the schedule configuration and the memo simultaneously, maintaining consistency between them.

Alternatives Considered:

No viable alternatives have been identified. The memo is the only mechanism available for storing metadata directly related to a schedule.

Example:

from temporalio.client import Client, ScheduleUpdate, ScheduleUpdateInput

async def main():
    client = await Client.connect("localhost:7233")
    handle = client.get_schedule_handle("schedule-id")

    # Get the current schedule description
    desc = await handle.describe()

    # Modify the memo
    desc.schedule.state.note = "Updated memo"

    # Create an update object with the modified memo
    update = ScheduleUpdate(schedule=desc.schedule)

    # Update the schedule
    await handle.update(ScheduleUpdateInput(description=desc, update=update))

if __name__ == "__main__":
    asyncio.run(main())

Benefits:

This feature enhancement would significantly improve the flexibility and usability of the Python SDK for schedules, allowing for more effective management of schedule-related metadata.

dhiaayachi commented 6 days ago

Thank you for your feature request! We appreciate you bringing this to our attention.

Currently, the ScheduleHandle.update method does not support updating the memo field. While we understand the need to keep the memo consistent with the updated schedule configuration, there is no direct way to achieve this with the current implementation.

As a workaround, you could consider storing the memo information in a separate external data store that is accessible both during the schedule creation and update processes. This allows you to manage the memo separately while maintaining consistency with the schedule.

We are actively working on improving the functionality of the ScheduleHandle.update method and will consider your suggestion for future updates.

dhiaayachi commented 6 days ago

Thank you for your feature request! It is a great suggestion for improving the ScheduleHandle.update method to include the ability to update memos.

Currently, Temporal doesn't offer a direct way to update memos alongside other schedule properties using ScheduleUpdateInput. One way to work around this limitation is to use the ScheduleHandle.describe method to retrieve the current memo and then combine it with the desired updated schedule properties in a custom ScheduleUpdate object before passing it to ScheduleHandle.update.

Let us know if you have any other suggestions for improving the schedule functionality.

dhiaayachi commented 6 days ago

Thank you for your feature request!

We understand the need to be able to update the memo field when updating a schedule. Currently, it's not possible to directly update the memo field using ScheduleHandle.update.

Here is a suggested workaround for now:

  1. Retrieve the current memo: Use ScheduleHandle.describe() to get the current ScheduleDescription object.
  2. Update the memo: Modify the memo field in the ScheduleDescription object.
  3. Create a new Schedule: Create a new Schedule object with the updated memo and other desired changes to the schedule configuration.
  4. Update the Schedule: Use ScheduleHandle.update() with the newly created schedule object.

We appreciate your suggestion and will consider adding this feature in a future release.

dhiaayachi commented 6 days ago

Thank you for your feature request!

We understand the need for updating the memo associated with a schedule to keep it consistent with the updated configuration.

Currently, the ScheduleHandle.update method doesn't support updating the memo field. We'll consider adding this feature in future releases.

For now, you can work around this limitation by using the ScheduleHandle.describe method to retrieve the current memo and update it manually before creating a new schedule with the updated memo.

We appreciate your feedback and will keep you updated on any changes to the ScheduleHandle.update method.

dhiaayachi commented 5 days ago

Thank you for your feature request!

You're right, currently the ScheduleHandle.update() method doesn't allow updating the memo field.

As a workaround, you could consider storing the metadata related to the schedule in a separate workflow state variable. You can then update this variable through ScheduleHandle.update() and use it to keep your memo consistent with the updated configuration.

We appreciate your suggestion and will consider it for future releases.