Repository navigation
feat(sdks/python): add cron_input to workflow and task declarations - #4413
Conversation
|
@adem-loghmari is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for opening! Should solve #3820 |
gregfurman
left a comment
There was a problem hiding this comment.
Looks great! Think we should add a workflow test for this, just to be safe 🙂
There was a problem hiding this comment.
nit: This should be snake-case i.e. cron_input.py
| # You can pass a `cron_input` to a workflow so that runs triggered by its | ||
| # `on_crons` schedules receive a predefined input. | ||
|
|
||
| cron_input_workflow = hatchet.workflow( |
There was a problem hiding this comment.
Can we add a test here for the workflow? i.e
hatchet/sdks/python/examples/simple/test_simple_workflow.py
Lines 8 to 12 in 785bb67
|
Thanks for the review! Addressed both:
|
gregfurman
left a comment
There was a problem hiding this comment.
Can you include an entry for this in sdks/python/CHANGELOG.md? Once done, think it looks good to ship
|
Added a CHANGELOG entry ( |
gregfurman
left a comment
There was a problem hiding this comment.
LGTM! Just need to fix the date and get some clarification on whether this should instead be a minor update before approving.
Otherwise, thanks for the neat PR!
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [1.33.19] - 2026-07-14 |
There was a problem hiding this comment.
Should this not be a minor release? Adding support for cron_input seems like a behaviour change cc @mrkaye97
There was a problem hiding this comment.
nit: also the date is wrong -- this'll require a regen of the docs as well 😅
| ## [1.33.19] - 2026-07-14 | |
| ## [1.33.19] - 2026-07-15 |
|
Fixed the date (2026-07-15) and regenerated the docs changelog to match. On the version bump: happy to make this a minor ( |
mrkaye97
left a comment
There was a problem hiding this comment.
patch version is fine here IMO - I'm not following the "rules" super well, but I've been using minor versions for more significant new features, vs. this feels like a smaller fix 🤷
in any case, thanks for the contribution!
Allow declaring a cron_input on workflow(), task(), and durable_task() so runs triggered by a workflow's on_crons schedules receive a predefined input. The value is serialized onto the cron_input field of CreateWorkflowVersionRequest via the existing _serialize_input path, replacing the hardcoded cron_input=None TODO in BaseWorkflow.to_proto. Adds a unit test and an example. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Rename examples/cron/cron-input.py to cron_input.py (snake_case, per review nit) - Register cron_input_workflow on the shared e2e-test-worker and add an integration test that actually runs the workflow end-to-end and asserts on its output, in addition to the existing proto-serialization unit tests
Bump the Python SDK to 1.33.19 and add a CHANGELOG entry for the new `cron_input` option, per review.
Regenerate frontend/docs/pages/reference/changelog/python.mdx from CHANGELOG.md via hack/docs/sync-changelog.sh, as enforced by the sync-python-changelog pre-commit hook.
d9680be to
6b9c3a8
Compare
|
Thanks for the contribution @adem-loghmari ! |
Description
Adds a
cron_inputoption to the Python SDK'sworkflow(),task(), anddurable_task()declarations. This lets you declare an input that is passed to runs triggered by a workflow'son_cronsschedules.The gRPC contract already carries this field —
CreateWorkflowVersionRequest.cron_inputexists in the generated stubs — but the high-level SDK gave no way to set it.BaseWorkflow.to_protopreviously hardcodedcron_input=Nonewith a## TODO: Fix thiscomment. This PR wires the value through the declaration APIs and serializes it onto the proto using the workflow'sinput_validator.Closes #3820
Example
See
sdks/python/examples/cron/cron_input.py.Changes
cron_inputparam to allworkflow/task/durable_taskoverloads onHatchet(with docstrings).cron_inputfield toWorkflowConfig.cron_inputontoCreateWorkflowVersionRequestinBaseWorkflow.to_proto(replaces the hardcodedNone).examples/cron/cron_input.py) and unit tests (tests/test_cron_input.py) asserting the value is serialized when provided and left unset otherwise.examples/cron/test_cron_input.py) that runs the workflow end-to-end.