Пример #1
0
    def _copy_symbol(symbols):
        for symbol in symbols:
            with ArcticTransaction(dest, symbol, USER, log) as mt:
                existing_data = dest.has_symbol(symbol)
                if existing_data:
                    if force:
                        logger.warn("Symbol: %s already exists in destination, OVERWRITING" % symbol)
                    elif splice:
                        logger.warn("Symbol: %s already exists in destination, splicing in new data" % symbol)
                    else:
                        logger.warn("Symbol: {} already exists in {}@{}, use --force to overwrite or --splice to join "
                                    "with existing data".format(symbol, _get_host(dest).get('l'),
                                                                _get_host(dest).get('mhost')))
                        continue

                version = src.read(symbol)
                new_data = version.data

                if existing_data and splice:
                    original_data = dest.read(symbol).data
                    preserve_start = to_pandas_closed_closed(DateRange(None, new_data.index[0].to_pydatetime(),
                                                                       interval=CLOSED_OPEN)).end
                    preserve_end = to_pandas_closed_closed(DateRange(new_data.index[-1].to_pydatetime(),
                                                                     None,
                                                                     interval=OPEN_CLOSED)).start
                    if not original_data.index.tz:
                        # No timezone on the original, should we even allow this?
                        preserve_start = preserve_start.replace(tzinfo=None)
                        preserve_end = preserve_end.replace(tzinfo=None)
                    before = original_data.loc[:preserve_start]
                    after = original_data[preserve_end:]
                    new_data = before.append(new_data).append(after)

                mt.write(symbol, new_data, metadata=version.metadata)
Пример #2
0
    def _copy_symbol(symbols):
        for symbol in symbols:
            with ArcticTransaction(dest, symbol, USER, log) as mt:
                existing_data = dest.has_symbol(symbol)
                if existing_data:
                    if force:
                        logger.warn("Symbol: %s already exists in destination, OVERWRITING" % symbol)
                    elif splice:
                        logger.warn("Symbol: %s already exists in destination, splicing in new data" % symbol)
                    else:
                        logger.warn("Symbol: {} already exists in {}@{}, use --force to overwrite or --splice to join "
                                    "with existing data".format(symbol, _get_host(dest).get('l'),
                                                                _get_host(dest).get('mhost')))
                        continue

                version = src.read(symbol)
                new_data = version.data

                if existing_data and splice:
                    original_data = dest.read(symbol).data
                    preserve_start = to_pandas_closed_closed(DateRange(None, new_data.index[0].to_pydatetime(),
                                                                       interval=CLOSED_OPEN)).end
                    preserve_end = to_pandas_closed_closed(DateRange(new_data.index[-1].to_pydatetime(),
                                                                     None,
                                                                     interval=OPEN_CLOSED)).start
                    if not original_data.index.tz:
                        # No timezone on the original, should we even allow this?
                        preserve_start = preserve_start.replace(tzinfo=None)
                        preserve_end = preserve_end.replace(tzinfo=None)
                    before = original_data.loc[:preserve_start]
                    after = original_data[preserve_end:]
                    new_data = before.append(new_data).append(after)

                mt.write(symbol, new_data, metadata=version.metadata)
Пример #3
0
    def _copy_symbol(symbols):
        for symbol in symbols:
            with ArcticTransaction(dest, symbol, USER, log) as mt:
                existing_data = dest.has_symbol(symbol)
                if existing_data:
                    if force:
                        logger.warn("Symbol: %s already exists in destination, OVERWRITING" % symbol)
                    elif splice:
                        logger.warn("Symbol: %s already exists in destination, splicing in new data" % symbol)
                    else:
                        logger.warn("Symbol: {} already exists in {}@{}, use --force to overwrite or --splice to join "
                                    "with existing data".format(symbol, _get_host(dest).get('l'),
                                                                _get_host(dest).get('mhost')))
                        continue

                version = src.read(symbol)
                new_data = version.data

                if existing_data and splice:
                    original_data = dest.read(symbol).data
                    before = original_data.ix[:to_pandas_closed_closed(DateRange(None,
                                                                                 new_data.index[0].to_pydatetime(),
                                                                                 interval=CLOSED_OPEN)).end]
                    after = original_data.ix[to_pandas_closed_closed(DateRange(new_data.index[-1].to_pydatetime(),
                                                                               None,
                                                                               interval=OPEN_CLOSED)).start:]
                    new_data = before.append(new_data).append(after)

                mt.write(symbol, new_data, metadata=version.metadata)
Пример #4
0
def test_get_host_list():
    store = Mock()
    store._arctic_lib.arctic.mongo_host = sentinel.host
    store._collection.database.client.nodes = set([('a', 12)])
    store._arctic_lib.get_name.return_value = sentinel.lib_name
    assert _get_host([store]) == {'mhost': 'sentinel.host',
                                 'mnodes': ['a:12'],
                                 'l': sentinel.lib_name,
                                 }
Пример #5
0
def test_get_host_list():
    store = Mock()
    store._arctic_lib.arctic.mongo_host = sentinel.host
    store._collection.database.client.nodes = set([('a', 12)])
    store._arctic_lib.get_name.return_value = sentinel.lib_name
    assert _get_host([store]) == {'mhost': 'sentinel.host',
                                 'mnodes': ['a:12'],
                                 'l': sentinel.lib_name,
                                 }
Пример #6
0
    def _copy_symbol(symbols):
        for symbol in symbols:
            with ArcticTransaction(dest, symbol, USER, log) as mt:
                existing_data = dest.has_symbol(symbol)
                if existing_data:
                    if force:
                        logger.warn(
                            "Symbol: %s already exists in destination, OVERWRITING"
                            % symbol)
                    elif splice:
                        logger.warn(
                            "Symbol: %s already exists in destination, splicing in new data"
                            % symbol)
                    else:
                        logger.warn(
                            "Symbol: {} already exists in {}@{}, use --force to overwrite or --splice to join with existing data"
                            .format(symbol,
                                    _get_host(dest).get('l'),
                                    _get_host(dest).get('mhost')))
                        continue

                version = src.read(symbol)
                new_data = version.data

                if existing_data and splice:
                    original_data = dest.read(symbol).data
                    before = original_data.ix[:to_pandas_closed_closed(
                        DateRange(None,
                                  new_data.index[0].to_pydatetime(),
                                  interval=CLOSED_OPEN)).end]
                    after = original_data.ix[to_pandas_closed_closed(
                        DateRange(new_data.index[-1].to_pydatetime(),
                                  None,
                                  interval=OPEN_CLOSED)).start:]
                    new_data = before.append(new_data).append(after)

                mt.write(symbol, new_data, metadata=version.metadata)
Пример #7
0
def test_get_host_VersionStore(library, mongo_host):
    assert _get_host(library) == {'mnodes': [mongo_host],
                                 'mhost': mongo_host,
                                 'l': u'arctic_test.TEST'}
Пример #8
0
def test_get_host_VersionStore(library, mongo_host):
    assert _get_host(library) == {"mnodes": [mongo_host], "mhost": mongo_host, "l": u"arctic_test.TEST"}
Пример #9
0
def test_get_host_not_a_vs():
    store = MagicMock()
    store._arctic_lib.get_name.side_effect = AttributeError("Hello")
    assert _get_host(store) == {}
    store._arctic_lib.get_name.side_effect = ValueError("Hello")
    assert _get_host(store) == {}
Пример #10
0
def test_get_host_not_a_vs():
    store = MagicMock()
    store._arctic_lib.get_name.side_effect = AttributeError("Hello")
    assert _get_host(store) == {}
    store._arctic_lib.get_name.side_effect = ValueError("Hello")
    assert _get_host(store) == {}