Skip to content

Commit

Permalink
kernelci.api.helper: enhance submit_regression()
Browse files Browse the repository at this point in the history
Make this function create the regression from the two nodes that define
the breaking point (the fail node and the previous pass node) and then
submit it. This abstracts all the model details and the logic behind the
regression generation away from the user code.

Signed-off-by: Ricardo Cañuelo <ricardo.canuelo@collabora.com>
  • Loading branch information
hardboprobot committed Feb 22, 2024
1 parent 4ff8f86 commit 124e397
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions kernelci/api/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,33 @@ def create_job_node(self, job_config, input_node,
except requests.exceptions.HTTPError as error:
raise RuntimeError(json.loads(error.response.text)) from error

def submit_regression(self, regression):
"""Post a regression object

[TODO] Leave this function in place in case we'll need any other
processing or formatting before submitting the regression node
"""
# pylint: disable=protected-access
return self.api._post('node', regression)
def submit_regression(self, fail_node: dict, pass_node: dict):

Check warning on line 140 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

too many blank lines (2)
"""Creates and submits a regression object from two existing

Check warning on line 141 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8

Check warning on line 141 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

indentation is not a multiple of 4
nodes (test or kbuilds) passed as parameters:
Arguments:
fail_node: dict describing the node that failed and triggered
the regression creation.
pass_node: dict describing the previous passing run of the same
test/build
General use case: failure detected, the fail_node and pass_node
are retrieved from the API and passed to this function to define
and submit a regression.
Returns the API request response.
"""
fail_node_obj = self.get_node_obj(fail_node)

Check warning on line 156 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8
pass_node_obj = self.get_node_obj(pass_node)

Check warning on line 157 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8
regression_dict = models.Regression.create_regression(

Check warning on line 158 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8
fail_node_obj, pass_node_obj, as_dict=True)

try:

Check warning on line 161 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8
return self.api.node.add(regression_dict)

Check warning on line 162 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 11 spaces, expected 12
except requests.exceptions.HTTPError as error:

Check warning on line 163 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 7 spaces, expected 8
raise RuntimeError(json.loads(error.response.text)) from error

Check warning on line 164 in kernelci/api/helper.py

View workflow job for this annotation

GitHub Actions / Lint

Bad indentation. Found 11 spaces, expected 12


def _prepare_results(self, results, parent, base):
node = results['node'].copy()
Expand Down

0 comments on commit 124e397

Please sign in to comment.