How to use omniduct - 10 common examples

To help you get started, we’ve selected a few omniduct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_separator(self):
        namespace = ParsedNamespaces.from_name(
            name='cat|my_db|my_table',
            namespaces=['catalog', 'database', 'table'],
            separator='|'
        )

        assert namespace.catalog == 'cat'
        assert namespace.database == 'my_db'
        assert namespace.table == 'my_table'
        assert namespace.as_dict() == {
            'catalog': 'cat',
            'database': 'my_db',
            'table': 'my_table'
        }
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_not_encapsulated(self):
        namespace = ParsedNamespaces.from_name('my_db.my_table', ['database', 'table'])
        assert namespace.as_dict() == {'database': 'my_db', 'table': 'my_table'}

        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(namespace, ['schema', 'table'])
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_not_encapsulated(self):
        namespace = ParsedNamespaces.from_name('my_db.my_table', ['database', 'table'])
        assert namespace.as_dict() == {'database': 'my_db', 'table': 'my_table'}

        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(namespace, ['schema', 'table'])
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_parsing_failure(self):
        with pytest.raises(ValueError):
            ParsedNamespaces.from_name(
                name='my_db.my_table',
                namespaces=['table']
            )
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_casting(self):
        namespace = ParsedNamespaces.from_name(
            name='my_db.my_table',
            namespaces=['catalog', 'database', 'table']
        )

        assert str(namespace) == '"my_db"."my_table"'
        assert bool(namespace) is True
        assert namespace.__bool__() == namespace.__nonzero__()  # Python 2/3 compatibility
        assert repr(namespace) == 'Namespace<"my_db"."my_table">'
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_nonexistent_namespace(self):
        with pytest.raises(AttributeError):
            ParsedNamespaces.from_name(
                name='my_table',
                namespaces=['table']
            ).database
github airbnb / omniduct / tests / databases / test__namespaces.py View on Github external
def test_empty(self):
        namespace = ParsedNamespaces.from_name("", ['database', 'table'])

        assert bool(namespace) is False
        assert namespace.database is None
        assert namespace.table is None
        assert str(namespace) == ''
        assert repr(namespace) == 'Namespace<>'
github airbnb / omniduct / omniduct / remotes / ssh_paramiko.py View on Github external
def _init(self):
        logger.warning("The Paramiko SSH client is still under development, \
                        and is not ready for use as a daily driver.")
github airbnb / omniduct / omniduct / databases / hiveserver2.py View on Github external
def _log_status(self, cursor, log_offset=0):
        matcher = re.compile('[0-9/]+ [0-9:]+ (INFO )?')

        if self.driver == 'pyhive':
            log = cursor.fetch_logs()
        else:
            log = cursor.get_log().strip().split('\n')

        for line in log[log_offset:]:
            if not line:
                continue
            m = matcher.match(line)
            if m:
                line = line[len(m.group(0)):]
            logger.info(line)

        return len(log)
github airbnb / omniduct / omniduct / caches / base.py View on Github external
# destructive (e.g. reading from cursors)
            return _cache.get(
                _key,
                namespace=_namespace,
                serializer=_serializer
            )
        except:
            logger.warning("Failed to save results to cache. If needed, please save them manually.")
            if config.cache_fail_hard:
                six.reraise(*sys.exc_info())
            return value  # As a last resort, return value object (which could be mutated by serialization).

    return wrapped


class Cache(Duct):
    """
    An abstract class providing the common API for all cache clients.
    """

    DUCT_TYPE = Duct.Type.CACHE

    @quirk_docs('_init', mro=True)
    def __init__(self, **kwargs):
        Duct.__init_with_kwargs__(self, kwargs)
        self._init(**kwargs)

    @abstractmethod
    def _init(self):
        pass

    # Data insertion and retrieval