MCPcopy Create free account
hub / github.com/intelowlproject/IntelOwl / annotate_runnable

Method annotate_runnable

api_app/queryset.py:844–875  ·  view source on GitHub ↗

Annotates configurations indicating if they are runnable. Args: user (User, optional): The user to check. Defaults to None. Returns: PythonConfigQuerySet: The annotated queryset.

(self, user: User = None)

Source from the content-addressed store, hash-verified

842 )
843
844 def annotate_runnable(self, user: User = None) -> "PythonConfigQuerySet":
845 """
846 Annotates configurations indicating if they are runnable.
847
848 Args:
849 user (User, optional): The user to check. Defaults to None.
850
851 Returns:
852 PythonConfigQuerySet: The annotated queryset.
853 """
854 # we are excluding the plugins that has failed the health_check
855 qs = (
856 self.exclude(health_check_status=False)
857 # we save the `configured` attribute in the queryset
858 .annotate_configured(user)
859 )
860 return (
861 # this super call parameters are required
862 super(PythonConfigQuerySet, qs)
863 # we set the parent `runnable` attribute
864 .annotate_runnable(user)
865 # and we do the logic AND between the two fields
866 .annotate(
867 runnable=Exact(
868 # I have no idea how to do the compare
869 # of two boolean field in a subquery.
870 # this is the same as runnable =`configured` AND `runnable`
871 Cast(F("configured"), IntegerField()) * Cast(F("runnable"), IntegerField()),
872 1,
873 )
874 )
875 )
876
877 def get_signatures(self, job) -> Generator[Signature, None, None]:
878 """

Callers 10

test_get_signatureMethod · 0.45
test_runnable_validMethod · 0.45
_get_signaturesMethod · 0.45
pivots_to_executeMethod · 0.45
is_runnableMethod · 0.45
perform_retryMethod · 0.45

Calls 1

annotate_configuredMethod · 0.45