-
-
Notifications
You must be signed in to change notification settings - Fork 300
328 lines (301 loc) · 13 KB
/
pre_compiled.yml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: Pre-Compiled and Upload
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
.\run-install.bat
.\env\python.exe core.py "prerequisites" --models "True" --exe "True" --pretraineds_v1_f0 "False" --pretraineds_v2_f0 "True" --pretraineds_v1_nof0 "False" --pretraineds_v2_nof0 "False"
- name: Clean up unnecessary files
run: |
Remove-Item -Path 'LICENSE', 'run-tensorboard.sh', 'run-install.sh', 'run-applio.sh', 'run-install.bat', 'requirements.txt', '.gitignore', '.github', '.git' -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem -Path . -Include __pycache__ -Recurse -Directory | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
- name: Read version from config.json
id: get-version
run: |
$version = (Get-Content -Path './assets/config.json' | ConvertFrom-Json).version
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Create ZIP file
run: |
$version = '${{ steps.get-version.outputs.version }}'
Compress-Archive -Path 'D:\a\Applio\Applio\*' -DestinationPath "D:\a\Applio\ApplioV$version.zip"
- name: Upload Windows Compiled
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
version: ${{ steps.get-version.outputs.version }}
run: |
.\env\python.exe -c "
import os
from huggingface_hub import login, upload_file
token = os.getenv('HF_TOKEN')
version = os.getenv('version')
login(token)
repo_id = 'IAHispano/Applio'
repo_file_path = f'D:/a/Applio/ApplioV{version}.zip'
upload_file(
commit_message=f'{version}',
path_or_fileobj=repo_file_path,
path_in_repo=f'Compiled/Windows/ApplioV{version}.zip',
repo_id=repo_id,
token=token)
"
Linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10.12"]
steps:
- uses: actions/checkout@v4
- name: Free up space on runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Read version from config.json
id: get-version
run: |
version=$(jq -r '.version' assets/config.json)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create virtual environment
run: |
pip install huggingface_hub
python -m venv .venv
. .venv/bin/activate
python -m ensurepip
python -m pip install "pip<24.1"
python -m pip install -r requirements.txt
python -m pip install torch==2.3.1 torchvision torchaudio --upgrade --index-url https://download.pytorch.org/whl/cu121
python core.py "prerequisites" --models "True" --exe "True" --pretraineds_v1_f0 "False" --pretraineds_v2_f0 "True" --pretraineds_v1_nof0 "False" --pretraineds_v2_nof0 "False"
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
deactivate
rm -f .venv/bin/Activate.ps1 .venv/bin/activate .venv/bin/activate.csh .venv/bin/activate.fish .venv/bin/pip .venv/bin/pip3 .venv/bin/pip3.10 .venv/bin/python .venv/bin/python3 .venv/bin/python3.10
- name: Clean up unnecessary files
run: |
rm -f LICENSE run-tensorboard.bat run-install.bat run-applio.bat run-install.sh requirements.txt .gitignore
rm -rf .github .git
- name: Create ZIP file
run: |
zip -9 -r ApplioV${{ steps.get-version.outputs.version }}.zip .
- name: Upload Linux Compiled
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
version: ${{ steps.get-version.outputs.version }}
run: |
python -c "
import os
from huggingface_hub import login, upload_file
token = os.getenv('HF_TOKEN')
version = os.getenv('version')
login(token)
repo_id = 'IAHispano/Applio'
repo_file_path = f'ApplioV{version}.zip'
upload_file(
commit_message=f'{version}',
path_or_fileobj=repo_file_path,
path_in_repo=f'Compiled/Linux/ApplioV{version}.zip',
repo_id=repo_id,
token=token)
"
Kaggle:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10.12"]
steps:
- uses: actions/checkout@v4
- name: Free up space on runner
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Read version from config.json
id: get-version
run: |
version=$(jq -r '.version' assets/config.json)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Install uv and create virtual environment
run: |
sudo apt-get install -y pigz
sudo apt-get install -y pv
pip install uv huggingface_hub
uv venv .venv --python 3.10.12
uv pip install -r requirements.txt
uv pip install https://github.com/IAHispano/imjoy-elfinder.git
uv pip uninstall torch torchvision torchaudio
. .venv/bin/activate
python -m ensurepip
python -m pip install "pip<24.1"
python -m pip install torch==2.3.1 torchvision torchaudio --upgrade --index-url https://download.pytorch.org/whl/cu121
deactivate
wget https://huggingface.co/IAHispano/Applio/resolve/main/Enviroment/Kaggle/bin_kaggle.tar.gz?download=true -O bin_kaggle.tar.gz
tar -xzf bin_kaggle.tar.gz
cp -r bin/* .venv/bin/
rm -rf bin
rm bin_kaggle.tar.gz
rm -f .venv/pyvenv.cfg .venv/bin/activate .venv/bin/activate.bat .venv/bin/activate.csh .venv/bin/activate.fish .venv/bin/activate.nu .venv/bin/activate.ps1 .venv/bin/activate_this.py .venv/bin/deactivate.bat .venv/bin/pydoc.bat .venv/bin/python .venv/bin/python3 .venv/bin/python3.10
- name: Create TAR Env
run: |
tar --use-compress-program="pigz --best --recursive | pv" -cvf KaggleV2.tar.gz .venv
- name: Upload Kaggle Env
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
version: ${{ steps.get-version.outputs.version }}
run: |
python -c "
import os
from huggingface_hub import login, upload_file
token = os.getenv('HF_TOKEN')
version = os.getenv('version')
login(token)
repo_id = 'IAHispano/Applio'
repo_file_path = 'KaggleV2.tar.gz'
upload_file(
commit_message=f'{version}',
path_or_fileobj=repo_file_path,
path_in_repo=f'Enviroment/Kaggle/{repo_file_path}',
repo_id=repo_id,
token=token)
"
Colab:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download and extract pre-packaged dependencies
run: |
wget https://huggingface.co/IAHispano/Applio/resolve/main/Enviroment/Colab/tmp_packages.tar.gz?download=true -O prepackaged.tar.gz
tar -xzf prepackaged.tar.gz -C /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/
- name: Read version from config.json
id: get-version
run: |
version=$(jq -r '.version' assets/config.json)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Record initial state of site-packages
run: |
python -c "
import csv
import os
def scan_and_write(base_path, output_file):
with open(output_file, 'w', newline='') as f:
writer = csv.writer(f)
for dirpath, dirs, files in os.walk(base_path):
for filename in files:
fname = os.path.join(dirpath, filename)
try:
mtime = os.path.getmtime(fname)
writer.writerow([fname, mtime])
except Exception as e:
print(f'Skipping irrelevant nonexistent file {fname}: {str(e)}')
print(f'Finished recording filesystem timestamps to {output_file}.')
scan_and_write(\"/opt/hostedtoolcache/Python/3.10.12/x64\", \"./usr_files.csv\")"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install torch==2.3.1 torchvision torchaudio --upgrade --index-url https://download.pytorch.org/whl/cu121
- name: Record final state of site-packages
run: |
python -c "
import csv
import os
def scan_and_write(base_path, output_file):
with open(output_file, 'w', newline='') as f:
writer = csv.writer(f)
for dirpath, dirs, files in os.walk(base_path):
for filename in files:
fname = os.path.join(dirpath, filename)
try:
mtime = os.path.getmtime(fname)
writer.writerow([fname, mtime])
except Exception as e:
print(f'Skipping irrelevant nonexistent file {fname}: {str(e)}')
print(f'Finished recording filesystem timestamps to {output_file}.')
scan_and_write(\"/opt/hostedtoolcache/Python/3.10.12/x64\", \"./usr_files_new.csv\")"
- name: Create TAR file
run: |
python -c "
import tarfile
import os
from tqdm import tqdm
import csv
def compare_files(old_file, new_file):
old_files = {}
new_files = {}
with open(old_file, 'r') as f:
reader = csv.reader(f)
old_files = {rows[0]: rows[1] for rows in reader}
with open(new_file, 'r') as f:
reader = csv.reader(f)
new_files = {rows[0]: rows[1] for rows in reader}
removed_files = old_files.keys() - new_files.keys()
added_files = new_files.keys() - old_files.keys()
unchanged_files = old_files.keys() & new_files.keys()
changed_files = {f for f in unchanged_files if old_files[f] != new_files[f]}
for file in removed_files:
print(f'File has been removed: {file}')
for file in changed_files:
print(f'File has been updated: {file}')
return list(added_files) + list(changed_files)
changed_files = compare_files('./usr_files.csv', './usr_files_new.csv')
base_dir = '/opt/hostedtoolcache/Python/3.10.12/x64/'
arc_base_dir = 'usr/local/'
with tarfile.open('./Pnpur.tar.gz', 'w:gz') as new_tar:
for file in tqdm(changed_files, desc='Compressing', unit='files'):
relative_path = os.path.relpath(file, base_dir)
if 'python3.10' in relative_path:
if 'site-packages' not in relative_path:
continue
if 'site-packages' in relative_path:
relative_path = relative_path.replace('site-packages', 'dist-packages')
new_path = os.path.join(arc_base_dir, relative_path)
new_tar.add(file, arcname=new_path)
"
- name: Upload Colab Env
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
version: ${{ steps.get-version.outputs.version }}
run: |
python -c "
import os
from huggingface_hub import login, upload_file
token = os.getenv('HF_TOKEN')
version = os.getenv('version')
login(token)
repo_id = 'IAHispano/Applio'
repo_file_path = 'Pnpur.tar.gz'
upload_file(
commit_message=f'{version}',
path_or_fileobj=repo_file_path,
path_in_repo=f'Enviroment/Colab/{repo_file_path}',
repo_id=repo_id,
token=token)
"