Commit d99ffd97 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Load annotators as resources in FailSafe annotator

parent 9e1b68db
Pipeline #18414 passed with stage
in 46 minutes and 56 seconds
import logging import logging
import six
from . import Annotator from . import Annotator
from .. import load_resource
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -21,7 +23,11 @@ class FailSafe(Annotator): ...@@ -21,7 +23,11 @@ class FailSafe(Annotator):
def __init__(self, annotators, required_keys, **kwargs): def __init__(self, annotators, required_keys, **kwargs):
super(FailSafe, self).__init__(**kwargs) super(FailSafe, self).__init__(**kwargs)
self.annotators = list(annotators) self.annotators = []
for annotator in annotators:
if isinstance(annotator, six.string_types):
annotator = load_resource(annotator, 'annotator')
self.annotators.append(annotator)
self.required_keys = list(required_keys) self.required_keys = list(required_keys)
def annotate(self, sample, **kwargs): def annotate(self, sample, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment