Skip to content

[core] package kernels-data as a python wrapper.#475

Merged
sayakpaul merged 11 commits intomainfrom
kernels-data-py-wrapper
Apr 17, 2026
Merged

[core] package kernels-data as a python wrapper.#475
sayakpaul merged 11 commits intomainfrom
kernels-data-py-wrapper

Conversation

@sayakpaul
Copy link
Copy Markdown
Member

@sayakpaul sayakpaul commented Apr 17, 2026

Part of #396. The subsequent PR will address validation in the client part of kernels.

Could we configure the access management on PyPI similar to the release workflow of ABI check?


/// A validated kernel name matching `^[a-z][-a-z0-9]*[a-z0-9]$`.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, Eq, Hash, PartialEq)]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

pyo3's #[pyclass(..., hash)] requires the Rust struct to implement std::hash::Hash — pyo3 delegates Python's __hash__ to the derived Rust hash.

Any preferred alternative?

@sayakpaul sayakpaul marked this pull request as ready for review April 17, 2026 06:35
Comment thread kernels-data/bindings/python/src/lib.rs
Comment thread kernels-data/bindings/python/src/lib.rs Outdated
/// Returns `None` if the file does not exist in the given directory.
/// Raises `ValueError` if the file exists but cannot be parsed.
#[staticmethod]
fn load_from_variant(variant_path: PathBuf) -> PyResult<Option<Self>> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd instead do load, which takes the full path to metadata.json and let the caller construct the path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also not 100% sure if PyO3 has this conversion, but it might be worth trying

Suggested change
fn load_from_variant(variant_path: PathBuf) -> PyResult<Option<Self>> {
fn load_from_variant(variant_path: impl AsRef<Path>) -> PyResult<Option<Self>> {

or variant_path: &Path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah not supported. Kept PathBuf, which is what pyo3 officially supports for path
arguments.

Comment thread kernels-data/bindings/python/src/lib.rs Outdated
Comment thread kernels-data/bindings/python/src/lib.rs Outdated
Comment thread kernels-data/bindings/python/src/lib.rs Outdated
Comment thread kernels-data/bindings/python/src/lib.rs Outdated
@sayakpaul
Copy link
Copy Markdown
Member Author

@danieldk thanks for the review. Your comments should have been addressed now. I have also squeezed in a mypy check in the CI for kernels-data.

Copy link
Copy Markdown
Member

@danieldk danieldk left a comment

Choose a reason for hiding this comment

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

Looks great!

@sayakpaul sayakpaul merged commit 2449324 into main Apr 17, 2026
62 checks passed
@sayakpaul sayakpaul deleted the kernels-data-py-wrapper branch April 17, 2026 12: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.

2 participants