def __init__(self, panoptes_context, plugin_type, plugin_type_display_name, celery_config, lock_timeout, plugin_scheduler_task, plugin_subtype=None): assert PanoptesContextValidators.valid_panoptes_context( panoptes_context), u'panoptes_context must be an instance of PanoptesContext' assert PanoptesValidators.valid_nonempty_string(plugin_type), u'plugin_type must be a non-empty str' assert PanoptesValidators.valid_nonempty_string(plugin_type_display_name), \ u'plugin_type_display_name must be a non-empty str' assert PanoptesCeleryValidators.valid_celery_config( celery_config), u'celery_config must be an instance of PanoptesCeleryConfig' assert PanoptesValidators.valid_nonzero_integer(lock_timeout), u'lock_timeout must be an int greater than zero' assert PanoptesValidators.valid_callback(plugin_scheduler_task), u'plugin_scheduler_task must be a callable' assert plugin_type is None or PanoptesValidators.valid_nonempty_string(plugin_type), u'plugin_type must be a ' \ u'None or a non-empty str' self._panoptes_context = panoptes_context self._config = self._panoptes_context.config_dict self._logger = self._panoptes_context.logger self._shutdown_plugin_scheduler = threading.Event() self._plugin_scheduler_celery_beat_service = None self._celery_config = celery_config self._celery = None self._t = None self._lock = None self._plugin_type = plugin_type self._plugin_subtype = plugin_subtype self._plugin_type_display_name = plugin_type_display_name self._lock_timeout = lock_timeout self._plugin_scheduler_task = plugin_scheduler_task self._tour_of_duty = PanoptesTourOfDuty(splay_percent=50) self._cycles_without_lock = 0
def __init__(self, plugin_name, plugin_type, plugin_class, plugin_info_class, plugin_data, panoptes_context, plugin_agent_kv_store_class, plugin_kv_store_class, plugin_secrets_store_class, plugin_logger_name, plugin_result_class, results_callback): assert PanoptesValidators.valid_nonempty_string( plugin_name), u'plugin_name must be a non-empty string' assert PanoptesValidators.valid_nonempty_string( plugin_type), u'plugin_type must be a non-empty string' assert PanoptesBasePluginValidators.valid_plugin_class( plugin_class ), u'plugin_class must be instance of PanoptesBasePlugin' assert PanoptesPluginInfoValidators.valid_plugin_info_class( plugin_info_class ), u'plugin_info_class must be instance of PanoptesPluginInfo' assert PanoptesValidators.valid_hashable_object( plugin_data), u'plugin_data must be a valid hashable object' assert PanoptesKeyValueStoreValidators.valid_kv_store_class( plugin_kv_store_class ), u'plugin_kv_store_class must be a subclass of PanoptesKeyValueStore' assert PanoptesKeyValueStoreValidators.valid_kv_store_class( plugin_secrets_store_class ), u'plugin_secrets_store_class must be a subclass of PanoptesKeyValueStore' assert PanoptesValidators.valid_nonempty_string(plugin_logger_name), u'plugin_logger_name must be a non-empty '\ u'string' assert PanoptesValidators.valid_callback( results_callback), u'plugin_callback must be a callable' self._plugin_name = plugin_name self._plugin_type = plugin_type self._plugin_class = plugin_class self._plugin_info_class = plugin_info_class self._plugin_data = plugin_data self._panoptes_context = panoptes_context self._plugin_agent_kv_store_class = plugin_agent_kv_store_class self._plugin_secrets_store_class = plugin_secrets_store_class self._plugin_kv_store_class = plugin_kv_store_class self._plugin_logger_name = plugin_logger_name self._logger = self._panoptes_context.logger self._plugin_result_class = plugin_result_class self._results_callback = weakref.proxy(results_callback)
def test_valid_callback(self): self.assertFalse(PanoptesValidators.valid_callback(object())) self.assertTrue(PanoptesValidators.valid_callback(object.__init__))