Skip to content

[Core] Introduce type for resource dictionaries #48710

Open
@pcmoritz

Description

Description

I'm not sure if there is currently a way to do this, ideally resource dictionaries would be typed like

class Resources(TypedDict, extra_items=float):
    CPU: float
    GPU: float
    memory: float
    object_store_memory: float

I don't think this is currently possible (please let us know if you know it is) -- but will be possible with this PEP: https://peps.python.org/pep-0728/

Use case

This will give people autocomplete in their IDE and make it less likely to mistype the keys in the dict (and still be fully compatible with the current API) :)

Metadata

Assignees

No one assigned

    Labels

    P2Important issue, but not time-criticalcoreIssues that should be addressed in Ray CoreenhancementRequest for new feature and/or capability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions