def iter_entry_points(self): from . import pitch_dtw, spcc, masked_spcc from pkg_resources import iter_entry_points as iep for ep in iep(self.entry_point_name): yield ep for name,cls in self.defaults: yield _entrypoint(name, cls)
def _load_class_entry_point(cls, group, name): entry_points = tuple(iep(group=group, name=name)) if not entry_points: return None class_entry_point = entry_points[0] loaded_class = class_entry_point.load() cls.app.logger.info("loaded entry point class %s:%s", group, class_entry_point.name) return loaded_class
def _load_pre_worker_entry_points(cls): try: server_config_class = cls._load_class_entry_point( "algorithm.serve.server_config", "config_api") if server_config_class: cls._server_config = server_config_class() except Exception: cls.app.logger.exception( "Unable to load server_config entry point") if cls._server_config is None: cls._server_config = BaseServerConfig() cls.app.logger.info("loading entry points") for entry_point in iep(group="algorithm.io.data_handlers.serve"): cls.request_iterators[entry_point.name] = entry_point.load() cls.app.logger.info("loaded request iterator %s", entry_point.name) for entry_point in iep(group="algorithm.request_iterators"): warnings.warn( "entrypoint algorithm.request_iterators is deprecated " "in favor of algorithm.io.data_handlers.serve", DeprecationWarning) cls.request_iterators[entry_point.name] = entry_point.load() cls.app.logger.info("loaded request iterator %s", entry_point.name) for entry_point in iep(group="algorithm.response_encoders"): cls.response_encoders[entry_point.name] = entry_point.load() cls.app.logger.info("loaded response encoder %s", entry_point.name) try: cls._model_class = cls._load_class_entry_point( "algorithm", "model") except Exception as e: raise_with_traceback( InferenceAlgorithmError( "Unable to load algorithm.model entry point", caused_by=e))
def iter_entry_points(self): from pkg_resources import iter_entry_points as iep for ep in iep(self.entry_point_name): yield ep for name, cls in self.defaults: yield _entrypoint(name, cls)