當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python distributed.Client.dump_cluster_state用法及代碼示例

用法:

dump_cluster_state(filename: str = 'dask-cluster-dump', exclude: collections.abc.Collection[str] =('run_spec',), format: Literal['msgpack', 'yaml'] = 'msgpack')

提取整個集群狀態的轉儲並保存到磁盤。這僅用於調試目的。

警告:客戶端的內存使用量可能很大。

結果將存儲在字典中:

{
    "scheduler_info": {...},
    "worker_info": {
        worker_addr: {...},  # worker attributes
        ...
    }
}

參數

filename:

輸出文件名。將自動附加適當的文件後綴(.msgpack.gz.yaml)。

exclude:

應該從轉儲中排除的屬性名稱的集合,例如排除代碼、回溯、日誌等。

默認排除 run_spec 這是序列化的用戶代碼。這通常不是調試所必需的。要允許對此進行序列化,請傳遞一個空元組。

format:

msgpack 或 yaml。如果使用 msgpack(默認),輸出將作為 msgpack 存儲在 gzip 壓縮文件中。

閱讀:

import gzip, msgpack
with gzip.open("filename") as fd:
    state = msgpack.unpack(fd)

或者:

import yaml
try:
    from yaml import CLoader as Loader
except ImportError:
    from yaml import Loader
with open("filename") as fd:
    state = yaml.load(fd, Loader=Loader)

相關用法


注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 distributed.Client.dump_cluster_state。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。