Skip to main content

Backend.AI Agent

Project description

Backend.AI Agent

The Backend.AI Agent is a small daemon that does:

  • Reports the status and available resource slots of a worker to the manager
  • Routes code execution requests to the designated kernel container
  • Manages the lifecycle of kernel containers (create/monitor/destroy them)

Package Structure

  • ai.backend
    • agent: The agent daemon implementation

Installation

Please visit the installation guides.

For development

Prerequisites

  • libnsappy-dev or snappy-devel system package depending on your distro
  • Python 3.6 or higher with pyenv and pyenv-virtualenv (optional but recommneded)
  • Docker 17.03 or later with docker-compose (18.03 or later is recommended)

Clone the meta repository and install a "halfstack" configuration. The halfstack configuration installs and runs dependency daemons such as etcd in the background.

~$ git clone https://github.com/lablup/backend.ai halfstack
~$ cd halfstack
~/halfstack$ docker-compose -f docker-compose.halfstack.yml up -d

Then prepare the source clone of the agent as follows. First install the current working copy.

~$ git clone https://github.com/lablup/backend.ai-agent agent
~$ cd agent
~/agent$ pyenv virtualenv venv-agent
~/agent$ pyenv local venv-agent
~/agent (venv-agent) $ pip install -U pip setuptools   # ensure latest versions
~/agent (venv-agent) $ pip install -U -r requirements-dev.txt

With the halfstack, you can run the agent simply like (note that you need a working manager running with the halfstack already):

~/agent (venv-agent) $ scripts/run-with-halfstack.sh python -m ai.backend.agent.server \
                     >                                      --scratch-root=/tmp --debug

To run tests:

~/agent (venv-agent) $ scripts/run-with-halfstack.sh python -m pytest -m 'not integration'

To run tests including integration tests, you first need to install the manager in the same virtualenv.

~$ git clone https://github.com/lablup/backend.ai-manager manager
~$ cd agent
~/agent (venv-agent) $ pip install -e ../manager
~/agent (venv-agent) $ scripts/run-with-halfstack.sh python -m pytest

Deployment

Running from a command line

The minimal command to execute:

python -m ai.backend.agent.server --etcd-addr localhost:2379 --namespace my-cluster

The agent reads most configurations from the given etcd v3 server where the cluster administrator or the Backend.AI manager stores all the necessary settings.

The etcd address and namespace must match with the manager to make the agent paired and activated. By specifying distinguished namespaces, you may share a single etcd cluster with multiple separate Backend.AI clusters.

By default the agent uses /var/cache/scratches directory for making temporary home directories used by kernel containers (the /home/work volume mounted in containers). Note that the directory must exist in prior and the agent-running user must have ownership of it. You can change the location by --scratch-root option.

For more arguments and options, run the command with --help option.

Example config for agent server/instances

/etc/supervisor/conf.d/agent.conf:

[program:backend.ai-agent]
user = user
stopsignal = TERM
stopasgroup = true
command = /home/user/run-agent.sh

/home/user/run-agent.sh:

#!/bin/sh
source /home/user/venv/bin/activate
exec python -m ai.backend.agent.server \
     --etcd-addr localhost:2379 \
     --namespace my-cluster

Networking

Basically all TCP ports must be transparently open to the manager. The manager and agent should run in the same local network or different networks reachable via VPNs.

The operation of agent itself does not require both incoming/outgoing access to the public Internet, but if the user's computation programs need, the docker containers should be able to access the public Internet (maybe via some corporate firewalls).

Several optional features such as automatic kernel image updates may require outgoing public Internet access from the agent as well.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backend.ai-agent-18.12.0a3.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

backend.ai_agent-18.12.0a3-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file backend.ai-agent-18.12.0a3.tar.gz.

File metadata

  • Download URL: backend.ai-agent-18.12.0a3.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for backend.ai-agent-18.12.0a3.tar.gz
Algorithm Hash digest
SHA256 dc5fc2a614a304376c97d17674ab8d0705c80dc2cf3d8458142cbef616420cc1
MD5 24e79a542bb241fa3db064e7f560f107
BLAKE2b-256 09234d280280d7223a8592233a4e3a2f5a0658f2a29bdb5ef9f812d30f9d4dab

See more details on using hashes here.

Provenance

File details

Details for the file backend.ai_agent-18.12.0a3-py3-none-any.whl.

File metadata

  • Download URL: backend.ai_agent-18.12.0a3-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for backend.ai_agent-18.12.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 ade3c028c92ea6a8e7cb962b320a113a3aa9a36303aa5b263ced28001ff49d98
MD5 23bb04e7045f2a9ac6b5a8289a62854e
BLAKE2b-256 c3bbf44db505685fb9f49858cb8921a3496a47c6d9c97a422c7cbef99c1bbcb7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page