Adding Custom Checks
The q2 check command can be extended with custom checks that are specific to your application.
Adding a check is as simple as creating a subclass of q2_sdk.tools.custom_checks.CustomCheck,
providing a descriptive message and implementing the check method. Two methods are provided
to provide feedback: print_pass_msg``and ``print_fail_msg. The check should return True if
the check passes and False if it fails.
Here’s a simple example of a custom check:
# configuration/checks/my_custom_check.py
from q2_sdk.tools.custom_checks import CustomCheck
class MyCustomCheck(CustomCheck):
msg = "Checking some condition"
def check(self) -> bool:
# Perform your custom check logic here
if some_condition_is_met:
self.print_pass_msg("The check has been checked")
return True
else:
self.print_fail_msg("The check has failed", suggested_fix="Try something else")
return False
To register your custom check, you need to add it to the CUSTOM_CHECKS list in
configuration/settings.py.
# configuration/settings.py
from configuration.checks.my_custom_check import MyCustomCheck
CUSTOM_CHECKS = [
MyCustomCheck,
# Add other custom checks here
]
When you run q2 check, your custom checks will be executed along with the built-in checks.