Skip to content

Commit faed903

Browse files
authored
chore(api): separate api and package pyproject (#1098)
* chore(api): separate api and package pyproject * fix: setupdb scripts * fix: add back authlib to the package
1 parent 9be333a commit faed903

7 files changed

Lines changed: 2245 additions & 7198 deletions

File tree

.github/workflows/build-server.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Python
2424
run: uv python install 3.12
2525
- name: Install dependencies
26-
run: uv sync --extra api
26+
run: uv sync --project carbonserver
2727
- name: Unit tests on api
2828
run: uv run task test-api-unit
2929
test_api_server:
@@ -60,7 +60,7 @@ jobs:
6060
- name: Set up Python
6161
run: uv python install 3.12
6262
- name: Install dependencies
63-
run: uv sync --extra api
63+
run: uv sync --project carbonserver
6464
- name: Setup database
6565
env:
6666
DATABASE_URL: postgresql://codecarbon-user:supersecret@localhost:5480/codecarbon_db

carbonserver/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ classifiers = [
1616
]
1717
dependencies = [
1818
"alembic<2.0.0",
19+
"authlib>=1.2.1",
1920
"bcrypt<5.0.0",
2021
"python-dateutil<3.0.0",
2122
"dependency-injector<5.0.0",
@@ -46,7 +47,7 @@ dependencies = [
4647
Homepage = "https://codecarbon.io/"
4748
Repository = "https://github.com/mlco2/codecarbon"
4849
Dashboard = "http://dashboard.codecarbon.io/"
49-
Documentation = "https://mlco2.github.io/codecarbon/"
50+
Documentation = "https://docs.codecarbon.io/"
5051
Issues = "https://github.com/mlco2/codecarbon/issues"
5152
Changelog = "https://github.com/mlco2/codecarbon/releases"
5253

carbonserver/uv.lock

Lines changed: 389 additions & 388 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -71,39 +71,12 @@ codecarbon = [
7171
Homepage = "https://codecarbon.io/"
7272
Repository = "https://github.com/mlco2/codecarbon"
7373
Dashboard = "http://dashboard.codecarbon.io/"
74-
Documentation = "https://mlco2.github.io/codecarbon/"
74+
Documentation = "https://docs.codecarbon.io/"
7575
Issues = "https://github.com/mlco2/codecarbon/issues"
7676
Changelog = "https://github.com/mlco2/codecarbon/releases"
7777

7878

7979
[dependency-groups]
80-
api = [
81-
"alembic<2.0.0",
82-
"authlib>=1.2.1",
83-
"bcrypt<5.0.0",
84-
"python-dateutil<3.0.0",
85-
"dependency-injector<5.0.0",
86-
"fastapi<1.0.0",
87-
"fief-client[fastapi]",
88-
"httpx",
89-
"pydantic[email]<2.0.0",
90-
"psycopg2-binary<3.0.0",
91-
"requests<3.0.0",
92-
"sqlalchemy<2.0.0",
93-
"uvicorn[standard]<1.0.0",
94-
"fastapi-pagination<1.0.0",
95-
"pytest",
96-
"mock",
97-
"responses",
98-
"fastapi-oidc;python_version>='3.10'",
99-
"numpy",
100-
"psutil",
101-
"requests-mock",
102-
"rapidfuzz",
103-
"PyJWT",
104-
"logfire[fastapi]>=1.0.1",
105-
"itsdangerous",
106-
]
10780
dev = [
10881
"taskipy",
10982
"bumpver",
@@ -138,47 +111,21 @@ viz-legacy = [
138111
"fire",
139112
]
140113

141-
api = [
142-
"alembic<2.0.0",
143-
"authlib>=1.2.1",
144-
"bcrypt<5.0.0",
145-
"python-dateutil<3.0.0",
146-
"dependency-injector<5.0.0",
147-
"fastapi<1.0.0",
148-
"fief-client[fastapi]",
149-
"httpx",
150-
"itsdangerous",
151-
"pydantic[email]<2.0.0",
152-
"psycopg2-binary<3.0.0",
153-
"requests<3.0.0",
154-
"sqlalchemy<2.0.0",
155-
"uvicorn[standard]<1.0.0",
156-
"fastapi-pagination<1.0.0",
157-
"pytest",
158-
"mock",
159-
"responses",
160-
"fastapi-oidc;python_version>='3.10'",
161-
"numpy",
162-
"psutil",
163-
"requests-mock",
164-
"rapidfuzz",
165-
"PyJWT",
166-
]
167-
168114

169115
[project.scripts]
170116
carbonboard = "codecarbon.viz.carbonboard:main"
171117
codecarbon = "codecarbon.cli.main:main"
172118

173119
[tool.taskipy.tasks]
174120
pre-commit-install = { cmd = "pre-commit install", help = "Install pre-commit hook." }
175-
dashboard = "cd carbonserver && uvicorn main:app --reload"
176-
dashboard-ci = "cd carbonserver && uvicorn main:app --host 0.0.0.0 --port 8008"
121+
dashboard = "uv run --project carbonserver uvicorn main:app --reload"
122+
dashboard-ci = "uv run --project carbonserver uvicorn main:app --host 0.0.0.0 --port 8008"
177123
docker = "docker-compose up -d"
178-
test-api-unit = "cd carbonserver && python -m pytest -vv tests/api/routers && python -m pytest -vv tests/api/service/ && python -m pytest -vv tests/api/usecase/"
179-
test-api-integ = "cd carbonserver && python -m pytest -vv tests/api/integration/"
180-
setup-db = "cd carbonserver && python3 -m alembic -c carbonserver/database/alembic.ini upgrade head"
181-
downgrade-db = "cd carbonserver && python -m alembic -c carbonserver/database/alembic.ini downgrade base"
124+
test-api-unit = "uv run --project carbonserver python -m pytest -vv carbonserver/tests/api/routers && uv run --project carbonserver python -m pytest -vv carbonserver/tests/api/service/ && uv run --project carbonserver python -m pytest -vv carbonserver/tests/api/usecase/"
125+
test-api-integ = "uv run --project carbonserver python -m pytest -vv carbonserver/tests/api/integration/"
126+
setup-db = "cd carbonserver && uv run --project carbonserver python -m alembic -c carbonserver/database/alembic.ini upgrade head"
127+
downgrade-db = "cd carbonserver && uv run --project carbonserver python -m alembic -c carbonserver/database/alembic.ini downgrade base"
128+
carbonserver-api-requirements = "uv pip compile carbonserver/pyproject.toml --output-file requirements/requirements-api.txt"
182129
build-doc = "zensical build -f mkdocs.yml"
183130
precommit-install = "pre-commit install"
184131
precommit-update = "pre-commit autoupdate"

requirements/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ This file contains all dependencies needed to run the CodeCarbon API server (car
88

99
### Updating the file
1010

11-
When you modify dependencies in `pyproject.toml` (especially those under the `[project.optional-dependencies.api]` section), you **must** regenerate this file:
11+
When you modify dependencies in `carbonserver/pyproject.toml`, you **must** regenerate this file:
1212

1313
```bash
14-
uv pip compile pyproject.toml --extra api --output-file requirements/requirements-api.txt
14+
uv pip compile carbonserver/pyproject.toml --output-file requirements/requirements-api.txt
1515
```
1616

1717
Then commit the updated file.

0 commit comments

Comments
 (0)