示例#1
0
def _wrap_operators_in_symtab(symtab):
    for name, impl in symtab.items():
        if (inspect.isclass(impl) and not issubclass(impl, Operator)
                and (hasattr(impl, 'predict') or hasattr(impl, 'transform'))):
            module = impl.__module__.split('.')[0]
            klass = impl.__name__
            try:
                m = importlib.import_module('lale.lib.' + module)
                symtab[name] = clone_op(getattr(m, klass), name)
                logger.info(f'Lale:Wrapped known operator:{name}')
            except (ModuleNotFoundError, AttributeError):
                try:
                    m = importlib.import_module('lale.lib.autogen')
                    symtab[name] = clone_op(getattr(m, klass), name)
                    logger.info(f'Lale:Wrapped autogen operator:{name}')
                except (ModuleNotFoundError, AttributeError):
                    if hasattr(impl, 'fit') and (hasattr(impl, 'predict') or
                                                 hasattr(impl, 'transform')):
                        logger.info(f'Lale:Wrapped unkwnown operator:{name}')
                        symtab[name] = make_operator(impl=impl, name=name)
示例#2
0
def _wrap_operators_in_symtab(symtab):
    for name, impl in symtab.items():
        if (inspect.isclass(impl) and not issubclass(impl, Operator)
                and (hasattr(impl, "predict") or hasattr(impl, "transform"))):
            operator = get_op_from_lale_lib(impl)
            if operator is None:
                symtab[name] = make_operator(impl=impl, name=name)
                logger.info(f"Lale:Wrapped unkwnown operator:{name}")
            else:
                symtab[name] = clone_op(operator, name)
                if operator.class_name().startswith("lale.lib.autogen"):
                    logger.info(f"Lale:Wrapped autogen operator:{name}")
                else:
                    logger.info(f"Lale:Wrapped known operator:{name}")
示例#3
0
文件: grammar.py 项目: krprls/lale
 def __getattr__(self, name):
     if name.startswith('_'):
         return self.__dict__[name]
     if name not in self._variables:
         self._variables[name] = NonTerminal(name)
     return clone_op(self._variables[name])