-
Notifications
You must be signed in to change notification settings - Fork 18
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
Dev plugin visibility #268
Conversation
…luded_plugins.json
… in this PR - still trying to look into fixtures
…ari-hub into hidden-plugin-feature
:param key: key to check in s3 | ||
:return: True iff cache exists | ||
""" | ||
if bucket is None: |
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.
We can return False also if key is an empty string so we can short circuit the try-except clause?
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.
true, though there is no use case for that yet
return None | ||
|
||
|
||
def cache(content: Union[dict, list], key: str) -> Union[dict, list]: |
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.
Since we are using type Union
for the parameter content
, when do we expect content
to be of type dict
vs type list
?
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.
technically it doesn't care, it would cache the given content regardless of type, just that the hints are saying these are supported ones
Cache the given content to the key location. | ||
|
||
:param content: content to cache | ||
:param key: key path in s3 |
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.
Should we do an error check for the key
parameter or an empty string check?
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.
we don't have anything calling it with empty string right now
""" | ||
version = get_attribute(plugin, ["info", "version"]) | ||
|
||
return { |
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.
we should include visibility here right?
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.
nope, the visibility comes from github metadata, the logic is in model.py
:return: plugin metadata list | ||
""" | ||
plugins_metadata = {} | ||
with futures.ThreadPoolExecutor(max_workers=32) as executor: |
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.
How did we decide on max_worker=32
?
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.
it is more or less arbitrary, just trying to parallelize the work, it may not be the optimal setting but good enough so far
api_url = url.replace("https://github.com/", | ||
"https://api.github.com/repos/") | ||
auth = None | ||
if github_client_id is not None and github_client_secret is not None: |
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.
Would if None not in (github_client_id, github_client_secret):
be more concise?
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.
if we have more items I would be tempted to do so, but I personally found this more readable
@@ -37,7 +37,7 @@ locals { | |||
frontend_alb_zone = try(local.secret[local.alb_key]["frontend"]["zone_id"], "") | |||
frontend_alb_dns = try(local.secret[local.alb_key]["frontend"]["dns_name"], "") | |||
|
|||
slack_url = try(local.secret["slack_url"], "") | |||
slack_url = try(local.secret["slack"]["url"], "") |
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.
Can you explain the context for this code change?
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.
we updated the slack URL in the infra config, it does not allow set of string value in the secret so it was wrapped in a library
backend/github.py
Outdated
citations['APA'] = citation.as_apalike() | ||
except ValueError: | ||
# invalid CITATION.cff content | ||
citations['citation'] = None |
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.
How about citations = dict.fromkeys(['citation', 'RIS', 'BibTex', 'APA'], None)
in the except
clause?
- cache/public-plugins.json (overwrite) | ||
- cache/hidden-plugins.json (overwrite) | ||
- cache/index.json (overwrite) | ||
- cache/{plugin}/{version}.json (skip if exists) |
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.
Why do we skip if exists?
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.
we don't reprocess metadata for plugin with known name and version because pypi metadata does not change
if plugin in plugins_metadata: | ||
del (plugins_metadata[plugin]) | ||
|
||
if visibility_plugins['public']: |
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.
In the case where hidden plugins do exist, how come we are not calling notify_new_packages
to notify if the conditions are true?
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.
we do not send notifications for hidden plugins, these notifications are for everyone to know there is a plugin that is ready for public use
""" | ||
excluded_plugins = get_excluded_plugins() | ||
for plugin, plugin_metadata in plugins_metadata.items(): | ||
if 'visibility' not in plugin_metadata: |
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.
if this condition is true, why do we not want to create the visibility
key in plugin_metadata
? Also, what would be the case in which this happens?
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.
if visibility does not present we treat it as a public plugin, this would occur when the developer does not specify the plugin visibility, which is equivalent to what we are displaying now
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.
LGTM!
Warning: this PR has some major refactors of code structure to support future feature development.
(Q: Why refactor now? A: because of the plugin visibility feature change, we are reworking some of the underlying flow which resulted in complexity increase and fundamental data filter/manipulations, the main block grow past hundreds line of code without breaking down, and made it difficult to develop for future.)
In order to test the refactored code, I have been adding more unit tests along the way and try to regression test against
https://plugin-visibility-frontend.dev.imaging.cziscience.com/
It seems the environment have been working consistently comparing to prod site so far. (other than the newly introduced visibility flag, which is being tested now with napari-demo set to 'hidden' and it seems to be working correctly)
Just to be safe, I plan to leave this dev branch up a few days on regression testing and make sure the zulip messaging is also consistent with prod behavior
ps. did I mention cffconverter updated their library suddenly (8 hours ago when I was working on it) and supported APA? I added it in since it is a very small change