Beispiel #1
0
 def dispatch_task(self, task):
     collection = get_dataset_collection_id(task.job.dataset.name)
     if collection is not None:
         collection = Collection.by_id(collection, deleted=True)
     handler = get_entry_point("aleph.task_handlers", task.stage.stage)
     if handler is None:
         raise RuntimeError(f"Invalid task handler: {task.stage}")
     log.info(f"Task [{task.job.dataset}]: {task.stage.stage} (started)")
     handler(collection, task)
     log.info(f"Task [{task.job.dataset}]: {task.stage.stage} (done)")
Beispiel #2
0
 def method(self):
     # method A: via a named Python entry point
     func = get_entry_point('memorious.operations', self.method_name)
     if func is not None:
         return func
     # method B: direct import from a module
     if ':' not in self.method_name:
         raise ValueError("Unknown method: %s", self.method_name)
     package, method = self.method_name.rsplit(':', 1)
     module = import_module(package)
     return getattr(module, method)
Beispiel #3
0
 def dispatch_task(self, collection, task):
     handler = get_entry_point("aleph.task_handlers", task.stage.stage)
     if handler is None:
         log.warning(
             "Task handler not found for task [%s]: %s",
             task.job.dataset,
             task.stage.stage,
         )
         return
     handler(collection, task)
     log.info("Task [%s]: %s (done)", task.job.dataset, task.stage.stage)
Beispiel #4
0
 def dispatch_task(self, task):
     collection = get_dataset_collection_id(task.job.dataset.name)
     if collection is not None:
         collection = Collection.by_id(collection, deleted=True)
     handler = get_entry_point("aleph.task_handlers", task.stage.stage)
     if handler is None:
         log.warning(
             f"Task handler not found for task [task.job.dataset]: task.stage.stage",
         )
         return
     log.info(f"Task [{task.job.dataset}]: {task.stage.stage} (started)")
     handler(collection, task)
     log.info(f"Task [{task.job.dataset}]: {task.stage.stage} (done)")
Beispiel #5
0
 def aggregator_method(self):
     if self.aggregator_config:
         method = self.aggregator_config.get("method")
         if not method:
             return
         # method A: via a named Python entry point
         func = get_entry_point("memorious.operations", method)
         if func is not None:
             return func
         # method B: direct import from a module
         if ":" in method:
             package, method = method.rsplit(":", 1)
             module = import_module(package)
             return getattr(module, method)
         raise ValueError("Unknown method: %s", self.method_name)
Beispiel #6
0
def handle_oauth(provider, oauth_token):
    handler = get_entry_point('aleph.oauth', settings.OAUTH_HANDLER)
    if handler is not None:
        return handler(provider, oauth_token)