Repository navigation
Plugin extensible xblock services - #927
felipemontoya wants to merge 3 commits into
Conversation
|
Thanks for the pull request, @felipemontoya! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
35dbbd5 to
ea3e7b0
Compare
|
@bradenmacdonald @symbolist @pdpinch as fellow maintainers of the xblock library, what do you think about this? |
Henrrypg
left a comment
There was a problem hiding this comment.
Hey folks, i was playing a bit with this implementation and i like it!
Here we have an example of how it could work with ora :) a quick test only adding suggestions as a raw text, but we definitively can go deeper
Screencast.from.12-06-26.17.08.11.webm
| **Why the ``needs``/``wants`` gate stays in front.** The declaration check | ||
| runs before any entry-point lookup, so a plugin-provided service is only ever | ||
| handed to blocks that explicitly asked for it. ``wants`` gives blocks a | ||
| portable soft-dependency: the same block works on installs with and without | ||
| the providing package, enabling features conditionally. |
There was a problem hiding this comment.
I can understand why we have a needs declaration (to show an appropriate error when a required service is not available). But I never understood the point of declaring wants. It just seems like pointless boilerplate.
"We don't allow XBlocks to access a service unless they declare it with needs/wants, because if they don't declare it, ___" What? It would still work totally fine if every XBlock implicitly wants every service, without having to declare them.
There was a problem hiding this comment.
@bradenmacdonald Remind me-- do XBlocks break in a loud way upon system startup if they're missing the 'needs' declaration? Or only when someone calls the service function?
If it's only when someone calls the service function, it does seem nearly useless. The only advantage I could think of is that you'd never be handling a None when using the service function, but I'm not sure throwing an exception is exactly better.
If it's upon system startup, or when trying to invoke the block at all, it could at least surface dependency issues early.
|
Hi @felipemontoya! Is this still in progress? |
|
@mphilbrick211 yes it is. It is just slowly simmering for a while waiting for any more comments while I start working on this again. I'm a core contributor to this repo so I could update and merge but I dont have immediate pressure as it will probably be 2~4 weeks before I come back to this initiative. |
|
Hello everyone, we're working with WGU team on integrate xblock-ai-evaluation with openedx-ai-extensions framework. It would be so helpful to get this PR merged for that effort. As i see this PR needs an approval from one more maintainer @felipemontoya may you rebase this PR please? Hi @Kelketek, can somebody from your team help us with a review here please? |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a47654f to
d23091d
Compare
|
Rebased. Happy to see other use cases for this extension point. I was planning to push this when I start working on ORA2 and the AI connection but I'm happy to start with your case. |
Kelketek
left a comment
There was a problem hiding this comment.
I'll have to look into the code part later, but I had a few questions/things to consider about the proposal as it stands.
| service still gets ``NoSuchServiceError``. | ||
| 2. Return the runtime-provided service from ``_services`` if present | ||
| (unchanged). | ||
| 3. **New:** if the runtime has nothing, try |
There was a problem hiding this comment.
Shouldn't we make deliberately installed plugin services priority? While this means extensions could potentially collide with officially supported services, the alternative is that the default services can never be overwritten, when it might be useful to do so.
| 3. **New:** if the runtime has nothing, try | ||
| ``_load_service_from_entry_point(block, service_name)``, which loads the | ||
| provider class from the ``xblock.service.v1`` group and instantiates it as | ||
| ``provider_class(runtime=self, xblock=block)``. |
There was a problem hiding this comment.
Are we sure this is a sufficient number of arguments for instantiating an XBlock service? Several services require the user to be specified. Some others use custom functions, such as the replace_urls service taking an optional lookup_asset_url argument which some runtimes provide and others do not.
| Placing the lookup after the ``_services`` miss, inside the one method every | ||
| runtime inherits, gives complete coverage (all Open edX runtimes, the | ||
| workbench, third-party runtimes that don't override ``service()``) for a | ||
| single small change, and gives a hard guarantee: *runtime-provided services |
There was a problem hiding this comment.
I think the advantage of being able to override core services may be worth a few more lines of code.
Currently there's no way to do this. I will concede that I know of no one in particular trying to do this, but we could expect that teams might want to run an experimental iteration on top of a service without running a custom fork of the platform, or a service might get 'promoted' to core and change the semantics of a service for a team who isn't ready to move yet, and is still installing the originating plugin.
| fallback is one dict lookup); loud ``AmbiguousPluginError`` when two installed | ||
| packages claim the same service name, instead of last-write-wins — the exact | ||
| failure mode that makes monkey-patching unacceptable; a sanctioned override | ||
| path (``xblock.service.v1.overrides``) when replacing a default implementation |
There was a problem hiding this comment.
This appears to imply that, yes, we are allowing overriding of default implementations. But that's in contradiction to the earlier statement that plugins won't be able to override the base service, and it would also imply that the existing services would need to be converted to plugins somehow. That would be a significant refactoring.
| is intentional; and ``register_temp_plugin`` for tests. | ||
|
|
||
| **Why ``provider_class(runtime=…, xblock=…)``.** This mirrors the | ||
| constructor of the reference ``Service`` class, gives the provider the two |
There was a problem hiding this comment.
This is the first I've heard of the reference Service class. I've never seen it used, nor do I know of any real service that accepts the runtime as an initialization argument. In the platform, all the services accept individual, specific arguments, and they are never the runtime.
The omission is glaring enough that I have to imagine it was intentional-- the idea being that each service should be completely separate and not depend on calling another service, which would be the most probable use of using the runtime directly.
| **Why the ``needs``/``wants`` gate stays in front.** The declaration check | ||
| runs before any entry-point lookup, so a plugin-provided service is only ever | ||
| handed to blocks that explicitly asked for it. ``wants`` gives blocks a | ||
| portable soft-dependency: the same block works on installs with and without | ||
| the providing package, enabling features conditionally. |
There was a problem hiding this comment.
@bradenmacdonald Remind me-- do XBlocks break in a loud way upon system startup if they're missing the 'needs' declaration? Or only when someone calls the service function?
If it's only when someone calls the service function, it does seem nearly useless. The only advantage I could think of is that you'd never be handling a None when using the service function, but I'm not sure throwing an exception is exactly better.
If it's upon system startup, or when trying to invoke the block at all, it could at least surface dependency issues early.
| ************ | ||
|
|
||
| * Installed packages can provide named runtime services to consenting blocks | ||
| on any runtime that uses the default resolution path; no host-application |
There was a problem hiding this comment.
The only host application that matters is the platform. The only other consumer of XBlocks I know of is the workbench, and I've already got a plan to deprecate it. Attempts to get other teams to use XBlocks have failed and they are in practice dependent on openedx-platform's implementation.
We don't have to be fearful of making changes in the host-application in fear of screwing up other environments.
This PR adds the capability for openedx plugins to add services to the xblock_runtime. This is needed to be able to offer xblocks (e.g: ORA) capabilities from inside a platform plugin (e.g: openedx-ai-extensions) in a way that does not create a dependency hell and lets the xblock respond gracefully when the service is not present.
References: