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

GSK-2617 Missing kwargs in a test make the whole suite fail #1748

Merged
merged 17 commits into from
Feb 8, 2024

Conversation

kevinmessiaen
Copy link
Member

@kevinmessiaen kevinmessiaen commented Jan 19, 2024

Description

Issue

When running a test suite, we do a validation that all the parameters have been set based on the typing annotation. (type is not Optional and no default value has been provided.

The problem is that the whole test Suite is cancelled if only one test is "misconfigured", furthermore it might happen that a required parameter is actually optional but the typing is wrong.

Solution

The validation now show a warning instead of an exception and run the Suite letting the test fail.

How to reproduce

Here is a small snippet that run a Suite with missing param

import giskard
from giskard.core.test_result import TestResult

@giskard.test()
def my_test(is_pass: bool, unused: int):
  return TestResult(passed=is_pass)

suite = giskard.Suite().add_test(my_test()).add_test(my_test(is_pass=True)).add_test(is_pass=True, unused=1)
result = suite.run()

Related Issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Copy link

linear bot commented Jan 19, 2024

Copy link

gitguardian bot commented Jan 19, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@@ -401,10 +401,6 @@ def run(self, verbose: bool = True, **suite_run_args):
run_args.update(suite_run_args)

results: List[(str, TestResult, Dict[str, Any])] = list()
required_params = self.find_required_params()
undefined_params = {k: v for k, v in required_params.items() if k not in run_args}
if len(undefined_params):
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's the same check in to_unittest that should be consistent with run

Copy link
Collaborator

Choose a reason for hiding this comment

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

why not keep the same check but convert an exception to a warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's right, a warning make a lot more sense especially with live logs now

@kevinmessiaen
Copy link
Member Author

kevinmessiaen commented Jan 30, 2024

@andreybavt I updated the Suite.run and Suite.to_unittest to now raise a warning in case of missing params.

@mattbit mattbit removed their request for review February 5, 2024 10:16
@kevinmessiaen kevinmessiaen changed the title GSK-2617 Missing kwargs in a test make the whole suite fail (Hub) GSK-2617 Missing kwargs in a test make the whole suite fail Feb 7, 2024
@vjern vjern self-requested a review February 7, 2024 11:31
Copy link
Contributor

@vjern vjern left a comment

Choose a reason for hiding this comment

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

I agree with the overall solution. +1 for early validation of required params, but it should not blockade the test suite being used, and it's worthwhile to still warn the user about it.

Feel free to commit or disregard my other nitpicks.

giskard/core/suite.py Outdated Show resolved Hide resolved
giskard/core/suite.py Outdated Show resolved Hide resolved
Co-authored-by: Jocelyn Vernay <59055698+vjern@users.noreply.github.com>
kevinmessiaen and others added 2 commits February 8, 2024 11:08
Co-authored-by: Jocelyn Vernay <59055698+vjern@users.noreply.github.com>
Copy link

sonarcloud bot commented Feb 8, 2024

@kevinmessiaen kevinmessiaen merged commit f6f9509 into main Feb 8, 2024
16 checks passed
@kevinmessiaen kevinmessiaen deleted the GSK-2617 branch February 8, 2024 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants