跳转到主要内容

Galileo:MC2实验和分析框架

项目描述

Galileo:MC2实验环境

PyPI Version

此项目允许用户为MC2(微型计算集群)定义操作实验,并在运行时与实验环境交互。Galileo包含两个主要组件,用户可以与之交互:实验控制器shell和Galileo仪表板。实验控制器可以在工作者上启动模拟客户端,并控制它们生成的负载量。此外,用户还可以与Symmetry的路由表shell交互,以控制服务请求发送到的集群节点。

构建

创建并激活新的虚拟环境

virtualenv .venv
source .venv/bin/activate

安装需求

pip install -r requirements.txt

如果您在父文件夹中本地有symmetry,通过以下方式链接它

pip install -e ../symmetry

Docker

要创建一个可以运行Galileo组件的Docker镜像,请运行

make docker

要创建一个可以运行Galileo组件的arm32v7 Docker镜像,请运行

make docker-arm

使用以下命令启动工作者

cd docker/galileo-worker
docker-compose up

arm32v7的compose文件位于

docker/arm

启动本地开发环境,包括:API、ExperimentDaemon、1个工作者、redis和数据库

cd docker/dev
docker-compose up

准备示例应用程序

我们使用示例应用程序准备集群。具体来说是一个图像分类服务。

以名为'mms'的Docker容器运行mxnet-model-server,暴露在端口8080。例如,要使用squeezenet和alexnet模型启动mxnet-model-server,请在集群节点上运行以下命令

docker run -itd --name mms -p 8080:8080 -p 8081:8081 awsdeeplearningteam/mxnet-model-server:1.0.0-mxnet-cpu mxnet-model-server --start \
--models squeezenet=https://s3.amazonaws.com/model-server/models/squeezenet_v1.1/squeezenet_v1.1.model,alexnet=https://s3.amazonaws.com/model-server/model_archive_1.0/alexnet.mar

准备实验工作者主机

承载生成负载的工作者的设备需要运行实验控制器主机应用程序。

bin/run worker --logging=INFO

所有运行时参数都通过galileo_*环境变量进行控制。查看docker/galileo-worker/worker.env以获取一些示例。

运行实验控制器shell

(.venv) pi@graviton:~/mc2/galileo $ bin/run shell
                                   __  __
 .-.,="``"=.          ____ _____ _/ (_) /__  ____
 '=/_       \        / __ `/ __ `/ / / / _ \/ __ \
  |  '=._    |      / /_/ / /_/ / / / /  __/ /_/ /
   \     `=./`.     \__, /\__,_/_/_/_/\___/\____/
    '=.__.=' `='   /____/


Welcome to the galileo shell!

Type `usage` to list available functions

galileo> usage
the galileo shell is an interactive python shell that provides the following commands

Commands:
  usage         show this message
  env           show environment variables
  pwd           show the current working directory

Functions:
  sleep         time.sleep wrapper

Objects:
  g             Galileo object that allows you to interact with the system
  show          Prints runtime information about the system to system out
  exp           Galileo experiment
  rtbl          Symmetry routing table

Type help(<function>) or help(<object>) to learn how to use the functions.

配置路由表

shell中的rtbl对象允许您设置负载均衡策略。在galileo shell中运行help(rtbl)。以下是如何为myservice服务设置记录的示例。

galileo> rtbl.set('myservice', ['host1:8080', 'host2:8080'], [1,2])
RoutingRecord(service='myservice', hosts=['host1:8080', 'host2:8080'], weights=[1, 2])
galileo> rtbl
+---------------------------+----------------------+-----------+
| Service                   |                Hosts |   Weights |
+---------------------------+----------------------+-----------+
| myservice                 |           host1:8080 |       1.0 |
|                           |           host2:8080 |       2.0 |
+---------------------------+----------------------+-----------+

运行实验守护进程


FIXME:这是过时的


实验守护进程持续从阻塞的redis队列galileo:experiments:instructions中读取。接收到指令后,控制器将执行命令并记录通过Redis发布的遥测数据。最后,将实验状态设置为'完成',并将客户端保存到数据库中的跟踪更新为引用实验。

注入新实验的Redis命令示例(其中exphost是实验主机的主机名)

LPUSH galileo:experiments:instructions '{"instructions": "spawn exphost squeezenet 1\nsleep 2\nrps exphost squeezenet 1\nsleep 5\nrps exphost squeezenet 0\nsleep 2\nclose exphost squeezenet"}'

您还可以指定exp_idcreatorname,否则将使用一些生成的/标准值。

您可以通过环境变量galileo_expdb_driversqlitemysql)更改用于存储实验数据的数据库。要将更改写入MySQL(或MariaDB),设置以下环境变量:galileo_expdb_mysql_hostgalileo_expdb_mysql_portgalileo_expdb_mysql_dbgalileo_expdb_mysql_usergalileo_expdb_mysql_password

您可以使用以下命令创建一个mariadb docker实例

./bin/run-db.sh

然后执行守护进程

python -m galileo.cli.experimentd

或运行脚本,该脚本从docker容器导出mariadb设置(添加--logging DEBUG以输出)

./bin/experimentd-mysql.sh

运行Galileo REST API

使用gunicorn提供服务

gunicorn -w 4 --preload -b 0.0.0.0:5001 \
    -c galileo/webapp/gunicorn.conf.py \
    galileo.webapp.wsgi:api

项目详情


下载文件

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

源分发

mc2-galileo-0.5.1.tar.gz (36.5 kB 查看哈希值)

上传时间

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面