Skip to content

types: add Globals / MutableGlobals aliases#9632

Merged
dmadisetti merged 1 commit into
dm/runner-cleanupfrom
dm/typing
May 21, 2026
Merged

types: add Globals / MutableGlobals aliases#9632
dmadisetti merged 1 commit into
dm/runner-cleanupfrom
dm/typing

Conversation

@dmadisetti
Copy link
Copy Markdown
Collaborator

📝 Summary

Replaces dict[str, Any] in the executor pipeline with MutableGlobals (alias), and Globals (Mapping[str, Any]).

Layering on top to prevent rebase churn

@dmadisetti dmadisetti added the internal A refactor or improvement that is not user facing label May 20, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 21, 2026 12:03am

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

Architecture diagram
sequenceDiagram
    participant Runner as Runner (by_kwargs)
    participant Evaluator as Evaluator
    participant Executor as DefaultExecutor
    participant Lifecycle as StrictLifecycle
    participant Globals as Globals Dict

    Note over Runner,Globals: Core Execution Pipeline
    
    Runner->>Runner: _new_evaluator()
    Runner->>Globals: NEW: Create MutableGlobals (dict[str, Any])
    
    loop For each ancestor cell in topological order
        Runner->>Evaluator: evaluate(cell, glbls: MutableGlobals)
        Evaluator->>Lifecycle: setup(cell, glbls: MutableGlobals)
        Lifecycle->>Lifecycle: Backup transitive refs
        Lifecycle-->>Evaluator: Skip | None
        
        alt Skip returned
            Evaluator->>Evaluator: Skip execution
        else Execute cell
            Evaluator->>Executor: execute_cell(cell, glbls: MutableGlobals)
            Executor->>Globals: exec(cell.body) with glbls
            Globals-->>Executor: Updated glbls
            Executor-->>Evaluator: Return value
        end
        
        Evaluator->>Lifecycle: teardown(cell, glbls: MutableGlobals, run_result)
        Lifecycle->>Globals: Restore backed-up refs
        Lifecycle-->>Evaluator: None
        Evaluator-->>Runner: RunResult
        
        Runner->>Runner: CHANGED: _returns(cell_impl, glbls: Globals)
        Note over Runner: Read-only view for collecting cell defs
    end
    
    Runner->>Runner: _substitute_refs(cell_impl, glbls: MutableGlobals, kwargs)
    Note over Runner: Mutate glbls with kwargs
    
    Runner-->>Runner: Return (result, glbls: MutableGlobals)
Loading

Re-trigger cubic

Base automatically changed from dm/traceback-cleanup to dm/runner-cleanup May 20, 2026 21:28
Replaces ad-hoc ``dict[str, Any]`` in the executor pipeline with
``MutableGlobals``, and the lone read-only consumer (``_returns`` in
``by_kwargs``) with ``Globals`` (``Mapping[str, Any]``). Documents
mutation intent without changing runtime behavior.
@dmadisetti dmadisetti force-pushed the dm/runner-cleanup branch from 3306d51 to ed7a283 Compare May 21, 2026 00:02
@dmadisetti dmadisetti merged commit 7debe2e into dm/runner-cleanup May 21, 2026
37 of 61 checks passed
@dmadisetti dmadisetti deleted the dm/typing branch May 21, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants