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

rfc: Define Python SDK Public API #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asikowitz
Copy link

@asikowitz asikowitz commented Nov 18, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a standardized public API for the acryl-datahub package to enhance user understanding.
    • Defined the __all__ variable to clearly list public classes and functions.
  • Documentation

    • Updated documentation to reflect new conventions for public API communication and versioning practices.
  • Future Work

    • Plans for automated validation of the public API and expansion of the public classes and functions list.

Copy link

coderabbitai bot commented Nov 18, 2024

Walkthrough

The changes introduce a standardized method for defining the public API of the acryl-datahub Python package. This includes the implementation of the __all__ variable in the root __init__.py file to explicitly list public classes and functions, while inner modules will have their __all__ set to an empty list. The proposal emphasizes the importance of clear communication regarding public interfaces, backward compatibility, and outlines future work for automated validation of the public API.

Changes

File Path Change Summary
active/008-metadata-ingestion-public-api.md Introduced a standardized approach for defining public API, discussed __all__ variable usage, and outlined documentation updates.
metadata-ingestion/src/datahub/init.py Defined __all__ to include ["DatahubClientConfig", "DataHubGraph", "Source", "SourceReport"].

Poem

In the code where rabbits hop,
A public API takes the top.
With __all__ now defined so clear,
Our users will have naught to fear.
Hops of joy, let’s celebrate,
For clarity makes our code first-rate! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
active/008-metadata-ingestion-public-api.md (4)

2-2: Format the RFC PR link using proper markdown syntax.

Convert the bare URL to a proper markdown link for better readability.

-- RFC PR: https://github.com/datahub-project/rfcs/pull/8
+- RFC PR: [#8](https://github.com/datahub-project/rfcs/pull/8)
🧰 Tools
🪛 Markdownlint

2-2: null
Bare URL used

(MD034, no-bare-urls)


64-94: Standardize markdown list markers.

The alternatives section uses a mix of * and + for list items. For consistency, use - throughout the document as per markdown best practices.

-- Mark internal APIs with a leading underscore
-  * Pros
-    + Simple and widely understood convention
-  * Cons:
-    + Requires renaming the majority of existing classes and methods
+- Mark internal APIs with a leading underscore
+  - Pros
+    - Simple and widely understood convention
+  - Cons:
+    - Requires renaming the majority of existing classes and methods

(Apply similar changes throughout the alternatives section)

🧰 Tools
🪛 Markdownlint

65-65: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


66-66: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


67-67: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


68-68: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


69-69: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


70-70: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


72-72: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


73-73: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


74-74: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


75-75: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


76-76: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


77-77: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


79-79: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


80-80: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


81-81: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


82-82: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


83-83: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


84-84: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


85-85: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


86-86: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


88-88: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


89-89: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


90-90: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


91-91: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


92-92: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


93-93: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


94-94: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


102-103: Enhance the future work section with specific validation criteria.

Consider adding more details about:

  • What aspects of the public API will be validated (documentation, type hints, backward compatibility)
  • How the validation will be implemented (e.g., custom tools, existing linters)
  • Criteria for adding new classes/functions to the public API

21-23: Consider elaborating on the versioning strategy.

While the requirement for semantic versioning is mentioned, it would be helpful to explicitly define:

  • What constitutes a breaking change in the public API
  • How version numbers will be incremented for different types of changes
  • How deprecation notices will be handled
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8852b24 and 13c8d01.

📒 Files selected for processing (1)
  • active/008-metadata-ingestion-public-api.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint
active/008-metadata-ingestion-public-api.md

65-65: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


66-66: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


67-67: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


68-68: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


69-69: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


70-70: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


72-72: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


73-73: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


74-74: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


75-75: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


76-76: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


77-77: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


79-79: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


80-80: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


81-81: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


82-82: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


83-83: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


84-84: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


85-85: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


86-86: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


88-88: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


89-89: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


90-90: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


91-91: Expected: dash; Actual: asterisk
Unordered list style

(MD004, ul-style)


92-92: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


93-93: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


94-94: Expected: dash; Actual: plus
Unordered list style

(MD004, ul-style)


2-2: null
Bare URL used

(MD034, no-bare-urls)

🔇 Additional comments (1)
active/008-metadata-ingestion-public-api.md (1)

41-47: Verify the existence and accessibility of the public API entities.

The example looks good, but let's verify that these classes exist and are properly exposed in their respective modules.

Copy link
Collaborator

@hsheth2 hsheth2 left a comment

Choose a reason for hiding this comment

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

Our public and private interfaces are confusingly intermixed right now. I think we probably want to do some refactoring here. For example, we probably should have a datahub.sdk with all the mce builder helpers and the graph.

If we did that, we'd be able to say something like "everything in datahub.api, datahub.sdk, datahub.metadata., datahub.ingestion.api., etc" are public, everything else is internal.

E.g. having end users use long import paths like datahub.ingestion.graph.client.DataHubGraph is pretty ugly. Ideally they'd be short like datahub.sdk.DataHubGraph. Some of our other import paths e.g datahub.specific.form also are pretty confusing

Importing and re-exporting things in init.py is pretty standard. We'll need some lint rules to make sure that

  1. the dependency graph is logical e.g. datahub.sdk should not depend on datahub.ingestion
  2. that we use the "true" import path instead of the aliased path everywhere. We already have issues with this, where we import datahub.utilities.urns.urn instead of datahub.metadata.urns

In init.py files we don't need to explicitly set __all__ if we're careful about what we import. I like how dagster does it https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/__init__.py

@hsheth2
Copy link
Collaborator

hsheth2 commented Nov 18, 2024

Broadly, we should do some refactoring instead of just setting all everywhere.

I'm also not actually opposed to renaming a bunch of things to have underscore prefixes e.g. datahub._ingestion

@asikowitz
Copy link
Author

Are you concerned at all about moving files, in case users depend on them in their own forks / scripts? Or would we move them + include a deprecated import reference. Also, what's the advantage of importing from datahub.sdk or datahub.ingestion.api over just datahub? Just a better break-up of the available functions / classes? I was thinking that, to reduce the initial work required, we'd just support just the module datahub and later on add stuff like datahub.sdk.

I like the dagster impl as a way to avoid an explicit __all__.

If we were to do a large renaming of files, then I'd probably advocate for a parent _internal module rather than individual private modules like _ingestion, then we can move certain classes out of _internal if we want them to be public.

@hsheth2
Copy link
Collaborator

hsheth2 commented Nov 19, 2024

Re moving files - we can keep deprecated import references around for a bit

Advantage of datahub.sdk and similar over top-level datahub -> yup mainly just organizational. That said, this isn't a strongly held opinion.

I think you're probably right that dumping everything in top-level datahub init for now is fine and will be easiest, and we can move things around later if needed

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