Skip to content

Commit 74e34bf

Browse files
authored
Merge pull request #1 from EmbeddedLLM/main
[Upstream] Merge from upstream to bump v0.0.43 to v0.0.65
2 parents e5e5704 + 4e380e1 commit 74e34bf

File tree

173 files changed

+16699
-2765
lines changed

Some content is hidden

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

173 files changed

+16699
-2765
lines changed

.github/ISSUE_TEMPLATE/feature-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ body:
2828
attributes:
2929
label: Your contribution
3030
description: |
31-
Is there any way that you could help, e.g. by submitting a PR? Make sure to read the [contribution guidelines](https://michaelfeil.eu/infinity)
31+
Is there any way that you could help, e.g. by submitting a PR? Make sure to read the [contribution guidelines](https://michaelfeil.github.io/infinity)
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# This code is adapted from jlumbroso/free-disk-space
2+
# Original Author: jlumbroso
3+
# Original Source: https://github.com/jlumbroso/free-disk-space
4+
5+
name: "Free Disk Space (Ubuntu)"
6+
description: "A configurable GitHub Action to free up disk space on an Ubuntu GitHub Actions runner."
7+
8+
# See: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
9+
branding:
10+
icon: "trash-2"
11+
color: "green"
12+
13+
inputs:
14+
android:
15+
description: "Remove Android runtime"
16+
required: false
17+
default: "true"
18+
dotnet:
19+
description: "Remove .NET runtime"
20+
required: false
21+
default: "true"
22+
haskell:
23+
description: "Remove Haskell runtime"
24+
required: false
25+
default: "true"
26+
27+
# option inspired by:
28+
# https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
29+
large-packages:
30+
description: "Remove large packages"
31+
required: false
32+
default: "true"
33+
34+
docker-images:
35+
description: "Remove Docker images"
36+
required: false
37+
default: "true"
38+
39+
# option inspired by:
40+
# https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
41+
tool-cache:
42+
description: "Remove image tool cache"
43+
required: false
44+
default: "false"
45+
46+
swap-storage:
47+
description: "Remove swap storage"
48+
required: false
49+
default: "true"
50+
51+
runs:
52+
using: "composite"
53+
steps:
54+
- shell: bash
55+
run: |
56+
# ======
57+
# MACROS
58+
# ======
59+
# macro to print a line of equals
60+
# (silly but works)
61+
printSeparationLine() {
62+
str=${1:=}
63+
num=${2:-80}
64+
counter=1
65+
output=""
66+
while [ $counter -le $num ]
67+
do
68+
output="${output}${str}"
69+
counter=$((counter+1))
70+
done
71+
echo "${output}"
72+
}
73+
# macro to compute available space
74+
# REF: https://unix.stackexchange.com/a/42049/60849
75+
# REF: https://stackoverflow.com/a/450821/408734
76+
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }
77+
# macro to make Kb human readable (assume the input is Kb)
78+
# REF: https://unix.stackexchange.com/a/44087/60849
79+
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
80+
# macro to output saved space
81+
printSavedSpace() {
82+
saved=${1}
83+
title=${2:-}
84+
echo ""
85+
printSeparationLine '*' 80
86+
if [ ! -z "${title}" ]; then
87+
echo "=> ${title}: Saved $(formatByteCount $saved)"
88+
else
89+
echo "=> Saved $(formatByteCount $saved)"
90+
fi
91+
printSeparationLine '*' 80
92+
echo ""
93+
}
94+
# macro to print output of dh with caption
95+
printDH() {
96+
caption=${1:-}
97+
printSeparationLine '=' 80
98+
echo "${caption}"
99+
echo ""
100+
echo "$ dh -h /"
101+
echo ""
102+
df -h /
103+
echo "$ dh -a /"
104+
echo ""
105+
df -a /
106+
echo "$ dh -a"
107+
echo ""
108+
df -a
109+
printSeparationLine '=' 80
110+
}
111+
# ======
112+
# SCRIPT
113+
# ======
114+
# Display initial disk space stats
115+
AVAILABLE_INITIAL=$(getAvailableSpace)
116+
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')
117+
printDH "BEFORE CLEAN-UP:"
118+
echo ""
119+
# Option: Remove Android library
120+
if [[ ${{ inputs.android }} == 'true' ]]; then
121+
BEFORE=$(getAvailableSpace)
122+
123+
sudo rm -rf /usr/local/lib/android || true
124+
AFTER=$(getAvailableSpace)
125+
SAVED=$((AFTER-BEFORE))
126+
printSavedSpace $SAVED "Android library"
127+
fi
128+
# Option: Remove .NET runtime
129+
if [[ ${{ inputs.dotnet }} == 'true' ]]; then
130+
BEFORE=$(getAvailableSpace)
131+
# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
132+
sudo rm -rf /usr/share/dotnet || true
133+
134+
AFTER=$(getAvailableSpace)
135+
SAVED=$((AFTER-BEFORE))
136+
printSavedSpace $SAVED ".NET runtime"
137+
fi
138+
# Option: Remove Haskell runtime
139+
if [[ ${{ inputs.haskell }} == 'true' ]]; then
140+
BEFORE=$(getAvailableSpace)
141+
sudo rm -rf /opt/ghc || true
142+
sudo rm -rf /usr/local/.ghcup || true
143+
144+
AFTER=$(getAvailableSpace)
145+
SAVED=$((AFTER-BEFORE))
146+
printSavedSpace $SAVED "Haskell runtime"
147+
fi
148+
# Option: Remove large packages
149+
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
150+
if [[ ${{ inputs.large-packages }} == 'true' ]]; then
151+
BEFORE=$(getAvailableSpace)
152+
153+
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
154+
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."
155+
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."
156+
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."
157+
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."
158+
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
159+
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
160+
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..."
161+
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..."
162+
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
163+
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
164+
AFTER=$(getAvailableSpace)
165+
SAVED=$((AFTER-BEFORE))
166+
printSavedSpace $SAVED "Large misc. packages"
167+
fi
168+
# Option: Remove Docker images
169+
if [[ ${{ inputs.docker-images }} == 'true' ]]; then
170+
BEFORE=$(getAvailableSpace)
171+
sudo docker image prune --all --force || true
172+
AFTER=$(getAvailableSpace)
173+
SAVED=$((AFTER-BEFORE))
174+
printSavedSpace $SAVED "Docker images"
175+
fi
176+
# Option: Remove tool cache
177+
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
178+
if [[ ${{ inputs.tool-cache }} == 'true' ]]; then
179+
BEFORE=$(getAvailableSpace)
180+
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
181+
182+
AFTER=$(getAvailableSpace)
183+
SAVED=$((AFTER-BEFORE))
184+
printSavedSpace $SAVED "Tool cache"
185+
fi
186+
# Option: Remove Swap storage
187+
if [[ ${{ inputs.swap-storage }} == 'true' ]]; then
188+
BEFORE=$(getAvailableSpace)
189+
sudo swapoff -a || true
190+
sudo rm -f /mnt/swapfile || true
191+
free -h
192+
193+
AFTER=$(getAvailableSpace)
194+
SAVED=$((AFTER-BEFORE))
195+
printSavedSpace $SAVED "Swap storage"
196+
fi
197+
# Output saved space statistic
198+
AVAILABLE_END=$(getAvailableSpace)
199+
AVAILABLE_ROOT_END=$(getAvailableSpace '/')
200+
echo ""
201+
printDH "AFTER CLEAN-UP:"
202+
echo ""
203+
echo ""
204+
echo "/dev/root:"
205+
printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL))
206+
echo "overall:"
207+
printSavedSpace $((AVAILABLE_END - AVAILABLE_INITIAL))

.github/workflows/ci.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
branches:
1313
- main
1414
- dev
15+
schedule: # nightly
16+
- cron: '0 0 * * *'
1517
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
1618

1719
# If another push to the same PR or branch happens while this workflow is still running,
@@ -29,17 +31,34 @@ env:
2931
WORKDIR: "libs/infinity_emb"
3032

3133
jobs:
32-
lint:
34+
lint-infinity_emb:
3335
uses:
3436
./.github/workflows/linting.yaml
3537
with:
3638
working-directory: libs/infinity_emb
3739
secrets: inherit
3840

39-
test:
41+
lint-embed_package:
42+
uses:
43+
./.github/workflows/linting.yaml
44+
with:
45+
working-directory: libs/embed_package
46+
extra_poetry: "--with test,lint,codespell"
47+
secrets: inherit
48+
49+
test-infinity_emb:
4050
uses:
4151
./.github/workflows/test.yaml
4252
with:
4353
working-directory: libs/infinity_emb
4454
upload_coverage: true
55+
secrets: inherit
56+
57+
test-embed_package:
58+
uses:
59+
./.github/workflows/test.yaml
60+
with:
61+
working-directory: libs/embed_package
62+
upload_coverage: false
63+
extra_poetry: "--with test"
4564
secrets: inherit

.github/workflows/docs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ jobs:
1212
deploy:
1313
runs-on: ubuntu-latest
1414
steps:
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: 3.11
1518
- uses: actions/checkout@v4
1619
with:
1720
fetch-depth: 0
1821
- name: Configure Git Credentials
1922
run: |
2023
git config user.name github-actions[bot]
2124
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
22-
- uses: actions/setup-python@v5
23-
with:
24-
python-version: 3.11
2525
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
2626
- uses: actions/cache@v4
2727
with:

.github/workflows/linting.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
required: true
88
type: string
99
description: "From which folder this pipeline executes"
10+
extra_poetry:
11+
description: 'Extra poetry commands to run'
12+
required: false
13+
type: string
14+
default: "--extras all --with test,lint,codespell"
1015

1116
env:
1217
POETRY_VERSION: "1.7.1"
@@ -32,8 +37,11 @@ jobs:
3237
- "3.9"
3338
- "3.12"
3439
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
3543
- name: Free Disk Space
36-
uses: jlumbroso/free-disk-space@v1.3.0
44+
uses: "./.github/actions/disk_cleanup"
3745
if: runner.os == 'Linux'
3846
with:
3947
tool-cache: false
@@ -43,7 +51,6 @@ jobs:
4351
large-packages: false
4452
docker-images: false
4553
swap-storage: false
46-
- uses: actions/checkout@v4
4754

4855
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
4956
uses: "./.github/actions/poetry_setup"
@@ -76,13 +83,7 @@ jobs:
7683
# It doesn't matter how you change it, any change will cause a cache-bust .
7784
working-directory: ${{ inputs.working-directory }}
7885
run: |
79-
poetry install --extras "all" --with test,lint,codespell
80-
81-
# - name: Install infinity_emb editable
82-
# working-directory: ${{ inputs.working-directory }}
83-
# if: ${{ inputs.working-directory != 'libs/infinity_emb' }}
84-
# run: |
85-
# pip install -e ../infinity_emb
86+
poetry install ${{ inputs.extra_poetry }}
8687
8788
- name: Get .mypy_cache to speed up mypy
8889
uses: actions/cache@v4

.github/workflows/pypi_release.yaml

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,52 +49,4 @@ jobs:
4949
with:
5050
packages-dir: ${{ env.WORKDIR }}/dist/
5151
verbose: true
52-
print-hash: true
53-
54-
post-test-pypi-publish:
55-
defaults:
56-
run:
57-
working-directory: ${{ env.WORKDIR }}
58-
59-
needs: publish-to-pypi
60-
61-
strategy:
62-
matrix:
63-
python-version:
64-
- "3.9"
65-
- "3.10"
66-
- "3.11"
67-
- "3.12"
68-
os:
69-
# get tag only works on Linux
70-
- ubuntu-latest
71-
runs-on: ${{ matrix.os }}
72-
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
73-
steps:
74-
- uses: actions/checkout@v4
75-
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
76-
uses: "./.github/actions/poetry_setup"
77-
with:
78-
python-version: ${{ matrix.python-version }}
79-
poetry-version: ${{ env.POETRY_VERSION }}
80-
working-directory: ${{ inputs.working-directory }}
81-
cache-key: core-release-publish
82-
83-
- name: Get git tag
84-
uses: actions-ecosystem/action-get-latest-tag@v1
85-
id: get-latest-tag
86-
- name: Set docker tag
87-
env:
88-
VERSION: ${{ steps.get-latest-tag.outputs.tag }}
89-
run: |
90-
echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
91-
92-
- name: Install minimal dependencies and import
93-
shell: bash
94-
run: |
95-
sleep 30
96-
poetry run pip install "infinity-emb[server]==${{ env.VERSION }}"
97-
poetry run infinity_emb --help
98-
poetry run python -c "import infinity_emb"
99-
# print version
100-
echo version=$(poetry run python -c "import infinity_emb;print(infinity_emb.__version__)") >> $GITHUB_OUTPUT
52+
print-hash: true

0 commit comments

Comments
 (0)