|
| 1 | +## Introduction |
| 2 | + |
| 3 | +The AVxcelerate Resource Manager REST API v0.1.0 is compatible with the AVX Architecture V2. |
| 4 | + |
| 5 | +This REST API allows to perform CRUD (Create, Read, Update, and Delete) operations on resources such as queues, deployments, applications and app-runtime-configurations. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +### Queues |
| 10 | + |
| 11 | +* You can create queues with the required storages, resource limits and environment variables |
| 12 | +* Allowing to manage queues helps will help you configure different applications within resource limits and group the applications requiring same storage together. |
| 13 | +* You can adjust the maximum number of workers that can concurrently run on a queue using the parameter 'maximum_allowed_worker_instances' |
| 14 | + |
| 15 | +### Plugins |
| 16 | + |
| 17 | + You can register a plugin with definition of container runtime. |
| 18 | +For example: Docker Engine / Kubernetes |
| 19 | + |
| 20 | +### Jobs |
| 21 | + |
| 22 | +* You can submit a resource-manager job by providing application details (name, version, image, environment variables, etc.) and track it to its completion. |
| 23 | +* You can also check the status of the job and clean the resources the job has acquired. |
| 24 | + |
| 25 | +## Python helper |
| 26 | + |
| 27 | +The AVxcelerate python APIs are hosted as a python package on a cluster as part of the Explore service deployment. The developers can install the package using pip and use it to call AVx autonomy APIs without needing to make raw REST calls. |
| 28 | + |
| 29 | +PyPi Regsitry URL: |
| 30 | + |
| 31 | +The python package is hosted as PyPi compliant registry on each deployed cluster. The registry URL is like this: |
| 32 | + |
| 33 | +https://BASE_URL/pypi |
| 34 | + |
| 35 | +For example, for AFT deployment: |
| 36 | + |
| 37 | +<https://explore.azure-aft.apps.frisbeedev.com/pypi> |
| 38 | + |
| 39 | +## Usage example |
| 40 | + |
| 41 | +Pre-requisites: |
| 42 | + |
| 43 | +We assume that on the system is running with the **Ubuntu 22.04** version, and that the following tools are already installed: |
| 44 | + |
| 45 | +- python 3.10 |
| 46 | +- pip 25.1 |
| 47 | +- uv 0.6 |
| 48 | + |
| 49 | +And we assume that you are using AVx Autonomy Toolchain version **25R2.1** |
| 50 | + |
| 51 | +Step 1: Create virtual environment |
| 52 | + |
| 53 | +```bash |
| 54 | +$ python -m venv .venv |
| 55 | +``` |
| 56 | + |
| 57 | +Step 2: Activate the virtual environment |
| 58 | + |
| 59 | +```bash |
| 60 | +$ source .venv/bin/activate |
| 61 | +``` |
| 62 | + |
| 63 | +Step 3: Install python packages: |
| 64 | + |
| 65 | +- ansys-api-avxcelerate-autonomy |
| 66 | +- ansys-avxcelerate-autonomy |
| 67 | + |
| 68 | +```bash |
| 69 | +$ pip install ansys-api-avxcelerate-autonomy ansys-avxcelerate-autonomy --extra-index-url [https://explore-service.traefik.me:9081/pypi](https://explore-service.traefik.me:9081/v1/pypi) |
| 70 | +``` |
| 71 | + |
| 72 | +Step 4: Use ansys-api-avxcelerate-autonomy and ansys-avxcelerate-autonomy in your python code |
| 73 | + |
| 74 | + |
| 75 | +```python |
| 76 | +import asyncio |
| 77 | + |
| 78 | +from ansys.api.avxcelerate.autonomy.explore_service.v1.api.jobs_api import JobsApi |
| 79 | + |
| 80 | +from ansys.api.avxcelerate.autonomy.explore_service.v1.api_client import ApiClient |
| 81 | + |
| 82 | +from ansys.api.avxcelerate.autonomy.explore_service.v1.configuration import Configuration |
| 83 | + |
| 84 | +from ansys.api.avxcelerate.autonomy.explore_service.v1.exceptions import NotFoundException |
| 85 | + |
| 86 | +from ansys.api.avxcelerate.autonomy.explore_service.v1.models.explore_job_read import ExploreJobRead |
| 87 | + |
| 88 | +from ansys.avxcelerate.autonomy.utils.auth_client_session import AuthClientSession |
| 89 | + |
| 90 | +from ansys.avxcelerate.autonomy.utils.token_provider import TokenProvider |
| 91 | + |
| 92 | +async def main(): |
| 93 | + |
| 94 | +base_url = "<https://explore.aws-stage.apps.frisbeedev.com>" |
| 95 | + |
| 96 | +configuration = Configuration(host=f"{base_url}/api/explore/v1") |
| 97 | + |
| 98 | +async with ApiClient(configuration) as api_client: |
| 99 | + |
| 100 | +session = AuthClientSession(base_url=f"{base_url}/api/explore/v1/") |
| 101 | + |
| 102 | +provider = TokenProvider(f"{base_url}/auth") |
| 103 | + |
| 104 | +session.set_provider(provider) |
| 105 | + |
| 106 | +provider.login() |
| 107 | + |
| 108 | +api_client.rest_client.pool_manager = session |
| 109 | + |
| 110 | +jobs_api = JobsApi(api_client) |
| 111 | + |
| 112 | +job_id = "exp-dec894b2-647c-4ca5-b516-cdfc18c58fdd" |
| 113 | + |
| 114 | +try: |
| 115 | + |
| 116 | +job: ExploreJobRead = await jobs_api.get_job(job_id) |
| 117 | + |
| 118 | +print(job) |
| 119 | + |
| 120 | +except NotFoundException: |
| 121 | + |
| 122 | +print("No job found against this id") |
| 123 | + |
| 124 | +except Exception as ex: |
| 125 | + |
| 126 | +print(str(ex)) |
| 127 | + |
| 128 | +print("Couldn't get job against this job id") |
| 129 | + |
| 130 | +asyncio.run(main()) |
| 131 | +``` |
| 132 | + |
0 commit comments