temporalio / temporalio/samples-python

[Feature Request] Guide against single-file structure

Open
#49 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
367
Forks
121
Avg merge
3d 20h
Merged PRs (30d)
11

Description

Is your feature request related to a problem? Please describe.

Given this single-file pattern of running a Workflow inside a Worker:

https://github.com/temporalio/samples-python/blob/7b3944926c3743bc0dcb3b781d8cc64e0330bac4/hello/hello_activity.py#L47-L64

there is potential (and one past instance I know of) for people learning based off of samples to think that in order to run a Workflow, you need to run it inside an async with Worker. When they try to develop an application based on that paradigm, they run into a number of issues.

Describe the solution you'd like

Make it clear that when developing, we recommend:

  • running a worker separately from workflows
  • defaulting to a single worker for all workflows, not one worker per workflow

We could make it clear by structuring all samples that way. OTOH I like the brevity of the single file samples. Another possibility is changing the comment. The drawbacks to that are:

  • some people don't read comments
  • the comment might not be clear, unless you point to a multi-file sample, what exactly we recommend doing

Comment is currently:

# While the worker is running, use the client to run the workflow and
# print out its result. Note, in many production setups, the client
# would be in a completely separate process from the worker.

Perhaps could be:

# Use the client to run the workflow and print out its result. 
# NOTE: when developing, we recommend starting out running a 
# single worker that has all your workflow and activities and
# running client code in a separate process. See, for example,
# how the encryption sample has a separate files to run:
# worker.py runs the worker and starter.py uses the client.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with hello/hello_activity.py lines 47-64 and compare its single-file Worker and workflow setup with the encryption sample's worker.py and starter.py. Decide whether the guidance belongs in sample structure or comments, then update the relevant samples so separate worker and client processes, with one worker serving workflows, are clear and consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.