-
Notifications
You must be signed in to change notification settings - Fork 11
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
ADR for Public Python API Conventions #186
Conversation
@kdmccormick, @bradenmacdonald: Please review the ADR here. |
I'm going to hold this ADR open for at least a week, (so until May 6th), to give anyone in the wider community a chance to comment on it. Edit: Advertised here: https://discuss.openedx.org/t/adr-on-python-public-api-conventions-in-learning-core/12872 |
App ``api`` modules should not import directly from apps outside their package. | ||
For example, ``openedx_learning.apps.personalization.api`` should import authoring API functions from ``openedx_learning.api.authoring``, **not** directly from something like ``openedx_learning.apps.authoring.components.api``. This will help to limit the impact of refactoring app package internal changes, as well as exposing shortcomings in the existing public APIs. | ||
|
||
Public API modules may implement their own functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. Not only for convenience but also as a way to address the natural evolution of the API. Do you think this might replace versioning by creating shims and deprecating functions with good documentation and timelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it will replace versioning altogether, but I definitely plan to use compatibility shims more liberally here than we have in for Django apps historically, and to make deprecations happen at the level of individual functions with deprecation warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this proposal. Left a question, but mostly curious about it. Nothing blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. It would be nice to update the import linter in edx-platform to make sure that people are following this.
@felipemontoya: Thank you for looking at it so quickly! |
|
||
This relies on the individual apps to properly set ``__all__`` to the list of functions that they are willing to publicly support. | ||
|
||
App ``api`` modules within a package of apps still import from each other. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth having a convention of _api
to indicate more local APIs that are meant to be used internal to the project but is not reliable outside of the openedx-learning
project? It seems cumbersom but also could help reduce the surface area of API that we have to guarantee to parties that build on top of openedx-learning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting idea. I guess it partly depends on where the maintenance boundaries end up being. This arrangement makes more sense to me if a single group of people is responsible for the broad package of authoring
apps, as opposed to multiple teams working on separate groups of apps in authoring
(which is... probable...?). I admit that part of my resistance to this idea might just be aesthetic–it feels weird to me that the components
app would import from a private module of publishing
(openedx_learning.apps.publishing._api
).
I'm hoping that between documentation and importlinter rules in edx-platform, it'll be clear that consumers should only import from modules in the openedx_learning.api
package. But I'm definitely open to revisiting this if it turns out to be a source of confusion.
Updated ADR to record feedback from @bradenmacdonald and @feanil. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see the import linting rules for this in edx-platform as close to merging this as possible.
I'll include it as part of the refactoring PR necessary on the edx-platform side to switch over. |
This proposes refactoring our apps and introducing two major new conventions at the same time:
openedx_learning.core
would now be inopenedx_learning.apps.authoring
, setting a pattern for grouping apps together into larger package groups.openedx_learning.api.authoring
module would be created to aggregate API modules from apps inopenedx_learning.apps.authoring
.I originally wrote this up as a part of the major refactoring in #184, but separated out here so that we can discuss it in its own space.