Skip to content

Commit 3ba90aa

Browse files
authored
Merge pull request #108 from nebulabroadcast/migrate-to-uv
Switch to UV
2 parents 1d6c150 + 5e4e86c commit 3ba90aa

File tree

26 files changed

+1282
-129
lines changed

26 files changed

+1282
-129
lines changed

.github/workflows/dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish a new version
1+
name: Publish a dev version
22

33
on:
44
push:
@@ -22,7 +22,7 @@ jobs:
2222
uses: SebRollen/[email protected]
2323
with:
2424
file: 'backend/pyproject.toml'
25-
field: 'tool.poetry.version'
25+
field: 'project.version'
2626

2727
- name: Build docker image
2828
uses: docker/build-push-action@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: SebRollen/[email protected]
2323
with:
2424
file: 'backend/pyproject.toml'
25-
field: 'tool.poetry.version'
25+
field: 'project.version'
2626

2727
- name: Build docker image
2828
uses: docker/build-push-action@v4

Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,22 @@ COPY ./frontend/public /frontend/public
1111
WORKDIR /frontend
1212
RUN yarn install && yarn build
1313

14-
FROM python:3.12-bullseye
14+
FROM python:3.12-slim
1515
ENV PYTHONBUFFERED=1
1616

1717
RUN \
1818
apt-get update \
19-
&& apt-get -yqq upgrade \
2019
&& apt-get -yqq install \
21-
cifs-utils
20+
cifs-utils \
21+
&& apt-get clean \
22+
&& rm -rf /var/lib/apt/lists/*
2223

23-
RUN mkdir /backend
2424
WORKDIR /backend
25-
COPY ./backend/pyproject.toml /backend/pyproject.toml
25+
COPY ./backend/pyproject.toml /backend/uv.lock .
26+
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
27+
uv pip install -r pyproject.toml --system
2628

27-
RUN \
28-
pip install -U pip && \
29-
pip install poetry && \
30-
poetry config virtualenvs.create false && \
31-
poetry install --no-interaction --no-ansi --only main
32-
33-
COPY ./backend /backend
29+
COPY ./backend .
3430
COPY --from=build /frontend/dist/ /frontend
3531

3632
CMD ["/bin/bash", "manage", "start"]

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
IMAGE_NAME=nebulabroadcast/nebula-server:dev
2-
VERSION=$(shell cd backend && poetry run python -c 'import nebula' --version)
2+
VERSION=$(shell cd backend && uv run python -c 'import nebula' --version)
33

44
check:
55
cd frontend && \
66
yarn format
77

88
cd backend && \
9-
poetry version $(VERSION) && \
10-
poetry run ruff format . && \
11-
poetry run ruff check --fix . && \
12-
poetry run mypy .
9+
sed -i "s/^version = \".*\"/version = \"$(VERSION)\"/" pyproject.toml && \
10+
uv run ruff format . && \
11+
uv run ruff check --fix . && \
12+
uv run mypy .
1313

1414
build: check
1515
docker build -t $(IMAGE_NAME) .

backend/api/browse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def sanitize_value(value: SerializableValue) -> str:
115115
def build_conditions(conditions: list[ConditionModel]) -> list[str]:
116116
cond_list: list[str] = []
117117
for condition in conditions:
118-
assert (
119-
condition.key in nebula.settings.metatypes
120-
), f"Invalid meta key {condition.key}"
118+
assert condition.key in nebula.settings.metatypes, (
119+
f"Invalid meta key {condition.key}"
120+
)
121121
condition.value = normalize_meta(condition.key, condition.value)
122122
if condition.operator in ["IN", "NOT IN"]:
123123
assert isinstance(condition.value, list), "Value must be a list"

backend/api/jobs/jobs_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ async def handle(
261261
LEFT JOIN services as s ON s.id = j.id_service
262262
LEFT JOIN users as u ON u.id = j.id_user
263263
LEFT JOIN actions as ac ON ac.id = j.id_action
264-
{('WHERE ' + (' AND '.join(conds))) if conds else ''}
264+
{("WHERE " + (" AND ".join(conds))) if conds else ""}
265265
ORDER BY
266266
j.progress DESC NULLS LAST,
267267
j.end_time DESC,

backend/api/order/set_rundown_order.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,24 @@ async def set_rundown_order(
6464
affected_bins.append(item["id_bin"])
6565

6666
elif obj.type == "asset":
67-
assert (
68-
obj.id is not None
69-
), "Asset ID must not be None when inserting asset to rundown"
67+
assert obj.id is not None, (
68+
"Asset ID must not be None when inserting asset to rundown"
69+
)
7070
asset = await nebula.Asset.load(
7171
obj.id,
7272
connection=conn,
7373
username=user.name,
7474
)
7575
if not asset:
7676
nebula.log.error(
77-
f"Unable to append {obj.type} ID {obj.id}. " f"Asset not found",
77+
f"Unable to append {obj.type} ID {obj.id}. Asset not found",
7878
user=user.name,
7979
)
8080
continue
8181

8282
if not can_append(asset, channel.rundown_accepts):
8383
nebula.log.error(
84-
f"Unable to append {obj.type} ID {obj.id}. "
85-
f"Asset not allowed",
84+
f"Unable to append {obj.type} ID {obj.id}. Asset not allowed",
8685
user=user.name,
8786
)
8887
continue

backend/api/scheduler/scheduler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ async def scheduler(
4848
if (event_at_position is not None) and event_at_position.id != event_data.id:
4949
# Replace event at position
5050

51-
assert (
52-
event_at_position.id is not None
53-
), "Event at position returned event without ID. This should not happen."
51+
assert event_at_position.id is not None, (
52+
"Event at position returned event without ID. This should not happen."
53+
)
5454
affected_events.append(event_at_position.id)
5555

5656
if event_data.id_asset:
@@ -88,9 +88,9 @@ async def scheduler(
8888
new_item["mark_out"] = asset["mark_out"]
8989
await new_item.save()
9090
ex_bin.items.append(new_item)
91-
assert (
92-
ex_bin.id is not None
93-
), "Bin ID should not be None at this point"
91+
assert ex_bin.id is not None, (
92+
"Bin ID should not be None at this point"
93+
)
9494
affected_bins.append(ex_bin.id)
9595

9696
# update the event

backend/nebula/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def hash_data(data: SerializableValue) -> str:
3232

3333
def create_hash() -> str:
3434
"""Create a pseudo-random hash (used as and access token)."""
35-
return hash_data([time.time(), random.random()])
35+
return hash_data([time.time(), random.random()]) # noqa: S311
3636

3737

3838
def sql_list(lst: list[Any], t: Literal["int", "str"] = "int") -> str:

backend/nebula/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
__all__ = ["db", "DB", "DatabaseConnection"]
22

3-
from typing import Any, AsyncGenerator
3+
from collections.abc import AsyncGenerator
4+
from typing import Any
45

56
import asyncpg
67
import asyncpg.pool

0 commit comments

Comments
 (0)