-
Notifications
You must be signed in to change notification settings - Fork 61
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
frontend: migrate API projects namespace to flask-restx #2807
Conversation
a4c578e
to
5278c29
Compare
5278c29
to
40f44af
Compare
40f44af
to
e97587d
Compare
with this we can get information about Actions in projects and show it to user Closes: fedora-copr#2807
I accidentally closed it in 1c8f37f (typo in issue number) |
b66bf04
to
e7f70da
Compare
e7f70da
to
93bd0d7
Compare
93bd0d7
to
4efd3c6
Compare
f8e6766
to
8c1c418
Compare
I am also getting tracebacks from
and
|
no progress |
8c1c418
to
fe32d34
Compare
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.
vcs-diff-lint found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
7ffc918
to
a6129a6
Compare
c8a09b6
to
007c77e
Compare
bdc2824
to
3b21979
Compare
fbbb56c
to
4e6ac08
Compare
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.
Thank you for all of the updates. I was honestly a bit worried about the number of changes in this PR but as it turns out, it looks really good!
I am adding some in-code comments and then do some testing and submit a follow-up.
@@ -38,8 +38,6 @@ | |||
from .json2form import get_form_compatible_data | |||
|
|||
|
|||
|
|||
|
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.
A leftover change here
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 is just syntax fix since it has 4 new lines instead of 2
@@ -51,48 +47,67 @@ def home(): | |||
# HTTP methods | |||
GET = ["GET"] | |||
POST = ["POST"] | |||
# TODO: POST != PUT nor DELETE, we should use at least use these methods according | |||
# conventions -> POST to create new element, PUT to update element, DELETE to delete | |||
# https://www.ibm.com/docs/en/urbancode-release/6.1.1?topic=reference-rest-api-conventions |
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.
Sounds reasonable but if we decide to do this, we need to fix python-copr
, ideally a few releases beforehand.
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.
yep, this is just todo - I deprecated it in docs so users are lightly pushed to use methods according to convention but I have no intention to discuss/bring a plan to drop them... just tell users the should use something else but keep it working.
I even introduced a warning header message that the endpoint is deprecated - but yes, this will be better once python-copr is fixed accordingly because then it would make response with warning headers even using copr's official python library which isn't good - thanks for pointing to it
if extra_fields is None: | ||
return result_dict | ||
|
||
return result_dict | extra_fields |
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.
At first sight, this function looks like a really good idea. I want to circle back here when finishing the review to check again.
@@ -40,6 +72,11 @@ def to_dict(copr): | |||
"packit_forge_projects_allowed": copr.packit_forge_projects_allowed_list, | |||
"follow_fedora_branching": copr.follow_fedora_branching, | |||
"repo_priority": copr.repo_priority, | |||
# TODO: unify projectname and name or (good luck) force marshaling to work |
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.
😆
""" | ||
Edit Copr project | ||
Edit existing Copr project for ownername/projectname in form. | ||
""" |
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 I understand correctly, we are going to deprecate this in the future and keep only PUT? Please don't use the @deprecated
decorator yet but it'd be a good idea to mention that we plan to deprecate it in the docstring. Same for other POST -> PUT/DELETE routes.
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 would be nice to warn users to use the proper HTTP method - e.g. PUT and fix it in python-copr.
I think mentioning it somewhere (e.g. release notes) is a good idea.
we are going to deprecate this in the future and keep only PUT
I think a lot of users use our API in this "bad" way and I don't want to force them to fix their already working scripts. This idea is mainly about documentation saying it is deprecated and a warning header saying it is deprecated but no plan to drop the functionality whatsoever
frontend/coprs_frontend/coprs/views/apiv3_ns/schema/__init__.py
Outdated
Show resolved
Hide resolved
is_background: Boolean | ||
ownername: String | ||
project_dirname: String | ||
projectname: String |
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 am quite unhappy, that we define the same data type on multiple places. Here, and in fields.py
.
projectname = String(
description="Name of the project",
example="copr-dev",
)
Can we do something about that?
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 am not 100% sure but I think there isn't a way to do it :/ pydantic/marshmallow or dataclasses needs to define somehow the types for i/o checking
- one possible solution is to get rid of
fields.py
but that will mean defining the same descriptions, etc. on multiple place - or with dataclasses we could just write
some_field: ...
orsome_field: Any
- it doesn't matter (python's syntax just needs some type definition), but pydantic/marshmallow will require it to check the input/output
I saw this way as the "lesser evil" and allowing #3031 happen with the least amount of pain as possible (thus dropping the deprecated parsers)
The following beaker tests fail, some of them possibly related to this PR:
|
6a986b2
to
700adf8
Compare
700adf8
to
dd17175
Compare
a3d4ba7
to
ab18608
Compare
ab18608
to
a787b5e
Compare
a787b5e
to
49d17cd
Compare
@FrostyX I fixed hopefully everything - some beaker tests still fail but I think it isn't fault of this PR. some were falling mainly because of @editable_copr -> @api_login_required has to be used before it |
I run beaker tests against the current main and the same tests fail as with this PR:
and runtest-architectures are stuck upon s390x |
Thank you for the progress. This is not an easy one. |
Fixes #2995