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 Array API inspection utilities #689

Merged
merged 36 commits into from
Feb 14, 2024
Merged

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Sep 20, 2023

This PR

@kgryte kgryte added API extension Adds new functions or objects to the API. topic: Device Handling Device handling. labels Sep 20, 2023
@kgryte kgryte added this to the v2023 milestone Sep 20, 2023
@rgommers
Copy link
Member

This looks pretty good to me overall, thanks @kgryte.

src/array_api_stubs/_draft/_types.py Outdated Show resolved Hide resolved
src/array_api_stubs/_draft/_types.py Outdated Show resolved Hide resolved
@kgryte
Copy link
Contributor Author

kgryte commented Jan 11, 2024

I've updated this PR to use a protocol instead of a data class. I believe this PR should be ready for final review.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

The way this PR is written and without looking at the linked discussions, it's not quite clear to me whether __array_namespace_info__ is an array method or a function in the namespace returned by array.__array_namespace__.

In addition, it could be useful to clarify in the __array_namespace_info__ docs that the returned object from that function/method may be either a namespace or a class; as long as the user can do this:

info = __array_namespace_info__()
info.capabilities()
info.devices()
info.dtypes()
info.default_dtypes()

@rgommers
Copy link
Member

The rendered docs look fine, maybe some explanation under Inspection APIs and right above the table of function/method names will help?

image

@rgommers
Copy link
Member

IIRC there were a few more things discussed for inclusion in the inspection API:

@kgryte
Copy link
Contributor Author

kgryte commented Jan 11, 2024

IIRC there were a few more things discussed for inclusion in the inspection API

I was planning on submitting follow-up PR(s) to avoid potential bikesheds and avoid piggybacking on this PR, but I can include some of the aforementioned additional capabilities in this PR. I don't have a strong opinion, except wanting to get this in sooner rather than later.

@kgryte
Copy link
Contributor Author

kgryte commented Jan 25, 2024

@rgommers The updated inspection.rst file now renders as

Screenshot 2024-01-25 at 1 55 06 AM

@kgryte
Copy link
Contributor Author

kgryte commented Jan 25, 2024

@rgommers @leofang I believe I have addressed your most recent review comments, and this PR should be ready for another round of review.

Copy link
Contributor

@leofang leofang left a comment

Choose a reason for hiding this comment

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

LGTM from my perspective. I'm keen to see this PR merged so that we can start addressing follow-up works (ex: #689 (comment)).

Ping @oleksandr-pavlyk for review, due to its relevance 🙂

src/array_api_stubs/_draft/info.py Show resolved Hide resolved
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

LGTM too now, modulo the one typo.

spec/draft/API_specification/inspection.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@leofang leofang left a comment

Choose a reason for hiding this comment

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

Two nits on formatting, but content-wise we're good to go!

src/array_api_stubs/_draft/info.py Outdated Show resolved Hide resolved
src/array_api_stubs/_draft/info.py Outdated Show resolved Hide resolved
@kgryte
Copy link
Contributor Author

kgryte commented Feb 14, 2024

Thanks, @leofang! Made the updates.

@rgommers I think we are good to go here.

@leofang leofang merged commit cc11aa3 into data-apis:main Feb 14, 2024
1 of 3 checks passed
@leofang
Copy link
Contributor

leofang commented Feb 15, 2024

Thanks to Athan for driving this and all for help!

@kgryte kgryte deleted the inspection-namespace branch February 21, 2024 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API. topic: Device Handling Device handling.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: add a unified inspection API namespace ENH: Should we allow querying certain implementation details
7 participants