How to track and display the progress of my Python workflow with two activities on my UI to display a progress bar?

Hello, I am new to Temporal and I would like to be able to track the progress of my workflow containing 2 activities so that I can display the state and progress of the workflow on my Web UI (so i can display a progress bar for each workflow and sub bar for activities inside the workflow)

I have browsed the forum multiple times about this topic but I never find a clear answer on how to proceed to achieve this.
Should i use the heartbeat ? Should i use a query ?

My backend and workflows are used in Python

Thank you for your help.

We solved this problem by tracking a user-facing workflow status as an entity with a database table describing it. That is, part of our workflow code looks like the following psuedo-code:

def workflow(ctx):
    execute_activity(log_workflow_start, { .. some user-facing metadata .. })

    execute_activity(set_workflow_progress, { step: "Doing Activity 1", complete_pct: 0.0f })
    execute_activity(activity_1, ...)

    execute_activity(set_workflow_progress, { step: "Doing Activity 2", complete_pct: 50.0f })
    execute_activity(activity_2, ...)

    execute_activity(log_workflow_success, { .. metadata .. })

This has worked OK for us so far. In practice we’ve written a little API to make this cleaner, and it records all the steps and sub-steps that have completed, which are projected into a nice little UI.

The reasons we landed on this over something 100% dependent on Temporal were:

  1. Our Temporal retention period is only 30 days, but we can use this to keep user-facing views for longer periods.
  2. Our workflows end up being a lot more complex with internal details that aren’t interesting to our customers.
  3. The Query API for Temporal is fairly fast, but notably slower than just plucking a row out of our local PostgreSQL database we’re already reading from to generate my UI.

Hope that’s helpful. I think there are a lot of valid options here that depend on your use-case and such.

Thank you for your answer, that’s really interesting and help me a lot.
Do you know (maybe you tried it) if it’s possible to track progression inside an activity.
In my case, i have a workflow with 2 activities and each activity can take approximatly 30 minutes. I would try to show progression feedback of each activity in my UI in order to show a smooth progress bar to my users (and not just 0%, 50%, 100%)

What would be the best way to do something like that ?
Thank’s again for you hep.