python里的integer_Python traitlets.Integer方法代码示例

# 需要导入模块: import traitlets [as 别名]

# 或者: from traitlets import Integer [as 别名]

def test_cluster_options_client_config(monkeypatch):

monkeypatch.setenv("TEST_OPTION_TWO", "large")

config = Config()

config.InProcessBackend.cluster_config_class = MyClusterConfig

config.InProcessBackend.cluster_options = options.Options(

options.Integer("option_one", default=1, min=1, max=4, target="option_one_b"),

options.Select("option_two", options=[("small", 1.5), ("large", 15)]),

)

async with temp_gateway(config=config) as g:

async with g.gateway_client() as gateway:

with dask.config.set(gateway__cluster__options={"option_one": 2}):

# Local config can override

opts = await gateway.cluster_options()

assert opts.option_one == 2

assert opts.option_two == "small"

# Without local config, uses server-side defaults

opts = await gateway.cluster_options(use_local_defaults=False)

assert opts.option_one == 1

assert opts.option_two == "small"

with dask.config.set(

gateway__cluster__options={"option_two": "{TEST_OPTION_TWO}"}

):

# Values can format from environment variables

opts = await gateway.cluster_options()

assert opts.option_one == 1

assert opts.option_two == "large"

with dask.config.set(

gateway__cluster__options={

"option_two": "{TEST_OPTION_TWO}",

"option_one": 3,

}

):

# Defaults are merged with kwargs to new_cluster

async with gateway.new_cluster(option_one=2) as cluster:

report = await gateway.get_cluster(cluster.name)

assert report.options == {"option_one": 2, "option_two": "large"}

# If passing `cluster_options`, defaults are assumed already applied

opts = await gateway.cluster_options()

opts.option_two = "small"

async with gateway.new_cluster(opts) as cluster:

report = await gateway.get_cluster(cluster.name)

assert report.options == {"option_one": 3, "option_two": "small"}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值