Spaces:
Running
Running
| set -e | |
| export HF_ENDPOINT="https://hf-mirror.com" | |
| if [ -z "$HF_TOKEN" ]; then | |
| echo "ERROR: HF_TOKEN not set." | |
| exit 1 | |
| fi | |
| VERSION="${HF_SOURCE_VERSION:-latest}" | |
| FILENAME="code-kg-chat-${VERSION}.tar.gz" | |
| echo "Downloading ${FILENAME} from ${HF_DATASET_ID}..." | |
| python3 -c " | |
| from huggingface_hub import hf_hub_download | |
| import tarfile, os, shutil | |
| path = hf_hub_download( | |
| repo_id='${HF_DATASET_ID}', | |
| filename='${FILENAME}', | |
| repo_type='dataset', | |
| token='${HF_TOKEN}', | |
| ) | |
| print(f'Downloaded: {path}') | |
| for item in os.listdir('/app'): | |
| full = os.path.join('/app', item) | |
| if os.path.isdir(full): | |
| shutil.rmtree(full) | |
| else: | |
| os.remove(full) | |
| with tarfile.open(path, 'r:gz') as tar: | |
| tar.extractall('/app') | |
| print('Extraction complete.') | |
| " | |
| exec python3 /app/server.py --auto-approve-source | |