|
1 | 1 | # Contributing |
2 | 2 |
|
3 | | -## Contributing environment |
4 | | - |
5 | | -To contribute to the project, please follow the instructions below to setup your development environment and launch the services locally. |
6 | | - |
7 | | -### Prerequisites |
8 | | - |
9 | | -- Python 3.12+ |
10 | | -- Docker and Docker Compose |
11 | | - |
12 | | -### Step 1: development environment |
13 | | - |
14 | | -#### Configuration |
15 | | - |
16 | | -It is recommended to use a Python [virtualenv](https://docs.python.org/3/library/venv.html). |
17 | | - |
18 | | -1. Create a *config.yml* file based on the example configuration file *[config.example.yml](./config.example.yml)*. |
19 | | - |
20 | | - ```bash |
21 | | - cp config.example.yml config.yml |
22 | | - ``` |
23 | | - |
24 | | -2. Create a *env* file based on the example environment file *[env.example](./env.example)* |
25 | | - |
26 | | - ```bash |
27 | | - cp .env.example .env |
28 | | - ``` |
29 | | - |
30 | | -3. Comment host names variables like this (by default, they are set to `localhost` in compose.example.yml): |
31 | | - |
32 | | - ```bash |
33 | | - # POSTGRES_HOST=postgres |
34 | | - ``` |
35 | | - |
36 | | -4. Check the [configuration documentation](./docs/configuration.md) to configure your configuration file. |
37 | | - |
38 | | -#### Packages installation |
39 | | - |
40 | | -1. Create a Python virtual environment (recommended) |
41 | | - |
42 | | -1. Install the dependencies with the following command: |
43 | | - |
44 | | - ```bash |
45 | | - pip install ".[api,playground,dev,test]" |
46 | | - ``` |
47 | | - |
48 | | -#### Linter installation |
49 | | - |
50 | | -The project linter is [Ruff](https://beta.ruff.rs/docs/configuration/). The specific project formatting rules are in the *[pyproject.toml](./pyproject.toml)* file. |
51 | | - |
52 | | -Please install the pre-commit hooks: |
53 | | - |
54 | | - ```bash |
55 | | - pre-commit install |
56 | | - ``` |
57 | | - |
58 | | -Ruff will run automatically at each commit. |
59 | | - |
60 | | -To setup ruff in VSCode or Cursor, you can add the following configuration to your editor: |
61 | | -```json |
62 | | -{ |
63 | | - "ruff.lint.enabled": true, |
64 | | - "ruff.lint.fix": true |
65 | | -} |
66 | | -``` |
67 | | - |
68 | | -### Step 2: launch services |
69 | | - |
70 | | -Start services locally with the following command: |
71 | | - |
72 | | -```bash |
73 | | -make dev |
74 | | -``` |
75 | | - |
76 | | -> [!NOTE] |
77 | | -> This command will start the API and the playground services and support the following options: |
78 | | -> ```bash |
79 | | -> make dev [service=api|playground|both] [env=.env] [compose=compose.yml] # service=both by default |
80 | | -> ``` |
81 | | -> For more information, run `make help`. |
82 | | -
|
83 | | -To run the services without make command, you can use the following commands: |
84 | | -
|
85 | | -1. Export the environment variables: |
86 | | - ```bash |
87 | | - export $(grep -v '^#' .env | xargs) |
88 | | - ``` |
89 | | -
|
90 | | -2. Launch the API: |
91 | | - ```bash |
92 | | - uvicorn api.main:app --log-level debug --reload |
93 | | - ``` |
94 | | - |
95 | | -3. Launch the Playground: |
96 | | - ```bash |
97 | | - streamlit run playground/main.py |
98 | | - ``` |
99 | | - |
100 | | -## Linter |
101 | | - |
102 | | -The project linter is [Ruff](https://beta.ruff.rs/docs/configuration/). The specific project formatting rules are in the *[pyproject.toml](./pyproject.toml)* file. See [Linter installation section](#linter-installation) to install the linter and run it at each commit. |
103 | | - |
104 | | -To run the linter manually: |
105 | | - |
106 | | -```bash |
107 | | -make lint |
108 | | -``` |
109 | | - |
110 | | -To setup ruff in VSCode or Cursor, you can add the following configuration to your editor (edit project root path): |
111 | | - |
112 | | -```json |
113 | | -{ |
114 | | - "[python]": { |
115 | | - "editor.formatOnType": true, |
116 | | - "editor.formatOnSave": true, |
117 | | - "editor.codeActionsOnSave": { |
118 | | - "source.fixAll": "explicit", |
119 | | - "source.organizeImports": "always" |
120 | | - }, |
121 | | - "ruff.configuration": "<absolute project root path >/pyproject.toml", |
122 | | - "ruff.format.preview": true, |
123 | | - "ruff.codeAction.fixViolation": {"enable": false}, |
124 | | - "ruff.organizeImports": true, |
125 | | - "ruff.fixAll": true, |
126 | | - "ruff.trace.server": "verbose", |
127 | | - "ruff.logLevel": "debug", |
128 | | - "ruff.nativeServer": "on", |
129 | | - } |
130 | | -} |
131 | | -``` |
132 | | - |
133 | | -## Commit |
134 | | - |
135 | | -Please respect the following convention for your commits: |
136 | | - |
137 | | -``` |
138 | | -[doc|feat|fix](theme) commit object (in english) |
139 | | -
|
140 | | -# example |
141 | | -feat(collections): collection name retriever |
142 | | -``` |
143 | | - |
144 | | -## Tests |
145 | | - |
146 | | -To run the tests: |
147 | | - |
148 | | -```bash |
149 | | -make test |
150 | | -``` |
151 | | - |
152 | | -## Modifications to SQL database structure |
153 | | - |
154 | | -### Modifications to the [`api/sql/models.py`](./api/sql/models.py) file |
155 | | - |
156 | | -If you have modified the API database tables in the [models.py](./api/sql/models.py) file, you need to create an Alembic migration with the following command: |
157 | | - |
158 | | -```bash |
159 | | -alembic -c api/alembic.ini revision --autogenerate -m "message" |
160 | | -``` |
161 | | - |
162 | | -Then apply the migration with the following command: |
163 | | - |
164 | | -```bash |
165 | | -alembic -c api/alembic.ini upgrade head |
166 | | -``` |
167 | | - |
168 | | -### Modifications to the [`playground/sql/models.py`](./playground/sql/models.py) file |
169 | | - |
170 | | -If you have modified the playground database tables in the [models.py](./playground/sql/models.py) file, you need to create an Alembic migration with the following command: |
171 | | - |
172 | | -```bash |
173 | | -alembic -c playground/alembic.ini revision --autogenerate -m "message" |
174 | | -``` |
175 | | - |
176 | | -Then apply the migration with the following command: |
177 | | - |
178 | | -```bash |
179 | | -alembic -c playground/alembic.ini upgrade head |
180 | | -``` |
181 | | - |
182 | | -## Generate configuration documentation |
183 | | - |
184 | | -To generate the configuration documentation, you can use the following command: |
185 | | - |
186 | | -```bash |
187 | | -python scripts/generate_configuration_documentation.py |
188 | | -``` |
189 | | - |
190 | | -> [!NOTE] |
191 | | -> This will generate the configuration documentation in the *[docs/docs/getting-started/configuration.md](./docs/docs/getting-started/configuration.md)* file from the [configuration schema](./api/schemas/core/configuration.py) with the [configuration header](./scripts/configuration_header.md). |
| 3 | +The contributings guides is available in *Contributing* section in [documentation](https://docs.opengatellm.com/docs/): |
| 4 | +- [Development environment](https://docs.opengatellm.com/docs/contributing/development-environment) |
| 5 | +- [Commit and hooks](https://docs.opengatellm.com/docs/contributing/commit) |
| 6 | +- [SQL](https://docs.opengatellm.com/docs/contributing/sql) |
| 7 | +- [Documentation](https://docs.opengatellm.com/docs/contributing/documentation) |
0 commit comments