Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

patchwork cleanups and enhacements #137

Merged
merged 6 commits into from
Sep 4, 2018
Merged

Conversation

veruu
Copy link
Contributor

@veruu veruu commented Aug 31, 2018

No description provided.

@coveralls
Copy link

coveralls commented Aug 31, 2018

Pull Request Test Coverage Report for Build 464

  • 3 of 24 (12.5%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.2%) to 38.147%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sktm/executable.py 0 1 0.0%
sktm/patchwork.py 3 23 13.04%
Files with Coverage Reduction New Missed Lines %
sktm/executable.py 1 16.26%
sktm/patchwork.py 2 18.43%
sktm/init.py 2 20.2%
Totals Coverage Status
Change from base Build 459: 0.2%
Covered Lines: 469
Relevant Lines: 1109

💛 - Coveralls

Copy link
Contributor

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

Thank you, Veronika! Looks good, I just would like to request some documentation changes.

Get project ID based on its name. Child classes need to implement
this method.
"""
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask you to write full documentation for this method? I think it's even more important to document than the implementations, as it defines the interface.

sktm/__init__.py Outdated
@@ -124,7 +123,6 @@ def add_pw(self, baseurl, pname, lpatch=None, restapi=False, apikey=None,
baseurl, pname, int(lpatch) if lpatch else None, skip
)

# FIXME Figure out the last patch first, then create the interface
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't read this code now, but I think converting between project ID and name shouldn't be a job for a patchwork project class, but rather for a patchwork server (instance) class. The latter can have an interface to retrieve project objects for specific IDs and have an interface for conversion to and from a project name, i.e. the _get_project_id() function should be moved there. Then we will be able to deal with these FIXMEs properly.

That's not something we need to do in this PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having a class to deal with a full Patchwork server is definitely a neat idea. Do you think you can submit an issue for that, so we don't forget about it while dealing with other things?

Copy link
Contributor

Choose a reason for hiding this comment

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

Aand, here it is: #140.

parser_patchwork.add_argument("--lastpatch", type=str, help="Last patch "
"(id for pw1; datetime for pw2)")
parser_patchwork.add_argument("--lastpatch", type=int,
help="Last patch ID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Aaah, finally, thank you 😌

sktm/__init__.py Outdated
lpatch: Last processed patch. Patch ID, if adding an XML
RPC-based interface. Patch timestamp, if adding a
REST-based interface. Can be omitted to
lpatch: Last processed patch. Patch ID. Can be omitted to
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think saying ID of the last processed patch. here would read better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely!

@@ -902,8 +901,7 @@ def get_patch_by_id(self, pid):
patch = self.rpc.patch_get(pid, self.fields)

if patch is None or patch == {}:
logging.warning("Failed to get data for patch %d", pid)
patch = None
raise Exception('Can\'t get patch by id %d)'.format(pid))
Copy link
Contributor

Choose a reason for hiding this comment

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

Niiice 👍

Introduce a method in the parent class that the child classes are
supposed to implement and override (fixes composition and pylint error)
and modify the argument name of the Patchwork1Project class' method to
match the one in the parent. Also fix the docstring about returned value
which didn't match what was actually being returned.

Signed-off-by: Veronika Kabatova <[email protected]>
It's assigned to None and never touched again. Just remove it.

Signed-off-by: Veronika Kabatova <[email protected]>
Seems like a legacy format was used here. pylint-3 is not a fan.

Signed-off-by: Veronika Kabatova <[email protected]>
We can't retrieve the data related to the project from the database
without having the project ID, for which we need the Patchwork project
interface. So figuring out the last patch before having the interface is
not possible. Remove the FIXMEs suggesting to do it.

Signed-off-by: Veronika Kabatova <[email protected]>
Throw an exception if the requested patch can't be retrieved. This was
already done for PatchworkV2Project but not PatchworkV1Project. Being
unable to retrieve a patch previously known as existing signals a
possible problem in sktm's logic, and it should be handled as such. The
unification also allows to remove the return value checks when this
method is used.

Signed-off-by: Veronika Kabatova <[email protected]>
@veruu
Copy link
Contributor Author

veruu commented Sep 3, 2018

@spbnick docs updated!

@spbnick spbnick merged commit 4194368 into cki-project:master Sep 4, 2018
@spbnick
Copy link
Contributor

spbnick commented Sep 4, 2018

Thank you, Veronika, and thank you for splitting the changes so nicely :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants