Skip to content

Conversation

@yeldarby
Copy link
Contributor

@yeldarby yeldarby commented Sep 17, 2025

Description

Adds statefulness to custom Python code blocks in Workflows, allowing blocks to maintain state across executions.

  • Local mode: Shared globals dict accessible by all custom blocks in the workflow
  • Modal mode: Per-block namespaces persist within container lifetime, with shared globals dict across all blocks

Note: the globals dict is left undocumented for now while we decide whether it is necessary & desired.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

  • Custom blocks can access and modify a persistent globals dictionary
  • State persists across multiple executions of the same block
  • Modal containers maintain separate namespaces for each unique code block

Any specific deployment considerations

Requires deployment of the Modal app.

Docs

  • Docs updated? What were the changes: Added info on this behavior to the custom python blocks docs.

Copy link
Collaborator

@hansent hansent left a comment

Choose a reason for hiding this comment

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

LGTM

@yeldarby yeldarby merged commit 9139a01 into main Sep 17, 2025
75 of 76 checks passed
@yeldarby yeldarby deleted the modal-state branch September 17, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants