Skip to content

feat(sdks/python): add cron_input to workflow and task declarations - #4413

Merged
mrkaye97 merged 5 commits into
hatchet-dev:mainfrom
adem-loghmari:feat/sdk-python-cron-input
Jul 16, 2026
Merged

mrkaye97 merged 5 commits into
hatchet-dev:mainfrom
adem-loghmari:feat/sdk-python-cron-input

Conversation

@adem-loghmari

@adem-loghmari adem-loghmari commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a cron_input option to the Python SDK's workflow(), task(), and durable_task() declarations. This lets you declare an input that is passed to runs triggered by a workflow's on_crons schedules.

The gRPC contract already carries this field — CreateWorkflowVersionRequest.cron_input exists in the generated stubs — but the high-level SDK gave no way to set it. BaseWorkflow.to_proto previously hardcoded cron_input=None with a ## TODO: Fix this comment. This PR wires the value through the declaration APIs and serializes it onto the proto using the workflow's input_validator.

Closes #3820

Example

class CronInput(BaseModel):
    name: str
    count: int

workflow = hatchet.workflow(
    name="cron-input-workflow",
    input_validator=CronInput,
    on_crons=["* * * * *"],
    cron_input=CronInput(name="alice", count=3),
)

See sdks/python/examples/cron/cron_input.py.

Changes

  • Add cron_input param to all workflow / task / durable_task overloads on Hatchet (with docstrings).
  • Add cron_input field to WorkflowConfig.
  • Serialize cron_input onto CreateWorkflowVersionRequest in BaseWorkflow.to_proto (replaces the hardcoded None).
  • Add an example (examples/cron/cron_input.py) and unit tests (tests/test_cron_input.py) asserting the value is serialized when provided and left unset otherwise.
  • Register the example on the shared e2e-test-worker and add an integration test (examples/cron/test_cron_input.py) that runs the workflow end-to-end.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@adem-loghmari is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the sdk-py Related to the Python sdk label Jul 14, 2026
@gregfurman

Copy link
Copy Markdown
Contributor

Thanks for opening! Should solve #3820

@gregfurman gregfurman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Think we should add a workflow test for this, just to be safe 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: This should be snake-case i.e. cron_input.py

Comment thread sdks/python/examples/cron/cron_input.py Outdated
# 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a test here for the workflow? i.e

@pytest.mark.parametrize("task", [simple, simple_durable])
@pytest.mark.asyncio(loop_scope="session")
async def test_simple_workflow_running_options(
task: Standalone[EmptyModel, dict[str, str]],
) -> None:

@adem-loghmari

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Addressed both:

  • Renamed the example to cron_input.py (snake_case)
  • Added examples/cron/test_cron_input.py, which registers cron_input_workflow on the shared e2e-test-worker and actually runs it end-to-end (sync + async), asserting on the task output and that cron_input is set on the proto — on top of the existing unit tests in tests/test_cron_input.py

@gregfurman gregfurman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you include an entry for this in sdks/python/CHANGELOG.md? Once done, think it looks good to ship

@adem-loghmari

Copy link
Copy Markdown
Contributor Author

Added a CHANGELOG entry (## [1.33.19]) and bumped the SDK version in pyproject.toml to match. Thanks!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 14, 2026

@gregfurman gregfurman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

Comment thread sdks/python/CHANGELOG.md Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this not be a minor release? Adding support for cron_input seems like a behaviour change cc @mrkaye97

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: also the date is wrong -- this'll require a regen of the docs as well 😅

Suggested change
## [1.33.19] - 2026-07-14
## [1.33.19] - 2026-07-15

@adem-loghmari

Copy link
Copy Markdown
Contributor Author

Fixed the date (2026-07-15) and regenerated the docs changelog to match.

On the version bump: happy to make this a minor (1.34.0) if that's the call — just flagging that there's precedent for shipping additive ### Added changes as a patch bump (e.g. 1.33.15 added oldest_excluding_retries to the task stats response as a patch), so I matched that convention here. No strong opinion either way — let me know what you and @mrkaye97 land on and I'll update.

@mrkaye97 mrkaye97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

Comment thread sdks/python/examples/cron/cron_input.py Resolved
Comment thread sdks/python/examples/cron/cron_input.py Resolved
adem-loghmari and others added 4 commits July 16, 2026 11:45
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.
@adem-loghmari
adem-loghmari force-pushed the feat/sdk-python-cron-input branch from d9680be to 6b9c3a8 Compare July 16, 2026 10:47
@adem-loghmari

Copy link
Copy Markdown
Contributor Author

Rebased onto main to pick up #4393 (task slot cost), which bumped the SDK to 1.34.0 and conflicted with my version. Renumbered this as 1.34.1 (patch, per @mrkaye97's call above) — changelog and docs mirror updated accordingly.

@mrkaye97

Copy link
Copy Markdown
Contributor

Thanks for the contribution @adem-loghmari !

@mrkaye97
mrkaye97 merged commit 663c408 into hatchet-dev:main Jul 16, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation sdk-py Related to the Python sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add support for cron_input in register_workflow

3 participants