
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
# Target: src/ai/backend/manager:dist

from setuptools import setup

setup(**{
    'author': 'Lablup Inc. and contributors',
    'classifiers': [
        'Intended Audience :: Developers',
        'Operating System :: MacOS :: MacOS X',
        'Operating System :: POSIX :: Linux',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3',
        'Environment :: No Input/Output (Daemon)',
        'Topic :: Scientific/Engineering',
        'Topic :: Software Development',
        'Development Status :: 5 - Production/Stable',
        'Programming Language :: Python :: 3.13',
        'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
    ],
    'description': 'Backend.AI Manager',
    'entry_points': {
        'backendai_cli_v10': [
            'mgr = ai.backend.manager.cli.__main__:main',
            'mgr.start-server = ai.backend.manager.server:main',
        ],
        'backendai_scheduler_v10': [
            'fifo = ai.backend.manager.scheduler.fifo:FIFOSlotScheduler',
            'lifo = ai.backend.manager.scheduler.fifo:LIFOSlotScheduler',
            'drf = ai.backend.manager.scheduler.drf:DRFScheduler',
        ],
        'backendai_agentselector_v10': [
            'legacy = ai.backend.manager.scheduler.agent_selector:LegacyAgentSelector',
            'roundrobin = ai.backend.manager.scheduler.agent_selector:RoundRobinAgentSelector',
            'concentrated = ai.backend.manager.scheduler.agent_selector:ConcentratedAgentSelector',
            'dispersed = ai.backend.manager.scheduler.agent_selector:DispersedAgentSelector',
        ],
        'backendai_error_monitor_v20': [
            'intrinsic = ai.backend.manager.plugin.error_monitor:ErrorMonitor',
        ],
        'backendai_network_manager_v1': [
            'overlay = ai.backend.manager.network.overlay:OverlayNetworkPlugin',
        ],
    },
    'install_requires': (
        'PyJWT~=2.10.1',
        'PyYAML~=6.0',
        'SQLAlchemy[postgresql_asyncpg]~=1.4.54',
        'aiodataloader~=0.4.2',
        'aiodocker==0.24.0',
        'aiofiles~=24.1.0',
        'aiohttp_cors~=0.8.1',
        'aiohttp_sse>=2.2',
        'aiohttp~=3.11.16',
        'aiomonitor~=0.7.0',
        'aiotools~=1.9.0',
        'alembic~=1.13.2',
        'async_timeout~=4.0',
        'attrs>=25.3',
        'backend.ai-cli==25.6.15',
        'backend.ai-common==25.6.15',
        'backend.ai-logging==25.6.15',
        'backend.ai-plugin==25.6.15',
        'bcrypt~=4.2.0',
        'boto3~=1.35',
        'callosum~=1.0.3',
        'click~=8.1.7',
        'cryptography>=44.0.2',
        'etcd-client-py~=0.4.0',
        'graphene~=3.3.0',
        'lark~=1.1.5',
        'more-itertools~=10.5.0',
        'msgpack~=1.1.0',
        'multidict~=6.2.0',
        'pydantic[email]~=2.11.3',
        'python-dateutil>=2.9',
        'pyzmq~=26.4',
        'redis[hiredis]==4.5.5',
        'ruamel.yaml~=0.18.10',
        'setproctitle~=1.3.5',
        'tabulate~=0.8.9',
        'tenacity>=9.0',
        'trafaret~=2.1',
        'typeguard~=4.3',
        'types-PyYAML',
        'types-aiofiles',
        'types-python-dateutil',
        'types-redis',
        'types-six',
        'types-tabulate',
        'typing_extensions~=4.11',
        'uvloop~=0.21; sys_platform != "Windows"',
        'yarl~=1.19.0',
    ),
    'license': 'LGPLv3',
    'long_description': """Backend.AI Manager with API Gateway
===================================

Package Structure
-----------------

* `ai.backend.manager`: Computing resource and workload management with public APIs

Installation
------------

Please visit [the installation guides](https://github.com/lablup/backend.ai/wiki).


### Kernel/system configuration

#### Recommended resource limits:

**`/etc/security/limits.conf`**
```
root hard nofile 512000
root soft nofile 512000
root hard nproc 65536
root soft nproc 65536
user hard nofile 512000
user soft nofile 512000
user hard nproc 65536
user soft nproc 65536
```

**sysctl**
```
fs.file-max=2048000
net.core.somaxconn=1024
net.ipv4.tcp_max_syn_backlog=1024
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.tcp_fin_timeout=10
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_early_retrans=1
net.ipv4.ip_local_port_range="10000 65000"
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 12582912 16777216
net.ipv4.tcp_wmem=4096 12582912 16777216
```


### For development

#### Prerequisites

* Python 3.6 or higher with [pyenv](https://github.com/pyenv/pyenv)
and [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) (optional but recommneded)
* Docker 18.03 or later with docker-compose (18.09 or later is recommended)

#### Common steps

Clone [the meta repository](https://github.com/lablup/backend.ai) and install a "halfstack"
configuration.  The halfstack configuration installs and runs several dependency daemons such as etcd in
the background.

```console
$ git clone https://github.com/lablup/backend.ai halfstack
$ cd 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.

```console
$ git clone https://github.com/lablup/backend.ai-manager manager
$ cd manager
$ pyenv virtualenv venv-manager
$ pyenv local venv-manager
$ pip install -U pip setuptools
$ pip install -U -r requirements/dev.txt
```

From now on, let's assume all shell commands are executed inside the virtualenv.

### Halfstack (single-node development & testing)

#### Recommended directory structure

* `backend.ai-dev`
  - `manager` (git clone from this repo)
  - `agent` (git clone from [the agent repo](https://github.com/lablup/backend.ai-agent))
  - `common` (git clone from [the common repo](https://github.com/lablup/backend.ai-common))

Install `backend.ai-common` as an editable package in the manager (and the agent) virtualenvs
to keep the codebase up-to-date.

```console
$ cd manager
$ pip install -U -e ../common -r requirements/dev.txt
```

#### Steps

Copy (or symlink) the halfstack configs:
```console
$ cp config/halfstack.toml ./manager.toml
$ cp config/halfstack.alembic.ini ./alembic.ini
```

Set up Redis:
```console
$ backend.ai mgr etcd put config/redis/addr 127.0.0.1:8110
```

> ℹ️ NOTE: You may replace `backend.ai mgr` with `python -m ai.backend.manager.cli` in case your `PATH` is unmodifiable.

Set up the public Docker registry:
```console
$ backend.ai mgr etcd put config/docker/registry/index.docker.io "https://registry-1.docker.io"
$ backend.ai mgr etcd put config/docker/registry/index.docker.io/username "lablup"
$ backend.ai mgr image rescan index.docker.io
```

Set up the vfolder paths:
```console
$ mkdir -p "$HOME/vfroot/local"
$ backend.ai mgr etcd put volumes/_mount "$HOME/vfroot"
$ backend.ai mgr etcd put volumes/_default_host local
```

Set up the allowed types of vfolder. Allowed values are "user" or "group".
If none is specified, "user" type is set implicitly:
```console
$ backend.ai mgr etcd put volumes/_types/user ""   # enable user vfolder
$ backend.ai mgr etcd put volumes/_types/group ""  # enable group vfolder
```

Set up the database:
```console
$ backend.ai mgr schema oneshot
$ backend.ai mgr fixture populate sample-configs/example-keypairs.json
$ backend.ai mgr fixture populate sample-configs/example-resource-presets.json
```

Then, run it (for debugging, append a `--debug` flag):

```console
$ backend.ai mgr start-server
```

To run tests:

```console
$ python -m flake8 src tests
$ python -m pytest -m 'not integration' tests
```

Now you are ready to install the agent.
Head to [the README of Backend.AI Agent](https://github.com/lablup/backend.ai-agent/blob/master/README.md).

NOTE: To run tests including integration tests, you first need to install and run the agent on the same host.

## Deployment

### Configuration

Put a TOML-formatted manager configuration (see the sample in `config/sample.toml`)
in one of the following locations:

 * `manager.toml` (current working directory)
 * `~/.config/backend.ai/manager.toml` (user-config directory)
 * `/etc/backend.ai/manager.toml` (system-config directory)

Only the first found one is used by the daemon.

Also many configurations shared by both manager and agent are stored in etcd.
As you might have noticed above, the manager provides a CLI interface to access and manipulate the etcd
data.  Check out the help page of our etcd command set:

```console
$ python -m ai.backend.manager.cli etcd --help
```

If you run etcd as a Docker container (e.g., via halfstack), you may use the native client as well.
In this case, PLEASE BE WARNED that you must prefix the keys with "/sorna/{namespace}" manaully:

```console
$ docker exec -it ${ETCD_CONTAINER_ID} /bin/ash -c 'ETCDCTL_API=3 etcdctl ...'
```

### Running from a command line

The minimal command to execute:

```sh
python -m ai.backend.gateway.server
```

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

### Writing a wrapper script

To use with systemd, crontab, and other system-level daemons, you may need to write a shell script
that executes specific CLI commands provided by Backend.AI modules.

The following example shows how to set up pyenv and virtualenv for the script-local environment.
It runs the gateway server if no arguments are given, and execute the given arguments as a shell command
if any.
For instance, you may get/set configurations like: `run-manager.sh python -m ai.backend.manager.etcd ...`
where the name of scripts is `run-manager.sh`.

```bash
#! /bin/bash
if [ -z "$HOME" ]; then
  export HOME="/home/devops"
fi
if [ -z "$PYENV_ROOT" ]; then
  export PYENV_ROOT="$HOME/.pyenv"
  export PATH="$PYENV_ROOT/bin:$PATH"
fi
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate venv-bai-manager

if [ "$#" -eq 0 ]; then
  exec python -m ai.backend.gateway.server
else
  exec "$@"
fi
```

### Networking

The manager and agent should run in the same local network or different
networks reachable via VPNs, whereas the manager's API service must be exposed to
the public network or another private network that users have access to.

The manager requires access to the etcd, the PostgreSQL database, and the Redis server.

| User-to-Manager TCP Ports | Usage |
|:-------------------------:|-------|
| manager:{80,443}          | Backend.AI API access |

| Manager-to-X TCP Ports | Usage |
|:----------------------:|-------|
| etcd:2379              | etcd API access |
| postgres:5432          | Database access |
| redis:6379             | Redis API access |

The manager must also be able to access TCP ports 6001, 6009, and 30000 to 31000 of the agents in default
configurations.  You can of course change those port numbers and ranges in the configuration.

| Manager-to-Agent TCP Ports | Usage |
|:--------------------------:|-------|
| 6001                       | ZeroMQ-based RPC calls from managers to agents |
| 6009                       | HTTP watcher API |
| 30000-31000                | Port pool for in-container services |


LICENSES
--------

[GNU Lesser General Public License](https://github.com/lablup/backend.ai-manager/blob/master/LICENSE)
[Dependencies](https://github.com/lablup/backend.ai-manager/blob/master/DEPENDENCIES.md)
""",
    'long_description_content_type': 'text/markdown',
    'name': 'backend.ai-manager',
    'namespace_packages': (
    ),
    'package_data': {
        'ai.backend.manager': (
            'VERSION',
            'py.typed',
        ),
        'ai.backend.manager.api': (
            'py.typed',
        ),
        'ai.backend.manager.models.alembic': (
            'revision_history/23.09.10.json',
            'revision_history/24.03.11.json',
            'revision_history/24.09.8.json',
            'script.py.mako',
        ),
        'ai.backend.manager.vendor': (
            '__init__.py',
            'bai-icon.svg',
            'graphiql.min.css',
            'graphiql.min.js',
            'react-dom.production.min.js',
            'react.production.min.js',
            'spec-viewer.js',
        ),
    },
    'packages': (
        'ai.backend.manager',
        'ai.backend.manager.actions',
        'ai.backend.manager.actions.monitors',
        'ai.backend.manager.api',
        'ai.backend.manager.cli',
        'ai.backend.manager.client',
        'ai.backend.manager.client.container_registry',
        'ai.backend.manager.container_registry',
        'ai.backend.manager.data.container_registry',
        'ai.backend.manager.data.image',
        'ai.backend.manager.data.resource',
        'ai.backend.manager.data.session',
        'ai.backend.manager.models',
        'ai.backend.manager.models.alembic',
        'ai.backend.manager.models.alembic.versions',
        'ai.backend.manager.models.gql_models',
        'ai.backend.manager.models.gql_models.metric',
        'ai.backend.manager.models.minilang',
        'ai.backend.manager.models.rbac',
        'ai.backend.manager.network',
        'ai.backend.manager.plugin',
        'ai.backend.manager.reporters',
        'ai.backend.manager.scheduler',
        'ai.backend.manager.service',
        'ai.backend.manager.service.container_registry',
        'ai.backend.manager.services',
        'ai.backend.manager.services.agent',
        'ai.backend.manager.services.agent.actions',
        'ai.backend.manager.services.container_registry',
        'ai.backend.manager.services.container_registry.actions',
        'ai.backend.manager.services.domain',
        'ai.backend.manager.services.domain.actions',
        'ai.backend.manager.services.group',
        'ai.backend.manager.services.group.actions',
        'ai.backend.manager.services.image',
        'ai.backend.manager.services.image.actions',
        'ai.backend.manager.services.keypair_resource_policy',
        'ai.backend.manager.services.keypair_resource_policy.actions',
        'ai.backend.manager.services.metric',
        'ai.backend.manager.services.metric.actions',
        'ai.backend.manager.services.metric.processors',
        'ai.backend.manager.services.project_resource_policy',
        'ai.backend.manager.services.project_resource_policy.actions',
        'ai.backend.manager.services.resource_preset',
        'ai.backend.manager.services.resource_preset.actions',
        'ai.backend.manager.services.session',
        'ai.backend.manager.services.session.actions',
        'ai.backend.manager.services.user',
        'ai.backend.manager.services.user.actions',
        'ai.backend.manager.services.user_resource_policy',
        'ai.backend.manager.services.user_resource_policy.actions',
        'ai.backend.manager.services.vfolder',
        'ai.backend.manager.services.vfolder.actions',
        'ai.backend.manager.services.vfolder.processors',
        'ai.backend.manager.services.vfolder.services',
        'ai.backend.manager.sweeper',
        'ai.backend.manager.vendor',
    ),
    'project_urls': {
        'Documentation': 'https://docs.backend.ai/',
        'Source': 'https://github.com/lablup/backend.ai',
    },
    'python_requires': '>=3.13,<3.14',
    'url': 'https://github.com/lablup/backend.ai',
    'version': '25.6.15',
    'zip_safe': False,
})
