Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubs #38

Merged
merged 5 commits into from
Nov 18, 2024
Merged

Add stubs #38

merged 5 commits into from
Nov 18, 2024

Conversation

flying-sheep
Copy link
Collaborator

@flying-sheep flying-sheep commented Nov 15, 2024

TODO:

  • figure out how to automatically generate the stubs when building

Eventually we should also get Jij-Inc/pyo3-stub-gen#102 merged and released, but that’s not important, as we will publish to PyPI and not to crates.io

Base automatically changed from ld/codec_pipeline to main November 15, 2024 18:45
@@ -5,8 +5,8 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "zarrs"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder why that worked. In #37, you made it so there are two Rust libraries called zarrs, which should be impossible.

Copy link
Owner

Choose a reason for hiding this comment

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

That's a good point.

@flying-sheep
Copy link
Collaborator Author

flying-sheep commented Nov 18, 2024

The generated file looks like this:

# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401

import numpy
import numpy.typing
import typing

class CodecPipelineImpl:
    def __new__(cls,metadata,validate_checksums = ...,store_empty_chunks = ...,concurrent_target = ...): ...
    def retrieve_chunks_and_apply_index(self, chunk_descriptions:typing.Sequence[tuple[tuple[str, typing.Sequence[int], str, typing.Sequence[int]], typing.Sequence[slice], typing.Sequence[slice]]], value:numpy.NDArray[typing.Any], chunk_concurrent_limit:int) -> None:
        ...

    def retrieve_chunks(self, chunk_descriptions:typing.Sequence[tuple[str, typing.Sequence[int], str, typing.Sequence[int]]], chunk_concurrent_limit:int) -> list[numpy.typing.NDArray[numpy.uint8]]:
        ...

    def store_chunks_with_indices(self, chunk_descriptions:typing.Sequence[tuple[tuple[str, typing.Sequence[int], str, typing.Sequence[int]], typing.Sequence[slice], typing.Sequence[slice]]], value:numpy.NDArray[typing.Any], chunk_concurrent_limit:int) -> None:
        ...

The type inference for __new__ doesn‘t work because we use #[pyo3(signature=...)]: Jij-Inc/pyo3-stub-gen#82

Copy link
Owner

@ilan-gold ilan-gold left a comment

Choose a reason for hiding this comment

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

Could you add to docs how to use this? In contributing.md?

@flying-sheep flying-sheep merged commit 3aea84d into main Nov 18, 2024
1 check passed
@flying-sheep flying-sheep deleted the pa/pyi branch November 18, 2024 19:57
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