跳转到主要内容

Python gRPC函数用于Rainbow调度器

项目描述

rainbow (python)

🌈️ 这里是keebler精灵和调度器居住的地方,在云中,还有棉花糖

https://github.com/converged-computing/rainbow/raw/main/docs/img/rainbow.png

这是rainbow调度器原型,具体是gRPC客户端的Python绑定。要了解更多关于rainbow的信息,请访问https://github.com/converged-computing/rainbow

示例

假设您可以使用Go运行服务器,让我们首先做那(例如,从上面链接的存储库的根目录,我们很快将提供一个容器)

注册

make server
go run cmd/server/server.go
2024/02/12 19:38:58 creating 🌈️ server...
2024/02/12 19:38:58 ✨️ creating rainbow.db...
2024/02/12 19:38:58    rainbow.db file created
2024/02/12 19:38:58    create cluster table...
2024/02/12 19:38:58    cluster table created
2024/02/12 19:38:58    create jobs table...
2024/02/12 19:38:58    jobs table created
2024/02/12 19:38:58 starting scheduler server: rainbow v0.1.0-draft
2024/02/12 19:38:58 server listening: [::]:50051

然后让我们进行注册,但这次是从这里的Python绑定(客户端)!我们将使用rainbow/client.py中的核心绑定,但运行来自examples的自定义命令。假设您已经将所有内容安装到venv中

python -m venv env
source env/bin/activate
pip install -e .

下面的命令将注册并保存密钥到一个新的配置文件中。请注意,如果您提供现有的一个,它将使用或更新它。

python ./examples/flux/register.py keebler --config-path ./rainbow-config.yaml
Saving rainbow config to ./rainbow-config.yaml
🤫️ The token you will need to submit jobs to this cluster is rainbow
🔐️ The secret you will need to accept jobs is 649598a9-e77b-4aa3-ab46-bfbbc5e2d606

再试一次 - 您不能两次注册一个集群。但当然,您也可以注册其他集群名称。一个“集群”实际上可以是一个集群,一个flux实例,或者任何可以接受作业的实体。脚本也接受参数(请参阅register.py --help

python ./examples/flux/register.py --help

🌈️ Rainbow scheduler register

options:
  -h, --help            show this help message and exit
  --cluster CLUSTER     cluster name to register
  --host HOST           host of rainbow cluster
  --secret SECRET       Rainbow cluster registration secret
  --config-path CONFIG_PATH
                        Path to rainbow configuration file to write or use
  --cluster-nodes CLUSTER_NODES
                        Nodes to provide for registration

注册子系统

现在让我们注册子系统。类似于注册,它将子系统节点的路径设置为默认值,并将--subsystem设置为“io。”这假设您已注册集群,并在./rainbow-config.yaml中有集群密钥

python ./examples/flux/register-subsystem.py keebler --config-path ./rainbow-config.yaml
status: REGISTER_SUCCESS

在服务器窗口中,您将看到已添加的子系统。

...
2024/03/09 14:21:50 📝️ received subsystem register: keebler
2024/03/09 14:21:50 Preparing to load 6 nodes and 30 edges
2024/03/09 14:21:50 We have made an in memory graph (subsystem io) with 7 vertices, with 15 connections to the dominant!
{
 "keebler": {
  "Name": "keebler",
  "Counts": {
   "io": 1,
   "mtl1unit": 1,
   "mtl2unit": 1,
   "mtl3unit": 1,
   "nvme": 1,
   "shm": 1
  }
 }
}

更新状态

虽然我们可能会在它们接受作业时从集群发送状态,但现在我们有一个单独的端点来执行一次性请求以更新状态。您可以在这里进行测试。

python ./examples/flux/update-state.py keebler --config-path ./rainbow-config.yaml
status: UPDATE_STATE_SUCCESS

在服务器终端(取决于您的日志级别)中,您将看到状态更新。

2024/04/05 18:45:16 We have made an in memory graph (subsystem io) with 7 vertices, with 15 connections to the dominant!
Metrics for subsystem io{
 "io": 1,
 "mtl1unit": 1,
 "mtl2unit": 1,
 "mtl3unit": 1,
 "nvme": 1,
 "shm": 1
}
2024/04/05 18:47:18 📝️ received state update: keebler
Updating state cost-per-node to 12
Updating state max-jobs to 100

请注意,状态元数据文件的路径作为默认值提供,以简化演示。此状态元数据将提供给选择算法,以便根据需要用于为最终集群做出选择。

提交作业(简单)

现在让我们向我们的模拟集群提交一个作业。我们需要提供上面收到的令牌。请记住,这是一个两阶段过程

  1. 查询图数据库以获取一个或多个集群匹配项。
  2. 将该请求发送到彩虹。

客户端处理这两者,因此您(作为用户)只需面对单一的提交。我们将提供作业的基本参数,但请注意,您也可以提供其他参数。

python ./examples/flux/submit-job.py --help

🌈️ Rainbow scheduler submit

positional arguments:
  command               Command to submit

options:
  -h, --help            show this help message and exit
  --config-path CONFIG_PATH
                        config path with cluster names
  --host HOST           host of rainbow cluster
  --token TOKEN         Cluster token for permission to submit jobs
  --nodes NODES         Nodes for job (defaults to 1)

然后提交!请记住,您需要先进行注册。请注意,我们需要提供我们的集群配置路径。

$ python examples/flux/submit-job.py --config-path ./rainbow-config.yaml --nodes 1 echo hello world
```bash
```console
{
    "version": 1,
    "resources": [
        {
            "type": "node",
            "count": 1,
            "with": [
                {
                    "type": "slot",
                    "count": 1,
                    "label": "echo",
                    "with": [
                        {
                            "type": "core",
                            "count": 1
                        }
                    ]
                }
            ]
        }
    ],
    "tasks": [
        {
            "command": [
                "echo",
                "hello",
                "world"
            ],
            "slot": "echo",
            "count": {
                "per_slot": 1
            }
        }
    ],
    "attributes": {}
}
clusters: "keebler"
status: RESULT_TYPE_SUCCESS

status: SUBMIT_SUCCESS

提交作业规范

我们还可以直接提交作业规范,这是一个高级用例。它基本上工作原理相同,只是我们直接从yaml加载作业规范。

python examples/flux/submit-jobspec.py --config-path ./rainbow-config.yaml ../../docs/examples/scheduler/jobspec-io.yaml

🌈️ Rainbow scheduler submit

positional arguments:
  jobspec               Jobspec path to submit

options:
  -h, --help            show this help message and exit
  --config-path CONFIG_PATH
                        config path with cluster metadata

它看起来大致相同 - 我会省略大部分。它只是作业定义的不同入口点。

clusters: "keebler"
status: RESULT_TYPE_SUCCESS

status: SUBMIT_SUCCESS

接收作业

在我们提交作业后,彩虹将它们分配给一个集群。在这个示例中,我们将它们分配给同一个集群(keebler),因此我们也可以使用我们的主机“keebler”来接收作业。下面是它的样子。

python ./examples/flux/receive-jobs.py --help

🌈️ Rainbow scheduler receive jobs

options:
  -h, --help            show this help message and exit
  --max-jobs MAX_JOBS   Maximum jobs to request (unset defaults to all)
  --config-path CONFIG_PATH
                        config path with cluster metadata

然后请求和接受作业

python examples/flux/receive-jobs.py --config-path ./rainbow-config.yaml
Status: REQUEST_JOBS_SUCCESS
Received 1 jobs to accept...

如果它在Flux中运行,我们就可以运行它,上面的响应已经告诉彩虹您已接受它(并且彩虹删除了该记录)。

许可证

HPCIC DevTools根据MIT许可证条款分发。所有新的贡献都必须在此许可证下进行。

有关详细信息,请参阅许可证版权声明

SPDX-License-Identifier: (MIT)

LLNL-CODE- 842614

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源分布

rainbow-scheduler-0.0.16.tar.gz (19.4 kB 查看哈希值)

上传时间

构建分布

rainbow_scheduler-0.0.16-py3-none-any.whl (27.5 kB 查看哈希值)

上传时间 Python 3

由以下支持