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


Python addict.Dict方法代码示例

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


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

示例1: resourceOffers

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def resourceOffers(self, driver, offers):
        filters = {'refuse_seconds': 5}

        for offer in offers:
            cpus = self.getResource(offer.resources, 'cpus')
            mem = self.getResource(offer.resources, 'mem')
            if cpus < TASK_CPU or mem < TASK_MEM:
                continue

            task = Dict()
            task_id = str(uuid.uuid4())
            task.task_id.value = task_id
            task.agent_id.value = offer.agent_id.value
            task.name = 'task {}'.format(task_id)
            task.executor = self.executor
            task.data = encode_data('Hello from task {}!'.format(task_id))

            task.resources = [
                dict(name='cpus', type='SCALAR', scalar={'value': TASK_CPU}),
                dict(name='mem', type='SCALAR', scalar={'value': TASK_MEM}),
            ]

            driver.launchTasks(offer.id, [task], filters) 
开发者ID:douban,项目名称:pymesos,代码行数:25,代码来源:scheduler.py

示例2: launchTask

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def launchTask(self, driver, task):
        def run_task(task):
            update = Dict()
            update.task_id.value = task.task_id.value
            update.state = 'TASK_RUNNING'
            update.timestamp = time.time()
            driver.sendStatusUpdate(update)

            print(decode_data(task.data), file=sys.stderr)
            time.sleep(30)

            update = Dict()
            update.task_id.value = task.task_id.value
            update.state = 'TASK_FINISHED'
            update.timestamp = time.time()
            driver.sendStatusUpdate(update)

        thread = Thread(target=run_task, args=(task,))
        thread.start() 
开发者ID:douban,项目名称:pymesos,代码行数:21,代码来源:executor.py

示例3: __init__

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def __init__(self, sched, framework, master_uri,
                 use_addict=False, implicit_acknowledgements=True,
                 principal=None, secret=None, failover=False,
                 timeout=DAY):
        super(MesosSchedulerDriver, self).__init__(timeout=timeout)
        self.sched = sched
        self.master_uri = master_uri
        self._framework = framework
        self.detector = None
        self._conn = None
        self.version = None
        self._failover = failover
        self._dict_cls = Dict if use_addict else dict
        self.implicit_acknowledgements = implicit_acknowledgements
        if principal is not None and secret is not None:
            self._basic_credential = 'Basic %s' % (
                b2a_base64(
                    ('%s:%s' % (principal, secret)).encode('ascii')
                ).decode('ascii').strip()
            )
        else:
            self._basic_credential = None 
开发者ID:douban,项目名称:pymesos,代码行数:24,代码来源:scheduler.py

示例4: make_fake_offer

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def make_fake_offer(
    cpu=50000, mem=50000, port_begin=31000, port_end=32000, pool="default"
):
    offer = Dict(
        agent_id=Dict(value="super_big_slave"),
        resources=[
            Dict(name="cpus", scalar=Dict(value=cpu)),
            Dict(name="mem", scalar=Dict(value=mem)),
            Dict(
                name="ports", ranges=Dict(range=[Dict(begin=port_begin, end=port_end)])
            ),
        ],
        attributes=[],
    )

    if pool is not None:
        offer.attributes = [Dict(name="pool", text=Dict(value=pool))]

    return offer 
开发者ID:Yelp,项目名称:paasta,代码行数:21,代码来源:test_adhoc_scheduler.py

示例5: test_user_long

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def test_user_long(db_session):
    test_user = (
        db_session.query(models.User)
        .filter_by(username="test_amazing_user_with_an_fancy_but_extremely_long_name")
        .first()
    )
    if not test_user:
        test_user = models.User(
            username="test_amazing_user_with_an_fancy_but_extremely_long_name",
            is_admin=False,
        )
        db_session.add(test_user)
        db_session.commit()
    return Dict(
        username="test_amazing_user_with_an_fancy_but_extremely_long_name",
        user_id=test_user.id,
    ) 
开发者ID:uc-cdis,项目名称:fence,代码行数:19,代码来源:conftest.py

示例6: oauth_client_public

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def oauth_client_public(app, db_session, oauth_user):
    """
    Create a public OAuth2 client.
    """
    url = "https://oauth-test-client-public.net"
    client_id = "test-client-public"
    test_user = db_session.query(models.User).filter_by(id=oauth_user.user_id).first()
    db_session.add(
        models.Client(
            client_id=client_id,
            user=test_user,
            allowed_scopes=["openid", "user", "fence"],
            redirect_uris=[url],
            description="",
            is_confidential=False,
            name="testclient-public",
            grant_types=["authorization_code", "refresh_token"],
        )
    )
    db_session.commit()
    return Dict(client_id=client_id, url=url) 
开发者ID:uc-cdis,项目名称:fence,代码行数:23,代码来源:conftest.py

示例7: encoded_jwt_no_proxy_group

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def encoded_jwt_no_proxy_group(kid, rsa_private_key, user_client, oauth_client):
    """
    Return a JWT and user_id for a new user containing the claims and
    encoded with the private key.
    Args:
        claims (dict): fixture
        rsa_private_key (str): fixture
    Return:
        str: JWT containing claims encoded with private key
    """
    headers = {"kid": kid}
    return Dict(
        jwt=jwt.encode(
            utils.authorized_download_credentials_context_claims(
                user_client["username"],
                user_client["user_id"],
                oauth_client["client_id"],
            ),
            key=rsa_private_key,
            headers=headers,
            algorithm="RS256",
        ).decode("utf-8"),
        user_id=user_client["user_id"],
        client_id=oauth_client["client_id"],
    ) 
开发者ID:uc-cdis,项目名称:fence,代码行数:27,代码来源:conftest.py

示例8: new_tissue_rna

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def new_tissue_rna(*args, **kwargs):
        rna = Dict(*args, **kwargs)

        if 'level' not in rna:
            rna.level = -1

        if 'value' not in rna:
            rna.value = 0

        if 'unit' not in rna:
            rna.unit = ''

        if 'zscore' not in rna:
            rna.zscore = -1

        return rna 
开发者ID:opentargets,项目名称:data_pipeline,代码行数:18,代码来源:HPA.py

示例9: extractConfig

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def extractConfig(config_path):
    return Dict(yaml.load(open(config_path))) 
开发者ID:dmechea,项目名称:PanopticSegmentation,代码行数:4,代码来源:semanticSegmentation.py

示例10: decodeSegmentationResults

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def decodeSegmentationResults(result_list):
    decoded_results = []
    for result in result_list:
        result_copy = Dict(result)
        encodedCounts = result_copy.segmentation.counts
        result_copy.segmentation.counts = encodedCounts.decode('utf8')

        decoded_results.append(result_copy)

    return decoded_results 
开发者ID:dmechea,项目名称:PanopticSegmentation,代码行数:12,代码来源:semanticSegmentation.py

示例11: convertClassesForPanoptic

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def convertClassesForPanoptic(result_list):
    converted_results = []
    for result in result_list:
        result_copy = Dict(result)
        categoryClass = result_copy.category_id
        panopticIndex = convertStuffIdToPanopticId(categoryClass)
        if panopticIndex is not None:
            result_copy.category_id = panopticIndex
            converted_results.append(result_copy)
        else:
            print ('No index, skipping')
    return converted_results 
开发者ID:dmechea,项目名称:PanopticSegmentation,代码行数:14,代码来源:semanticSegmentation.py

示例12: _extract_item

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def _extract_item(self, item):
        return dictlib.Dict(item) 
开发者ID:openrca,项目名称:orca,代码行数:4,代码来源:client.py

示例13: parse

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def parse(self, config_path):
        config_dict = file_utils.load_yaml(config_path)
        validator = cerberus.Validator(self._schema)
        is_valid = validator.validate(config_dict)
        if not is_valid:
            raise exceptions.ConfigParseError(errors=validator.errors)
        return dict_lib.Dict(validator.document) 
开发者ID:openrca,项目名称:orca,代码行数:9,代码来源:config.py

示例14: __init__

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def __init__(self, id, properties, **kwargs):
        super().__init__()
        self.id = id
        self.properties = dictlib.Dict(properties)
        self.created_at = kwargs.get('created_at')
        self.updated_at = kwargs.get('updated_at')
        self.deleted_at = kwargs.get('deleted_at') 
开发者ID:openrca,项目名称:orca,代码行数:9,代码来源:graph.py

示例15: main

# 需要导入模块: import addict [as 别名]
# 或者: from addict import Dict [as 别名]
def main(master):
    executor = Dict()
    executor.executor_id.value = 'MinimalExecutor'
    executor.name = executor.executor_id.value
    executor.command.value = '%s %s' % (
        sys.executable,
        abspath(join(dirname(__file__), 'executor.py'))
    )
    executor.resources = [
        dict(name='mem', type='SCALAR', scalar={'value': EXECUTOR_MEM}),
        dict(name='cpus', type='SCALAR', scalar={'value': EXECUTOR_CPUS}),
    ]

    framework = Dict()
    framework.user = getpass.getuser()
    framework.name = "MinimalFramework"
    framework.hostname = socket.gethostname()

    driver = MesosSchedulerDriver(
        MinimalScheduler(executor),
        framework,
        master,
        use_addict=True,
    )

    def signal_handler(signal, frame):
        driver.stop()

    def run_driver_thread():
        driver.run()

    driver_thread = Thread(target=run_driver_thread, args=())
    driver_thread.start()

    print('Scheduler running, Ctrl+C to quit.')
    signal.signal(signal.SIGINT, signal_handler)

    while driver_thread.is_alive():
        time.sleep(1) 
开发者ID:douban,项目名称:pymesos,代码行数:41,代码来源:scheduler.py


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