當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。