Skip to content

Add Driver helpers for variable lookup#1605

Open
officialasishkumar wants to merge 1 commit into
apache:mainfrom
officialasishkumar:feat/driver-variable-lookup
Open

Add Driver helpers for variable lookup#1605
officialasishkumar wants to merge 1 commit into
apache:mainfrom
officialasishkumar:feat/driver-variable-lookup

Conversation

@officialasishkumar
Copy link
Copy Markdown

Adds public Driver helpers for looking up variables by name and retrieving the public HamiltonGraph representation without iterating over list_available_variables().

Changes

  • Added a cached Driver.variables mapping keyed by variable name.
  • Added Driver.get_variable(name) for direct variable lookup.
  • Added Driver.get_graph() to return the external HamiltonGraph API object.
  • Added regression coverage for variable lookup and graph access.

How I tested this

  • uv run --with pytest pytest tests/test_hamilton_driver.py::test_driver_variable_lookup tests/test_hamilton_driver.py::test_driver_get_graph_returns_hamilton_graph
  • uv run ruff format --check hamilton/driver.py tests/test_hamilton_driver.py
  • uv run ruff check hamilton/driver.py tests/test_hamilton_driver.py

Notes

Fixes #1138.

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

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.

Get nodes/variables from driver by name

1 participant