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

[doc][api] add a function to check if an api is really public #46261

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

can-anyscale
Copy link
Collaborator

@can-anyscale can-anyscale commented Jun 25, 2024

Add a function to check if an api name is prefixed with _

Also a function to check if an api is really public

Test:

  • CI

@can-anyscale can-anyscale changed the title [doc][api] add a function to check if an api has a private name [doc][api] add a function to check if an api is really public Jun 25, 2024
Check if this API has a private name. Private names are those that start with
underscores.
"""
return self.name.split(".")[-1].startswith("_")
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are many special functions in python that are actually public, but starts with _, like __del__, __iter__, __len__, __init__, __next__, etc, etc..

Copy link
Collaborator

Choose a reason for hiding this comment

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

and I am actually not sure about the annotation story for those in ray's api world..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure about the annotation story for those in ray's api worl

that is fine, and why we need to agree on this api policy across teams (see line 8 which is our agreed definition of private, not public, etc.)

Screenshot 2024-06-25 at 9 24 00 PM

i will be implementing what is in this policy for now, and if the policy change i will update the code accordingly; at least this will allow me to turn on the lint check for data team who has aligned with this policy

Copy link
Collaborator

Choose a reason for hiding this comment

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

what does data team say about these api's? maybe ask them to have a look?

like at least __init__ method of a public api class needs to be public, right? do those also need to be explicitly annotated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

currenly folks do not annotate the __init__ methods, or any other _ methods; instead the class needs to be annotated (e.g. https://github.com/ray-project/ray/blob/master/python/ray/data/dataset.py#L130)

existing logic for what is excluded from annotations https://github.com/ray-project/ray/blob/master/ci/lint/check_api_annotations.py#L42 (_ names and things under .internal.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in documentation, the class is used instead of the __init__ method as the constructor https://docs.ray.io/en/latest/data/api/dataset.html (e.g. ray.data.Dataset instead of ray.data.Dataset.__init__)

Copy link
Member

Choose a reason for hiding this comment

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

at least this will allow me to turn on the lint check for data team who has aligned with this policy

The table overall looks good to me. To clarify, we're allowed to completely deprecate a stable API after 6 months warning, but we're not allowed to deprecate a parameter of a stable API with 6 months warning?

currenly folks do not annotate the init methods, or any other _ methods; instead the class needs to be annotated

Yeah, we don't typically annotate dunder method. It's conventional to document either __init__ or the class itself, but I think we annotate the class more often (if not always).

Copy link
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

(let you go forward..)

Check if this API has a private name. Private names are those that start with
underscores.
"""
return self.name.split(".")[-1].startswith("_")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what does data team say about these api's? maybe ask them to have a look?

like at least __init__ method of a public api class needs to be public, right? do those also need to be explicitly annotated?

can-anyscale and others added 2 commits June 26, 2024 18:44
Signed-off-by: can <can@anyscale.com>
Currently the `autosummary\n` will be strip the newline character, leads
to incorrect parsing. The test case only works since it has double new
lines. Fix the code + test case.

Test:
- CI

Signed-off-by: can <can@anyscale.com>
@can-anyscale can-anyscale enabled auto-merge (squash) June 26, 2024 19:22
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Jun 26, 2024
@can-anyscale can-anyscale merged commit b67ac12 into master Jun 26, 2024
7 of 8 checks passed
@can-anyscale can-anyscale deleted the can-api05 branch June 26, 2024 19:44
underscores.
"""
name_has_underscore = self.name.split(".")[-1].startswith("_")
is_internal = ".internal." in self.name
Copy link
Member

Choose a reason for hiding this comment

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

Think this has been addressed in a follow-up PR, but should be ._internal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants