Skip to content

Commit f2bbee3

Browse files
authored
[DOC] Add setup documentation for aiondemand and AIOD-rest-api (openml#55)
Added setup guide for [`aiondemand`](https://github.com/aiondemand/aiondemand) and [`AIoD-rest-api`](https://github.com/aiondemand/AIoD-rest-api) ## Related Issues openml#53
1 parent 2900ba8 commit f2bbee3

5 files changed

Lines changed: 241 additions & 1 deletion

File tree

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ aiod.publications.search(query="Robotics")
4848
```
4949
## Contributing
5050

51-
Interested in contributing? Check out the [contributing guidelines](contributing.md).
51+
Interested in contributing? Check out the [contributing guidelines](contributing.md), then start with the [Developer Setup Guide](developer_setup.md) to set up your local development environment. Check out the complete documentation here: https://aiondemand.github.io/aiondemand/developer_setup
5252
By contributing to this project, you agree to abide by our [Code of Conduct](conduct.md).
5353

5454
## Credits

docs/developer_setup.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# AI-on-Demand dev environment setup guide
2+
3+
This guide sets up a complete local development environment for AI-on-Demand, which consists of:
4+
5+
**What you'll set up:**
6+
1. Python client library (`aiondemand`)
7+
2. REST API backend service (`AIOD-rest-api`)
8+
3. Development tools (linting, testing, pre-commit hooks)
9+
10+
Both repositories work together as a single system and should be tested together.
11+
12+
---
13+
14+
## Prerequisites
15+
16+
- Python 3.10 or higher (check with command: `python -V`)
17+
- pip package manager (check with command: `pip list`)
18+
- Docker setup (check with command: `docker ps`)
19+
20+
---
21+
22+
## One-Time Initial Setup
23+
24+
### Part 1: Setup `aiondemand` (Python Client)
25+
26+
Clone the repository:
27+
```bash
28+
git clone https://github.com/aiondemand/aiondemand
29+
cd aiondemand
30+
```
31+
32+
**Create and activate virtual environment:**
33+
34+
```bash
35+
# Create venv
36+
python -m venv venv
37+
```
38+
39+
**Windows:**
40+
```bash
41+
.\venv\Scripts\activate
42+
```
43+
44+
**Mac/Linux:**
45+
```bash
46+
source venv/bin/activate
47+
```
48+
49+
**Install Package with developer dependencies**
50+
51+
```bash
52+
pip install -e ".[dev]"
53+
```
54+
55+
**Quick check**:
56+
```bash
57+
python -c "import aiod; print('aiondemand installed successfully!')"
58+
```
59+
60+
---
61+
62+
### Part 2: Setup `AIOD-rest-api` (Backend Service)
63+
64+
Clone the repository:
65+
```bash
66+
git clone https://github.com/aiondemand/AIOD-rest-api
67+
cd AIOD-rest-api
68+
```
69+
70+
**Configure environment:**
71+
72+
Edit the `.env` file to enable local development mode (located at line no.: 4):
73+
```bash
74+
USE_LOCAL_DEV=true
75+
```
76+
77+
**Build Docker images** (one-time):
78+
```bash
79+
# Build specific images
80+
docker compose build app
81+
docker compose build deletion
82+
83+
# Build all images
84+
docker compose build
85+
86+
# Run DB data migration
87+
docker compose up fill-db-with-examples
88+
```
89+
90+
- **Note:** Add this command in the `Dockerfile` after the `apt-get install` block if the python package dependencies seem to be broken (happens sometimes in Windows): `pip install --upgrade pip setuptools wheel`
91+
92+
**Running tests**
93+
```bash
94+
py -3.11 -m venv .venv
95+
.venv\Scripts\activate
96+
pip install -e ".[dev]"
97+
pytest src/tests
98+
```
99+
Note: currently the tests are expected to fail. update regarding this is currently tracked here: https://github.com/aiondemand/AIOD-rest-api/issues/681
100+
101+
---
102+
103+
## Complete System Verification
104+
105+
After completing both setup parts, verify the entire system is working:
106+
107+
### 1. Verify Python Client Installation
108+
```bash
109+
cd aiondemand
110+
.\venv\Scripts\activate # Windows
111+
# source venv/bin/activate # Mac/Linux
112+
113+
python -c "import aiod; print(f'aiod version: {aiod.__version__}')"
114+
```
115+
116+
### 2. Verify REST API Service
117+
Start the services:
118+
```bash
119+
cd AIOD-rest-api
120+
docker compose up
121+
```
122+
123+
Check API documentation at: `http://localhost:8000/docs`
124+
125+
![alt text](./images/aiod-rest-api-verify-1.png)
126+
127+
### 3. Verify data migration in database
128+
As the mysql database does not expose any ports, we cannot check the data in tables directly using a db client. instead we can manually check from the openapi docs or run `curl` request on the actual fastpi endpoint to check if there is any data in the table:
129+
130+
```bash
131+
curl "http://localhost:8000/counts/contacts?detailed=false"
132+
```
133+
- Should return 1
134+
135+
### 4. Verify Elasticsearch
136+
Go to `http://localhost:9200` and login with:
137+
- **Username:** `elastic`
138+
- **Password:** `changeme`
139+
140+
![alt text](./images/aiod-rest-api-verify-2.png)
141+
142+
---
143+
144+
## Common Development Tasks
145+
146+
### Using the SDK with a Local Backend
147+
148+
149+
By default, the SDK (`aiod`) connects to the remote production backend at `https://api.aiod.eu/`. To use your locally running backend (for development or testing), update the API server URL in your code as follows:
150+
151+
### 1. Configure SDK to Use Local Backend
152+
153+
Set the API server URL before making any requests:
154+
155+
```python
156+
import aiod
157+
158+
# Point the SDK to your locally running backend
159+
aiod.config.api_server = "http://localhost:8000/"
160+
```
161+
162+
### 2. Fetch Data from Local Backend
163+
164+
Now you can use the SDK as usual, and it will communicate with your local backend. For example, to fetch a list of contacts (assuming your local database has data):
165+
166+
```python
167+
import aiod
168+
169+
# Ensure the SDK is using the local backend
170+
aiod.config.api_server = "http://localhost:8000/"
171+
172+
# Fetch and print the list of contacts
173+
contacts = aiod.contacts.get_list()
174+
print(contacts)
175+
```
176+
177+
To confirm your local server is set up perfectly, it should return a response like this:
178+
179+
```bash
180+
platform platform_resource_identifier ... telephone identifier
181+
0 example 1 ... [0032 xxxx xxxx] con_osweUoxaTYQDVuoEwz9HdWXx
182+
183+
[1 rows x 7 columns]
184+
```
185+
186+
This will retrieve data from your locally running backend instead of the remote server. You can set `aiod.config.api_server` to any remote or local URL as needed.
187+
188+
### Starting the Development Environment
189+
190+
**Every time you work on the project:**
191+
192+
1. **Activate Python environment:**
193+
```bash
194+
cd aiondemand
195+
.\venv\Scripts\activate # Windows
196+
# source venv/bin/activate # Mac/Linux
197+
```
198+
199+
2. **Start backend services:**
200+
```bash
201+
cd AIOD-rest-api
202+
docker compose up
203+
```
204+
205+
3. **Stop services when done:**
206+
```bash
207+
# In the AIOD-rest-api terminal, press Ctrl+C, then:
208+
docker compose down
209+
```
210+
211+
---
212+
213+
## Contributor Workflow Guide
214+
215+
Before raising a pull request, run these checks to ensure code quality:
216+
217+
### Run Full Test Suite
218+
```bash
219+
cd aiondemand
220+
.\venv\Scripts\activate # Windows
221+
# source venv/bin/activate # Mac/Linux
222+
223+
python -m pytest -v
224+
```
225+
226+
### Run Linting
227+
```bash
228+
ruff check .
229+
```
230+
231+
### Auto-fix Linting Issues
232+
```bash
233+
ruff check --fix .
234+
```
235+
236+
### Run Pre-commit Hooks
237+
```bash
238+
pre-commit run --all-files
239+
```
87.6 KB
Loading
44.3 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extra_css:
2020

2121
nav:
2222
- Introduction: 'README.md'
23+
- 'Developer Setup': 'developer_setup.md'
2324
- Examples:
2425
- 'Getting Started': 'examples/getting-started.ipynb'
2526
- Sharing: 'examples/sharing.ipynb'

0 commit comments

Comments
 (0)