Skip to content

Commit 46d4c23

Browse files
authored
Merge pull request #1 from KolosalAI/dev
Pull from dev to Main
2 parents a0df88c + 237c504 commit 46d4c23

Some content is hidden

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

87 files changed

+33449
-3002
lines changed

.dockerignore

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1-
# ignore pycache
2-
**/__pycache__/
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
36

4-
# ignore venv folder
5-
venv/
7+
**/.DS_Store
8+
**/__pycache__
9+
**/.venv
10+
**/.classpath
11+
**/.dockerignore
12+
**/.env
13+
**/.git
14+
**/.gitignore
15+
**/.project
16+
**/.settings
17+
**/.toolstarget
18+
**/.vs
19+
**/.vscode
20+
**/*.*proj.user
21+
**/*.dbmdl
22+
**/*.jfm
23+
**/bin
24+
**/charts
25+
**/docker-compose*
26+
**/compose.y*ml
27+
**/Dockerfile*
28+
**/node_modules
29+
**/npm-debug.log
30+
**/obj
31+
**/secrets.dev.yaml
32+
**/values.dev.yaml
33+
LICENSE
34+
README.md

.github/workflows/basic.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Basic Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v4
18+
19+
- name: Set up Python
20+
run: uv python install 3.10
21+
22+
- name: Install dependencies
23+
run: |
24+
uv sync --extra dev
25+
26+
- name: Run tests
27+
run: |
28+
uv run pytest tests/unit/ -v --maxfail=5
File renamed without changes.

.github/workflows/test.yml.backup

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
validate:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
should_run: ${{ steps.changes.outputs.should_run }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Check if we should run tests
19+
id: changes
20+
run: |
21+
echo "should_run=true" >> $GITHUB_OUTPUT
22+
echo "Workflow validation passed"
23+
24+
- name: Validate pyproject.toml
25+
run: |
26+
python -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))" || \
27+
python -c "import tomli; tomli.load(open('pyproject.toml', 'rb'))" || \
28+
echo "Could not validate pyproject.toml, but continuing anyway"
29+
30+
test:
31+
needs: validate
32+
if: needs.validate.outputs.should_run == 'true'
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
os: [ubuntu-latest, windows-latest, macos-latest]
38+
python-version: ["3.10", "3.11", "3.12"]
39+
include:
40+
# Test with GPU on Ubuntu
41+
- os: ubuntu-latest
42+
python-version: "3.10"
43+
gpu: true
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v3
50+
with:
51+
version: "latest"
52+
53+
- name: Set up Python ${{ matrix.python-version }}
54+
run: uv python install ${{ matrix.python-version }}
55+
56+
- name: Install dependencies
57+
run: |
58+
uv sync --extra dev
59+
60+
- name: Download test models
61+
run: |
62+
uv run python tests/models/create_test_models.py
63+
continue-on-error: true
64+
65+
- name: Lint with ruff
66+
run: |
67+
uv run ruff check .
68+
69+
- name: Check formatting with black
70+
run: |
71+
uv run black --check .
72+
73+
- name: Check import sorting with isort
74+
run: |
75+
uv run isort --check-only .
76+
77+
- name: Type check with mypy
78+
run: |
79+
uv run mypy framework
80+
continue-on-error: true
81+
82+
- name: Run unit tests
83+
run: |
84+
uv run pytest tests/unit/ --cov=framework --cov-report=xml --junitxml=junit.xml -v
85+
86+
- name: Run integration tests
87+
run: |
88+
uv run pytest tests/integration/ --cov=framework --cov-append --cov-report=xml --junitxml=junit-integration.xml -v
89+
90+
- name: Run GPU tests
91+
if: matrix.gpu == true
92+
run: |
93+
# Only run if CUDA is available
94+
uv run python -c "import torch; exit(0 if torch.cuda.is_available() else 1)" && \
95+
uv run pytest -m gpu tests/ --cov=framework --cov-append --cov-report=xml -v || \
96+
echo "CUDA not available, skipping GPU tests"
97+
98+
- name: Security scan with bandit
99+
run: |
100+
uv run bandit -r framework -f json -o bandit-report.json
101+
uv run bandit -r framework
102+
continue-on-error: true
103+
104+
- name: Safety check
105+
run: |
106+
uv run safety check --json --output safety-report.json
107+
uv run safety check
108+
continue-on-error: true
109+
110+
- name: Upload coverage to Codecov
111+
uses: codecov/codecov-action@v3
112+
with:
113+
file: ./coverage.xml
114+
flags: unittests
115+
name: codecov-umbrella
116+
fail_ci_if_error: false
117+
118+
benchmark:
119+
needs: validate
120+
if: needs.validate.outputs.should_run == 'true'
121+
runs-on: ubuntu-latest
122+
steps:
123+
- uses: actions/checkout@v4
124+
125+
- name: Install uv
126+
uses: astral-sh/setup-uv@v3
127+
with:
128+
version: "latest"
129+
130+
- name: Set up Python
131+
run: uv python install 3.10
132+
133+
- name: Install dependencies
134+
run: |
135+
uv sync --extra dev
136+
137+
- name: Download test models
138+
run: |
139+
uv run python tests/models/create_test_models.py
140+
continue-on-error: true
141+
142+
- name: Run benchmarks
143+
run: |
144+
uv run pytest -m benchmark --benchmark-only --benchmark-json=benchmark.json tests/
145+
continue-on-error: true
146+
147+
- name: Store benchmark results
148+
uses: benchmark-action/github-action-benchmark@v1
149+
if: github.ref == 'refs/heads/main' && hashFiles('benchmark.json') != ''
150+
with:
151+
tool: 'pytest'
152+
output-file-path: benchmark.json
153+
github-token: ${{ secrets.GITHUB_TOKEN }}
154+
auto-push: true
155+
continue-on-error: true
156+
157+
docs:
158+
needs: validate
159+
if: needs.validate.outputs.should_run == 'true'
160+
runs-on: ubuntu-latest
161+
steps:
162+
- uses: actions/checkout@v4
163+
164+
- name: Install uv
165+
uses: astral-sh/setup-uv@v3
166+
with:
167+
version: "latest"
168+
169+
- name: Set up Python
170+
run: uv python install 3.10
171+
172+
- name: Install dependencies
173+
run: |
174+
uv sync --extra docs
175+
176+
- name: Check if mkdocs.yml exists
177+
run: |
178+
if [ -f "mkdocs.yml" ] || [ -f "mkdocs.yaml" ]; then
179+
echo "MkDocs configuration found"
180+
uv run mkdocs build --strict
181+
else
182+
echo "No MkDocs configuration found, skipping docs build"
183+
fi
184+
185+
- name: Deploy docs to GitHub Pages
186+
if: github.ref == 'refs/heads/main' && (hashFiles('mkdocs.yml') != '' || hashFiles('mkdocs.yaml') != '')
187+
run: |
188+
uv run mkdocs gh-deploy --force
189+
190+
docker:
191+
needs: validate
192+
if: needs.validate.outputs.should_run == 'true'
193+
runs-on: ubuntu-latest
194+
steps:
195+
- uses: actions/checkout@v4
196+
197+
- name: Set up Docker Buildx
198+
uses: docker/setup-buildx-action@v3
199+
200+
- name: Build Docker image
201+
uses: docker/build-push-action@v5
202+
with:
203+
context: .
204+
load: true
205+
tags: torch-inference:test
206+
207+
- name: Test in Docker
208+
run: |
209+
docker run --rm torch-inference:test python -m pytest tests/unit/ -v
210+
211+
release:
212+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
213+
needs: [validate, test, benchmark, docs, docker]
214+
runs-on: ubuntu-latest
215+
steps:
216+
- uses: actions/checkout@v4
217+
with:
218+
fetch-depth: 0
219+
220+
- name: Install uv
221+
uses: astral-sh/setup-uv@v3
222+
with:
223+
version: "latest"
224+
225+
- name: Set up Python
226+
run: uv python install 3.10
227+
228+
- name: Install dependencies
229+
run: |
230+
uv sync --extra dev
231+
uv add twine
232+
233+
- name: Build package
234+
run: |
235+
uv build
236+
237+
- name: Check package
238+
run: |
239+
uv run twine check dist/*
240+
241+
- name: Upload to Test PyPI
242+
if: success() && secrets.TEST_PYPI_API_TOKEN != ''
243+
uses: pypa/gh-action-pypi-publish@release/v1
244+
with:
245+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
246+
repository_url: https://test.pypi.org/legacy/
247+
skip_existing: true

0 commit comments

Comments
 (0)