Skip to content

Commit a0969d2

Browse files
authored
feat: make beeai-cli use frozen versions, split uv.lock (#909)
Signed-off-by: Jan Pokorný <[email protected]>
1 parent 77fa7bd commit a0969d2

File tree

100 files changed

+2172
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2172
-842
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Starting up the platform using the CLI (`beeai platform start`, even `mise beeai
4343
Build a local `ghcr.io/i-am-bee/beeai-platform/beeai-server:local` image using:
4444

4545
```sh
46-
mise beeai-server:image:build
46+
mise beeai-server:build
4747
```
4848

4949
Then, start the platform using:
@@ -156,7 +156,7 @@ To run BeeAI components in development mode (ensuring proper rebuilding), use th
156156
#### Server
157157
Build image and run the platform using:
158158
```shell
159-
mise run beeai-server:image:build
159+
mise run beeai-server:build
160160
mise run beeai-cli:run -- platform start --import ghcr.io/i-am-bee/beeai-platform/beeai-server:local --set image.tag=local
161161
```
162162
Or use development setup described in [Running and debugging individual components](#running-and-debugging-individual-components)

apps/beeai-cli/pyproject.toml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ dependencies = [
2222
"typer~=0.16.0",
2323
]
2424

25-
[tool.uv.sources]
26-
beeai-server = { workspace = true }
27-
beeai-sdk = { workspace = true }
25+
[dependency-groups]
26+
dev = [
27+
"pyright>=1.1.399",
28+
"pytest>=8.3.4",
29+
"ruff>=0.8.5",
30+
]
2831

2932
[project.scripts]
3033
beeai = "beeai_cli:app"
@@ -36,3 +39,28 @@ build-backend = "uv_build"
3639

3740
[tool.uv.build-backend]
3841
source-include = ["src/beeai_cli/data"]
42+
43+
[tool.ruff]
44+
line-length = 120
45+
target-version = "py313"
46+
lint.select = [
47+
"E", # pycodestyle errors
48+
"W", # pycodestyle warnings
49+
"F", # pyflakes
50+
"UP", # pyupgrade
51+
"I", # isort
52+
"B", # bugbear
53+
"N", # pep8-naming
54+
"C4", # Comprehensions
55+
"Q", # Quotes
56+
"SIM", # Simplify
57+
"RUF", # Ruff
58+
"TID", # tidy-imports
59+
"ASYNC", # async
60+
# TODO: add "DTZ", # DatetimeZ
61+
# TODO: add "ANN", # annotations
62+
]
63+
lint.ignore = [
64+
"E501" # line lenght (annyoing)
65+
]
66+
force-exclude = true

apps/beeai-cli/src/beeai_cli/utils.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from copy import deepcopy
1313
from enum import Enum
1414
from io import BytesIO
15-
from typing import TYPE_CHECKING, Any, Optional, TypeVar, cast
15+
from typing import TYPE_CHECKING, Any, Optional, cast
1616

1717
import anyio
1818
import typer
@@ -71,18 +71,11 @@ def check_json(value: Any) -> dict[str, Any]:
7171
raise typer.BadParameter(f"Invalid JSON '{value}'") from e
7272

7373

74-
DictType = TypeVar("DictType", bound=dict)
75-
76-
77-
def omit[DictType](dict: DictType, keys: Iterable[str]) -> DictType:
74+
def omit[DictType: dict](dict: DictType, keys: Iterable[str]) -> DictType:
7875
return {key: value for key, value in dict.items() if key not in keys}
7976

8077

81-
T = TypeVar("T")
82-
V = TypeVar("V")
83-
84-
85-
def filter_dict(map: dict[str, T | V], value_to_exclude: V = None) -> dict[str, V]:
78+
def filter_dict[T, V](map: dict[str, T | V], value_to_exclude: V = None) -> dict[str, V]:
8679
"""Remove entries with unwanted values (None by default) from dictionary."""
8780
return {filter: value for filter, value in map.items() if value is not value_to_exclude}
8881

apps/beeai-cli/tasks.toml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
# setup
2+
3+
["beeai-cli:setup"]
4+
dir = "{{config_root}}/apps/beeai-cli"
5+
run = "uv sync --all-extras --dev"
6+
sources = ["uv.lock", "pyproject.toml"]
7+
outputs = { auto = true }
8+
19
# check
210

311
["beeai-cli:check"]
412
depends = ["beeai-cli:check:*"]
513

614
["beeai-cli:check:ruff-check"]
7-
depends = ["setup:uv"]
15+
depends = ["beeai-cli:setup"]
816
dir = "{{config_root}}/apps/beeai-cli"
917
run = "uv run python -m ruff check --quiet"
1018
sources = ["src/**/*.py"]
1119
outputs = { auto = true }
1220

1321
["beeai-cli:check:ruff-format"]
14-
depends = ["setup:uv"]
22+
depends = ["beeai-cli:setup"]
1523
dir = "{{config_root}}/apps/beeai-cli"
1624
run = "uv run python -m ruff format --quiet --check"
1725
sources = ["src/**/*.py"]
@@ -30,14 +38,14 @@ outputs = { auto = true }
3038
depends = ["beeai-cli:fix:*"]
3139

3240
["beeai-cli:fix:ruff-check"]
33-
depends = ["setup:uv"]
41+
depends = ["beeai-cli:setup"]
3442
dir = "{{config_root}}/apps/beeai-cli"
3543
run = "uv run python -m ruff check --quiet --fix"
3644
sources = ["src/**/*.py"]
3745
outputs = { auto = true }
3846

3947
["beeai-cli:fix:ruff-format"]
40-
depends = ["setup:uv"]
48+
depends = ["beeai-cli:setup"]
4149
dir = "{{config_root}}/apps/beeai-cli"
4250
run = "uv run python -m ruff format --quiet"
4351
sources = ["src/**/*.py"]
@@ -47,8 +55,8 @@ outputs = { auto = true }
4755

4856
["beeai-cli:run"]
4957
description = "NOTE: Use double dash to pass extra args, like `mise beeai-cli:run -- provider list`"
50-
depends = ["setup:uv", "beeai-cli:build:copy-helm-chart"]
51-
dir = "{{cwd}}"
58+
depends = ["beeai-cli:setup", "beeai-cli:build:copy-helm-chart"]
59+
dir = "{{config_root}}/apps/beeai-cli"
5260
run = "uv run beeai"
5361

5462
# build
@@ -75,21 +83,34 @@ sources = ["{{config_root}}/helm/dist/beeai-platform-*.tgz"]
7583
outputs = ["./src/beeai_cli/data/helm-chart.tgz"]
7684

7785
["beeai-cli:build"]
78-
depends = ["setup:uv", "beeai-cli:build:*"]
86+
depends = ["beeai-cli:setup", "beeai-cli:build:*"]
7987
dir = "{{config_root}}/apps/beeai-cli"
8088
sources = ["src/**/*", "hatch_build.py", "pyproject.toml", "vendor/lima/**/*"]
8189
outputs = ["dist/**/*"]
8290
run = '''
8391
#!/usr/bin/env bash
8492
set -euo pipefail
8593
94+
# Build sdist and wheel
8695
rm -rf ./dist
8796
uv build -q --out-dir ./dist
88-
8997
export lima_version=$(yq -r '.tools["asdf:CrouchingMuppet/asdf-lima"]' ../../mise.toml)
9098
export version="$(yq -r '.project.version' pyproject.toml | tr -d -)"
9199
export universal_wheel=$(realpath "./dist/beeai_cli-$version-py3-none-any.whl")
92100
101+
# Pin versions from uv.lock in wheel
102+
tmpdir="$(mktemp -d)"
103+
unzip -q "$universal_wheel" "beeai_cli-${version}.dist-info/METADATA" -d "$tmpdir"
104+
insert_line=$(awk '/^Requires-Dist:/ {print FNR-1; exit}' "$tmpdir/beeai_cli-${version}.dist-info/METADATA" | cut -d: -f1)
105+
(
106+
head -n $insert_line "$tmpdir/beeai_cli-${version}.dist-info/METADATA"
107+
uv export --no-hashes --no-emit-workspace --format requirements-txt | awk '/^[[:space:]]*#/ {next} NF {print "Requires-Dist: " $0 }'
108+
awk -v insert_line="$insert_line" 'NR > insert_line && $0 !~ /^Requires-Dist:/' "$tmpdir/beeai_cli-${version}.dist-info/METADATA"
109+
) > "$tmpdir/beeai_cli-${version}.dist-info/METADATA.new"
110+
mv "$tmpdir/beeai_cli-${version}.dist-info/METADATA.new" "$tmpdir/beeai_cli-${version}.dist-info/METADATA"
111+
(cd "$tmpdir" && zip -q "$universal_wheel" "beeai_cli-${version}.dist-info/METADATA")
112+
113+
# Make platform-specific wheels by bundling limactl
93114
build_wheel() {
94115
wheel_tag="$1"
95116
hostagent_arch="$2"
@@ -104,12 +125,10 @@ build_wheel() {
104125
(cd "$tmpdir" && zip -q "$platform_wheel" -r .)
105126
rm -rf "$tmpdir"
106127
}
107-
108128
build_wheel manylinux_2_28_x86_64 x86_64 &
109129
build_wheel manylinux_2_28_aarch64 aarch64 &
110130
build_wheel macosx_12_0_x86_64 x86_64 &
111131
build_wheel macosx_12_0_arm64 aarch64 &
112-
113132
for job in $(jobs -p); do wait $job; done
114133
'''
115134

0 commit comments

Comments
 (0)