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

Dev plugin visibility #268

Merged
merged 46 commits into from
Sep 24, 2021
Merged

Dev plugin visibility #268

merged 46 commits into from
Sep 24, 2021

Conversation

liu-ziyang
Copy link
Contributor

@liu-ziyang liu-ziyang commented Sep 23, 2021

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

klai95 and others added 30 commits August 25, 2021 16:48
… in this PR - still trying to look into fixtures
:param key: key to check in s3
:return: True iff cache exists
"""
if bucket is None:
Copy link
Contributor

@klai95 klai95 Sep 23, 2021

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?

Copy link
Contributor Author

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]:
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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

backend/pypi.py Outdated Show resolved Hide resolved
"""
version = get_attribute(plugin, ["info", "version"])

return {
Copy link
Contributor

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?

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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"], "")
Copy link
Contributor

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?

Copy link
Contributor Author

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

@liu-ziyang liu-ziyang requested a review from klai95 September 24, 2021 01:01
citations['APA'] = citation.as_apalike()
except ValueError:
# invalid CITATION.cff content
citations['citation'] = None
Copy link
Contributor

@klai95 klai95 Sep 24, 2021

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)
Copy link
Contributor

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?

Copy link
Contributor Author

@liu-ziyang liu-ziyang Sep 24, 2021

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']:
Copy link
Contributor

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?

Copy link
Contributor Author

@liu-ziyang liu-ziyang Sep 24, 2021

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:
Copy link
Contributor

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?

Copy link
Contributor Author

@liu-ziyang liu-ziyang Sep 24, 2021

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

Copy link
Contributor

@klai95 klai95 left a comment

Choose a reason for hiding this comment

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

LGTM!

@liu-ziyang liu-ziyang merged commit 67e3ca8 into main Sep 24, 2021
@liu-ziyang liu-ziyang deleted the dev-plugin-visibility branch September 24, 2021 21:14
@liu-ziyang liu-ziyang linked an issue Sep 24, 2021 that may be closed by this pull request
neuromusic added a commit that referenced this pull request Oct 7, 2021
…i sourcing clearer (#271)

- adds field that describes functionality of Dev plugin visibility #268
- uses local svg for PyPI logo
- revises wording of fields where we prioritize info in `.napari`
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.

hidden plugins
2 participants