Skip to content

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
@gitguardian
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!

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
Contributor

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
Contributor

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) 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.

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>
@kevinmessiaen kevinmessiaen merged commit f6f9509 into main Feb 8, 2024
@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

4 participants