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

chore: Clean up KFP SDK docstrings, make formatting a little more consistent #4218

Merged
merged 11 commits into from
Aug 3, 2020

Conversation

alexlatchford
Copy link
Contributor

@alexlatchford alexlatchford commented Jul 15, 2020

If you want to check out the rendering of this build you can see it here: https://al-kubeflow-pipelines.readthedocs.io/en/alexla-cleanup-sdk-docs/

Some of the biggest changes can be seen in the kfp.Client changes, old version vs new version in this PR.

Description of your changes:

Done:

  • Update KFP SDK to use Google Style docstrings and get them to render nicely.
    • Removed references to the kfp.notebook package for now as it's not actually rendering anything.
    • Removed default modules.rst listing, wasn't actually linked anywhere and it's duplicated by the functionality in the index.rst.
  • Added a couple of new docstrings for prominent methods.
    • I've tried to not change the content of the existing docstrings where possible to minimize the complexity of the review, should just be stylistic changes.
  • Added in a .readthedocs.yml config file to make it easier to understand the dependency structure of the KFP SDK docs.

My plan is to get a little bit of feedback on whether this is a good approach before updating the remainder of the modules in a similar fashion.


Would be nice to cherry-pick this across since it makes the formatting of the KFP SDK docs a little more consistent.

@kubeflow-bot
Copy link

This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Hi @alexlatchford. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@alexlatchford
Copy link
Contributor Author

alexlatchford commented Jul 15, 2020

/assign @paveldournov

~~Looks like you're the recommended reviewer, this PR isn't 100% ready although it could be merged, I've really only gone through ~50% of the modules but I'm planning on giving the same treatment to all of them if this approach is approved. Current progress:~~

Finished all the modules now:

  • kfp.Client
  • kfp.compiler
  • kfp.components (Need a bit more work on the submodules here)
  • kfp.containers
  • kfp.dsl
  • kfp.extensions

@Bobgy
Copy link
Contributor

Bobgy commented Jul 15, 2020

/assign
/cc @Ark-kun

Super thanks!

@@ -140,6 +139,10 @@
#
# html_sidebars = {}

html_css_files = [
'custom.css',
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed this to break the lines of long code blocks, see here for an example.

other_client_secret: The client secret used to obtain the auth codes and refresh tokens.
existing_token: Pass in token directly, it's used for cases better get token outside of SDK, e.x. GCP
Cloud Functions or caller already has a token
cookies: CookieJar object containing cookies that will be passed to the pipelines API.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something I noticed consistently was that we were missing the API docs for constructors despite them being there. Looks like Sphinx reads from the class docstring by default, you can have it read from the class docstring or __init__ or both so happy to conform to either if people have a preference. For now I just kept the Sphinx default.

@@ -79,17 +80,19 @@ def build_image_from_working_dir(image_name: str = None, working_dir: str = None
file_filter_re: Optional. A regular expression that will be used to decide which files to include in the container building context.
timeout: Optional. The image building timeout in seconds.
base_image: Optional. The container image to use as the base for the new image. If not set, the Google Deep Learning Tensorflow CPU image will be used.
builder: Optional. An instance of ContainerBuilder or compatible class that will be used to build the image.
builder: Optional. An instance of :py:class:`kfp.containers.ContainerBuilder` or compatible class that will be used to build the image.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just wanted to highlight the syntax we can use to add in cross-SDK reference hyperlinks. There are a bunch more than just :py:class: but basically all follow a similar format: https://www.sphinx-doc.org/en/1.7/domains.html#python-roles

...
```
Example:
::
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another common problem I fixed was setting injecting literal (::) so Sphinx would interpret the example as a formatted code block.

Looks like Sphinx needs the :: to be followed by a blank line then the code block indented for it to actually format nicely. Guessing there is likely something we can do with a linter to begin to enforce this but for now I've just fixed them manually.

@alexlatchford alexlatchford force-pushed the alexla/cleanup-sdk-docs branch from 1afcfbe to b7b132f Compare July 16, 2020 15:52
@Ark-kun
Copy link
Contributor

Ark-kun commented Jul 17, 2020

Wow! Thank you for this tremendous work!
The docstrings were in dire need for a good overhaul. They were added long before we started using Sphinx.

kfp.components (Need a bit more work on the submodules here)

JFYI: Do not bother with kfp.components.structures.kubernetes - it will be removed soon.

I only have couple of small comments:

  • In some cases where you reference classes you might want to use more specific :py:... keywords instead of just :code:.
  • In some cases there are indentation changes that make the diff seem bigger than it is. I wonder whether we can keep the indentations in some places.

@Bobgy
Copy link
Contributor

Bobgy commented Jul 17, 2020

/ok-to-test

@Bobgy Bobgy added the cherrypick-approved area OWNER approves to cherry pick this PR to current active release branch label Jul 17, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bobgy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Bobgy
Copy link
Contributor

Bobgy commented Jul 31, 2020

@alexlatchford Do you have suggestions on where to read about syntax and how to verify rendered documentation locally?

Also, is there any lint tools that can catch the most common mistakes?

These will be helpful to let us follow best practices along new changes.

@alexlatchford
Copy link
Contributor Author

Hey @Bobgy I can write up something and add it to the developer_guide.md it that works for you? (Will do it as a separate PR as this one is now approved).

Do you need anything from me to fix those pending tests (which I'm guessing will block the merging)?

  • kubeflow-pipeline-e2e-test
  • kubeflow-pipeline-sample-test

@Bobgy
Copy link
Contributor

Bobgy commented Jul 31, 2020

That will be awesome! Separate PR also works.

I think they are already fixed.
/retest

@chases2
Copy link

chases2 commented Jul 31, 2020

Prow seems to be having trouble merging this PR.
/check-cla

@chases2
Copy link

chases2 commented Jul 31, 2020

/hold

@chases2
Copy link

chases2 commented Jul 31, 2020

Seems to be a known issue #1653

The cla/google check is the only thing not passed (without the hold), so Prow thinks it can merge, but GitHub doesn't.

@Bobgy
Copy link
Contributor

Bobgy commented Jul 31, 2020

@googlebot rescan

@Bobgy
Copy link
Contributor

Bobgy commented Jul 31, 2020

/unhold

Sorry for confusion @chases2, sometimes the cla check stuck.

@Bobgy
Copy link
Contributor

Bobgy commented Aug 1, 2020

/retest

Looks like some build failure in master. I will fix it next week

@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/retest

@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/retest
test infra seems flaky

@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/retest

1 similar comment
@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/retest

@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/test kubeflow-pipeline-backend-test

@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

/retest

@k8s-ci-robot
Copy link
Contributor

@alexlatchford: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
kubeflow-pipeline-e2e-test 2fb1973 link /test kubeflow-pipeline-e2e-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@Bobgy Bobgy merged commit 704c8c7 into kubeflow:master Aug 3, 2020
@Bobgy
Copy link
Contributor

Bobgy commented Aug 3, 2020

Force merged because failures are flaky.

@alexlatchford alexlatchford deleted the alexla/cleanup-sdk-docs branch August 3, 2020 16:35
chensun pushed a commit to chensun/pipelines that referenced this pull request Aug 7, 2020
…sistent (kubeflow#4218)

* Prepare SDK docs environment so its easier to understand how to build the docs locally so theyre consistent with ReadTheDocs.

* Clean up docstrings for kfp.Client

* Add in updates to the docs for compiler and components

* Update components area to add in code references and make formatting a little more consistent.

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Remove unused kfp.notebook package links

* Clean up a few more errant references

* Clean up the DSL docs some more

* Update SDK docs for KFP extensions to follow Sphinx guidelines

* Clean up formatting of docstrings after Ark-Kuns comments
@Bobgy Bobgy removed the cherrypick-approved area OWNER approves to cherry pick this PR to current active release branch label Sep 4, 2020
@Bobgy
Copy link
Contributor

Bobgy commented Sep 4, 2020

Cannot really cherrypick this to 1.0.1 because there are merge conflicts

Jeffwan pushed a commit to Jeffwan/pipelines that referenced this pull request Dec 9, 2020
…sistent (kubeflow#4218)

* Prepare SDK docs environment so its easier to understand how to build the docs locally so theyre consistent with ReadTheDocs.

* Clean up docstrings for kfp.Client

* Add in updates to the docs for compiler and components

* Update components area to add in code references and make formatting a little more consistent.

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Clean up containers, add in custom CSS to ensure we do not overflow on inline code blocks

* Remove unused kfp.notebook package links

* Clean up a few more errant references

* Clean up the DSL docs some more

* Update SDK docs for KFP extensions to follow Sphinx guidelines

* Clean up formatting of docstrings after Ark-Kuns comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants