-
Notifications
You must be signed in to change notification settings - Fork 25
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
Update invenio GitHub #99
Update invenio GitHub #99
Conversation
concentrate the configuration of all calls in one place
9826cc0
to
50a5c99
Compare
e76934f
to
4eb6323
Compare
b9f65b3
to
6ae5be8
Compare
@@ -0,0 +1,109 @@ | |||
// /* |
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.
this code is jquery, it will be removed.
I just commented it for now.
@@ -20,14 +20,14 @@ | |||
* or submit itself to any jurisdiction. |
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.
this code is jquery, it will be removed.
I just commented it for now.
4b16040
to
9ba7aaa
Compare
) | ||
|
||
return repo_instance | ||
|
||
@classmethod | ||
def _dev_api(cls): |
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.
These three class methods were not tested yet by me.
It seems only revoke_token
is used by a task
'ping' column tracked the last time a repository received a ping event. it was never consumed on Zenodo before, so we decided to remove it. the event itself is still persisted in db.
9ba7aaa
to
189ad7f
Compare
def decorator(f): | ||
@wraps(f) | ||
def inner(*args, **kwargs): | ||
github = GitHubAPI(user_id=current_user.id) |
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.
question: this decorator instantiates a GithubAPI
object, while the views that use the decorator start by instantiating it (again). Should we pass the instance? E.g.
kwargs["github_api"] = github
return f(*args, **kwargs)
@register_menu( # TODO modify? | ||
blueprint, | ||
"settings.github", | ||
# TODO substitute github for icon + 'Github' |
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.
TODO: the github icon does not show up in the UI. This has to be enabled when working the UI part of the integration
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.
ping @anikachurilova
releases=releases, | ||
serializer=current_github.record_serializer, | ||
) | ||
except RepositoryAccessError as e: | ||
abort(403) |
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 a big fan of these try/catch
and then abort(code)
. Perhaps we can have error handlers (as we do with resources). For now it works, but there's room for improvement
|
||
### | ||
# TODO to be moved to its own folder (e.g. separate ui / api) |
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.
Do we want to separate ui
and api
endpoints? We do this separation in some modules, it's easier to navigate the code.
github.sync(async_hooks=False) | ||
db.session.commit() | ||
except Exception: | ||
db.session.rollback() |
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 moved away from nested sessions, as they were giving me some trouble. Namely, when we have to commit a session before spawning a celery task it would make the nested session error on exit.
@@ -26,17 +26,18 @@ | |||
|
|||
from flask import url_for | |||
|
|||
# TODO uncomment when migrated |
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.
Commented for now since I did not touch badges and tests were failing
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've reviewed this with the premise that is a module migration to work with RDM but is not the intention to leave the code 100% clean and fix previous problems (although many were done anyway). I tried to review as much as possible, but is very hard to make an in-depth review in a sensible time due to its size; so my comments are more on structure than actual code implementation.
Tiny rant, nothing personal:
I'm seeing this (very big PRs, I've done it too), and I think we are setting ourselves for failure. Big PRs stay very long in the review column since they are very intimidating. For future reference, it would be nice to have more self contained PRs.
- Black and other migrations
- Example app removal
- Actual code/functionality changes
Having all in one PR with 54 files and 2.2/2.7k changes is quite unmanagable and very time consuming to review. Half of the brain power goes to understand if the change was black formatting or actual code. We can review commits, but in this case there's 5 on the actual code so there's still a need to jump from commit to commit.
Honestly, even GitHub lags to handle a PR of this size 😂
Comments apply in many places related to layers:
- We are importing
NoResultsFound
in some classes and in some we are not. - There is an
api.py
module and others get an actual name, e.g.receivers.py
, nonetheless many seem to be APIs. - A clear separation between whats a model and what's an API, and even maybe splitting some of those API classes.
- I'd suggest to have an
/api
folder and then tiny classes inside since it seems this module does not need an actual service layer but it can be okay with just an api to bridge services (in rdm-records) to the GH api.
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8, 3.9] |
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 wonder if we should remove 3.7 and start adding 3.10
invenio_github/admin.py
Outdated
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.
Will this be migrated to invenio-administration as part of a separate PR?
567b23b
to
33d29b6
Compare
33d29b6
to
7aee5a8
Compare
90b092f
to
ca8b731
Compare
'invenio_github.handlers:account_setup' | ||
GITHUB_REMOTE_APP['params']['request_token_params']['scope'] = \ | ||
'user,admin:repo_hook,read:org' | ||
REMOTE_APP["disconnect_handler"] = "invenio_github.handlers:disconnect" |
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.
question: importing the REMOTE_APP
could be troublesome if it was replaced by another instance. Perhaps we should get the github remote app using the oauth-client extension.
E.g:
remote = LocalProxy(
lambda: current_oauthclient.oauth.remote_apps[
current_app.config["GITHUB_WEBHOOK_RECEIVER_ID"]
]
)
However this is config, can we lazy load?
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.
Created an issue
closes #98
This PR is based on the updates from #97