当前位置: 首页>>代码示例>>Python>>正文


Python arctic.Arctic方法代码示例

本文整理汇总了Python中arctic.Arctic方法的典型用法代码示例。如果您正苦于以下问题:Python arctic.Arctic方法的具体用法?Python arctic.Arctic怎么用?Python arctic.Arctic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arctic的用法示例。


在下文中一共展示了arctic.Arctic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def __init__(self, collection_name, mongo_db=None):


        if mongo_db is None:
            mongo_db = mongoDb()

        database_name = mongo_db.database_name
        host = mongo_db.host

        # Arctic doesn't accept a port

        store = Arctic(host)
        library_name = database_name+"."+collection_name
        store.initialize_library(library_name) # will this fail if already exists??
        library = store[library_name]

        self.database_name = database_name
        self.collection_name = collection_name
        self.host = host

        self.store = store
        self.library_name = library_name
        self.library = library 
开发者ID:robcarver17,项目名称:pysystemtrade,代码行数:25,代码来源:arctic_connection.py

示例2: test_multiprocessing_safety

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def test_multiprocessing_safety(mongo_host, library_name):
    # Create/initialize library at the parent process, then spawn children, and start them aligned in time
    total_processes = 64
    total_writes_per_child = 100

    register_get_auth_hook(my_auth_hook)

    global MY_ARCTIC
    MY_ARCTIC = Arctic(mongo_host=mongo_host)

    MY_ARCTIC.initialize_library(library_name, VERSION_STORE)
    assert isinstance(MY_ARCTIC.get_library(library_name), VersionStore)

    processes = [Process(target=f, args=(library_name, total_writes_per_child, True)) for _ in range(total_processes)]

    for p in processes:
        p.start()

    for p in processes:
        p.join()

    for p in processes:
        assert p.exitcode == 0

    assert isinstance(MY_ARCTIC.get_library(library_name), VersionStore) 
开发者ID:man-group,项目名称:arctic,代码行数:27,代码来源:test_arctic_multithreading.py

示例3: __init__

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def __init__(self, TYPE):
        """
        :param TYPE: 'BS', 'IS', 'CF'
        """

        ############ SETTING #############
        self.config = GetConfig()
        self.TYPE = TYPE # 'BS', 'IS', 'CF'
        self.MONGO = self.config.MONGO
        self.CSV = self.config.CSV
        self.RAW = False
        self.outdir = self.config.fund_dir
        self.encode = self.config.encode
        self.proxypool = self.config.proxypool

        ############ CHANGE ABOVE SETTING #############

        if self.MONGO:
            from arctic import Arctic
            # mongod --dbpath D:/idwzx/project/arctic
            a = Arctic(self.config.ahost)
            a.initialize_library('ashare_{}'.format(self.TYPE))
            self.lib = a['ashare_{}'.format(self.TYPE)]

        self.result_dict = {} 
开发者ID:quantasset,项目名称:factorset,代码行数:27,代码来源:FundCrawler.py

示例4: loader_func

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def loader_func(**kwargs):
    try:
        from arctic import Arctic
        from arctic.store.versioned_item import VersionedItem
    except ImportError:
        raise ImportError("In order to use the arctic loader you must install arctic!")
    host = Arctic(kwargs.get("host"))
    lib = host.get_library(kwargs.get("library"))
    read_kwargs = {}
    start, end = (kwargs.get(p) for p in ["start", "end"])
    if start and end:
        read_kwargs["chunk_range"] = pd.date_range(start, end)
    data = lib.read(kwargs.get("node"), **read_kwargs)
    if isinstance(data, VersionedItem):
        data = data.data
    return data


# IMPORTANT!!! This function is required for building any customized CLI loader. 
开发者ID:man-group,项目名称:dtale,代码行数:21,代码来源:arctic_loader.py

示例5: find_loader

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def find_loader(kwargs):
    """
    Arctic implementation of data loader which will return a function if any of the
    `click` options based on LOADER_KEY & LOADER_PROPS have been used, otherwise return None

    :param kwargs: Optional keyword arguments to be passed from `click`
    :return: data loader function for arctic implementation
    """
    arctic_opts = get_loader_options(LOADER_KEY, kwargs)
    if len([f for f in arctic_opts.values() if f]):

        def _arctic_loader():
            return loader_func(**arctic_opts)

        return _arctic_loader
    return None 
开发者ID:man-group,项目名称:dtale,代码行数:18,代码来源:arctic_loader.py

示例6: write_to_db

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def write_to_db(target_building, iterator):
    '''write the data from a building'''

    conn = Arctic('localhost')

    #create a lib for the tgt_bldg, a lib is akin to a collection
    if target_building not in conn.list_libraries():
        conn.initialize_library(target_building, lib_type=CHUNK_STORE)
        print ('library for %s created'%target_building)

    #connect to the lib for writing
    lib = conn[target_building]

    for sensor, timestamps, data in iterator:
        df = pd.DataFrame({'date': timestamps, 'data': data})
        df.set_index('date', inplace=True)
        lib.write(sensor, df)
        #print ('writing %s is done'%sensor) 
开发者ID:plastering,项目名称:plastering,代码行数:20,代码来源:timeseries_interface.py

示例7: get_store

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def get_store():
    """
    get Arctic store connection
    :return: arctic connection
    """

    mongo_host = conf.MONGO_HOST
    store = arctic.Arctic(mongo_host)
    return store 
开发者ID:pandalibin,项目名称:backtrader-cn,代码行数:11,代码来源:models.py

示例8: setup

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def setup(self, arg):
        self.store = Arctic("127.0.0.1")
        self.store.delete_library('test.lib')
        self.store.initialize_library('test.lib')
        self.lib = self.store['test.lib'] 
开发者ID:man-group,项目名称:arctic,代码行数:7,代码来源:benchmarks.py

示例9: __init__

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def __init__(self):
        self.store = Arctic("127.0.0.1") 
开发者ID:man-group,项目名称:arctic,代码行数:4,代码来源:benchmarks.py

示例10: insert_random_data

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def insert_random_data(config, args, n_rows):
    store = Arctic(args.mongodb, app_name="benchmark")
    lib_name = lib_name_from_args(config)
    store.delete_library(lib_name)
    store.initialize_library(lib_name, segment='month')
    lib = store[lib_name]

    for sym in range(args.symbols):
        df = gen_oneminute_dataset(n_row=n_rows, n_col=n_rows, dense=args.dense)
        lib.write('sym' + str(sym), df) 
开发者ID:man-group,项目名称:arctic,代码行数:12,代码来源:fwd_benchmarks.py

示例11: append_random_rows

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def append_random_rows(config, args, n_rows):
    store = Arctic(args.mongodb, app_name="benchmark")
    lib_name = lib_name_from_args(config)

    lib = store[lib_name]

    for _ in range(args.appends):
        for sym in range(args.symbols):
            df = gen_oneminute_dataset(n_row=APPEND_NROWS, n_col=n_rows, dense=False)
            lib.append('sym' + str(sym), df) 
开发者ID:man-group,项目名称:arctic,代码行数:12,代码来源:fwd_benchmarks.py

示例12: test_multiprocessing_safety_parent_children_race

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def test_multiprocessing_safety_parent_children_race(mongo_host, library_name):
    # Create Arctic and directly fork/start children (no wait)
    total_iterations = 12
    total_processes = 6
    total_writes_per_child = 20

    global MY_ARCTIC

    for i in range(total_iterations):
        processes = list()

        MY_ARCTIC = Arctic(mongo_host=mongo_host)
        for j in range(total_processes):
            p = Process(target=f, args=(library_name, total_writes_per_child, False))
            p.start()  # start directly, don't wait to create first all children procs
            processes.append(p)

        MY_ARCTIC.initialize_library(library_name, VERSION_STORE)  # this will unblock spinning children

        for p in processes:
            p.join()

        for p in processes:
            assert p.exitcode == 0

        MY_ARCTIC.reset()

    assert isinstance(MY_ARCTIC.get_library(library_name), VersionStore) 
开发者ID:man-group,项目名称:arctic,代码行数:30,代码来源:test_arctic_multithreading.py

示例13: test_enable_sharding

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def test_enable_sharding():
    arctic_lib = create_autospec(ArcticLibraryBinding)
    arctic_lib.arctic = create_autospec(Arctic)
    with patch('arctic.store.bson_store.enable_sharding', autospec=True) as enable_sharding:
        arctic_lib.get_top_level_collection.return_value.database.create_collection.__name__ = 'some_name'
        arctic_lib.get_top_level_collection.return_value.database.collection_names.__name__ = 'some_name'
        bsons = BSONStore(arctic_lib)
        bsons.enable_sharding()
        # Check we always set the sharding to be hashed.
        assert enable_sharding.call_args_list == [call(arctic_lib.arctic, arctic_lib.get_name(), hashed=True, key='_id')] 
开发者ID:man-group,项目名称:arctic,代码行数:12,代码来源:test_bson_store.py

示例14: arctic

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def arctic(mongo_server_module):
    disable_arctic_cache(mongo_server_module.api)
    mongo_server_module.api.drop_database("arctic")
    mongo_server_module.api.drop_database("arctic_{}".format(getpass.getuser()))
    return Arctic(mongo_server_module.api) 
开发者ID:man-group,项目名称:dtale,代码行数:7,代码来源:conftest.py

示例15: open

# 需要导入模块: import arctic [as 别名]
# 或者: from arctic import Arctic [as 别名]
def open(self, store='chunkstore'):
		self.db = Arctic('localhost')
		try:
			self.store = self.db[store]
		except:
			self.db.initialize_library(store, lib_type=CHUNK_STORE)
			self.store = self.db[store]
			self.store._arctic_lib.set_quota(maxDBStorage * 1024 * 1024 * 1024) 
开发者ID:Zvezdin,项目名称:blockchain-predictor,代码行数:10,代码来源:arctic_store_database.py


注:本文中的arctic.Arctic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。