-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
105 lines (92 loc) · 3.4 KB
/
justfile
File metadata and controls
105 lines (92 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
set shell := ["bash", "-euo", "pipefail", "-c"]
mode_file := ".fair-mode"
mode := `cat .fair-mode 2>/dev/null || echo local`
[private]
_sync := if mode == "k8s" { "--group dev --group local --group docs --group example --extra k8s" } else { "--group dev --group local --group docs --group example" }
[doc('Show current mode and available recipes')]
default:
@echo "mode: {{ mode }}"
@echo ""
@just --list --unsorted
[doc('Switch to local mode')]
local:
@echo local > {{ mode_file }} && echo "mode: local"
[doc('Switch to k8s mode')]
k8s:
@echo k8s > {{ mode_file }} && echo "mode: k8s"
[doc('Install dependencies and configure tools')]
setup:
#!/usr/bin/env bash
set -euo pipefail
uv sync {{ _sync }}
if [[ "$(cat {{ mode_file }} 2>/dev/null || echo local)" == "k8s" ]]; then
missing=""
for cmd in kind kubectl helm helmfile mc; do
command -v "$cmd" >/dev/null 2>&1 || missing="$missing $cmd"
done
[[ -z "$missing" ]] || { echo "Missing:$missing"; exit 1; }
fi
uv run pre-commit install --hook-type commit-msg --hook-type pre-commit
uv run zenml init
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES uv run zenml login --local
[doc('Lint and format')]
lint:
uv run ruff check --fix . && uv run ruff format . && uv run ty check
[doc('Remove ZenML state and artifacts')]
clean:
#!/usr/bin/env bash
set -euo pipefail
if [[ "$(cat {{ mode_file }} 2>/dev/null || echo local)" == "k8s" ]]; then
just --justfile infra/dev/justfile tear
fi
uv run zenml clean -y
rm -rf .zen artifacts dist *.egg-info
[doc('Run tests')]
test:
uv run pytest tests/ -v
[doc('Run model tests inside Docker (requires built images)')]
test-models model="":
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "{{ model }}" ]]; then
dirs=("models/{{ model }}")
else
dirs=(models/*/tests)
dirs=("${dirs[@]%/tests}")
fi
for model_dir in "${dirs[@]}"; do
name=$(basename "$model_dir")
echo "=== Testing $name ==="
docker build -f "$model_dir/Dockerfile" -t "fair-models/$name:test" .
echo "Step tests :"
docker run --rm --entrypoint "" \
-e FAIR_FORCE_CPU=1 \
"fair-models/$name:test" \
bash -c "pip install pytest && python -m pytest models/$name/tests/ -v --tb=short"
echo "Integration test :"
docker run --rm --entrypoint "" \
-e FAIR_FORCE_CPU=1 \
"fair-models/$name:test" \
bash -c "pip install pytest 'zenml[server]' && python -m pytest models/test_integration.py -v --tb=short -m slow --model-dir=models/$name"
done
[doc('Validate STAC items and model pipelines')]
validate:
uv run python scripts/validate_stac_items.py && uv run python scripts/validate_model.py
[doc('Serve documentation locally')]
docs:
uv sync --group docs && uv run zensical serve
[doc('Run all example pipelines')]
example:
#!/usr/bin/env bash
set -euo pipefail
if [[ "$(cat {{ mode_file }} 2>/dev/null || echo local)" == "k8s" ]]; then
just --justfile infra/dev/justfile run-example
else
for ex in segmentation classification detection; do
uv run python "examples/$ex/run.py" clean
uv run python "examples/$ex/run.py" all
done
fi
[doc('Run pre-commit hooks and commitizen')]
commit:
uv run pre-commit run --all-files && uv run cz commit