Repository navigation
get_requested_site: configurable backend to get the site for an API call - #410
Merged
Merged
Conversation
OmarIthawi
force-pushed
the
req_site_backend
branch
from
January 18, 2022 06:56
4026bb7 to
c4f0951
Compare
OmarIthawi
marked this pull request as ready for review
January 18, 2022 06:56
OmarIthawi
requested review from
estherjsuh,
johnbaldwin,
melvinsoft and
shadinaif
as code owners
January 18, 2022 06:56
estherjsuh
approved these changes
Jan 18, 2022
johnbaldwin
reviewed
Jan 24, 2022
|
|
||
| This functions makes use of the `REQUESTED_SITE_BACKEND` setting if configured, otherwise | ||
| it defaults to Django's get_current_site(). | ||
|
|
Contributor
There was a problem hiding this comment.
@OmarIthawi Please add "Using the backend" instructions either here, in this module docstring or in a readme doc
Contributor
Author
There was a problem hiding this comment.
Thanks John! I'll add the instructions to the README doc.
Contributor
Author
There was a problem hiding this comment.
I've documented the feature in a new Configurations section. I'll merge after someone spot check the section.
It's not a complete one, but a start.
johnbaldwin
approved these changes
Jan 24, 2022
johnbaldwin
left a comment
Contributor
There was a problem hiding this comment.
Just one comment to include this new functionality configuration instructions in the code or a readme doc. Thanks!
Description ----------- Dashboard needs to be able to access Figures API with privileged access by sending site's UUID parameter. This concept is Tahoe-specific and shouldn't make it into Figures (thanks John for advocating for that). Therefor this PR adds a plugin to customize the logic we use to `get_current_site()` I've added a Figures plugin repo to do that: - appsembler/tahoe-figures-plugins#1 Using the backend ----------------- - Install a package which has the custom backend e.g. `pip install tahoe-figures-plugins` - In the `server-vars.yml` configure Figures like below: ```yaml FIGURES: REQUESTED_SITE_BACKEND: 'tahoe_figures_plugins.sites:get_current_site_or_by_uuid' ``` Backward compatibility ---------------------- - By default this PR changes nothing for both community and Tahoe installations - The tests works as-is for all Figures views - The plugin only used when configured Benchmark --------- I tested the `import_from_path` function and the load takes 0.0069ms per call if the backend is already imported in the Python module system on a staging server. Loading the backend for the first time (e.g. a new Python gunicorn worker) takes 0.5ms. This seems like an acceptable delay to add on top of the each request.
OmarIthawi
force-pushed
the
req_site_backend
branch
from
January 27, 2022 09:02
c4f0951 to
932eeab
Compare
- left out few items undocumented - another Figures doc update is needed
OmarIthawi
force-pushed
the
req_site_backend
branch
from
January 27, 2022 09:36
d2ecb21 to
6ececda
Compare
OmarIthawi
added a commit
that referenced
this pull request
Jan 27, 2022
Merging after #410 is merged.
thraxil
approved these changes
Jan 27, 2022
OmarIthawi
added a commit
that referenced
this pull request
Jan 27, 2022
Merging after #410 is merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Dashboard needs to be able to access Figures API with privileged access by sending site's UUID parameter.
This concept is Tahoe-specific and shouldn't make it into Figures (thanks John for advocating for that). Therefor this PR adds a plugin to customize the logic we use to
get_current_site()I've added a Figures plugin repo to do that:
get_current_site_or_by_uuidtahoe-figures-plugins#1Using the backend
Install a package which has the custom backend e.g.
pip install tahoe-figures-pluginsIn the
server-vars.ymlconfigure Figures like below:Backward compatibility
Benchmark
I tested the
import_from_pathfunction and the load takes 0.0069ms per call if the backend is already imported in the Python module system on a staging server.Loading the backend for the first time (e.g. a new Python gunicorn worker) takes 0.5ms.
This seems like an acceptable delay to add on top of the each request.
Expand to see the "timeit" code used
Test module reload time with cache
Test module reload time without cache