Spaces:
Sleeping
Sleeping
Download scripts/run_capped.sh from Mongoosetross/reverse-etymology: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/spaces/Mongoosetross/reverse-etymology/resolve/main/scripts/run_capped.sh
- Command line
-
hf download hf://spaces/Mongoosetross/reverse-etymology/scripts/run_capped.sh
-
curl -L -o run_capped.sh https://huggingface.co/spaces/Mongoosetross/reverse-etymology/resolve/main/scripts/run_capped.sh
767 Bytes
| # Run a pipeline command under a hard virtual-memory cap so a runaway job | |
| # dies with an allocation error instead of OOM-killing the whole VM. | |
| # | |
| # Usage: scripts/run_capped.sh [command...] | |
| # Env: ETYMOLOGY_MEMLIMIT_GIB (default 10). Set to 0 to disable ulimit. | |
| set -euo pipefail | |
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| cd "$ROOT" | |
| export PYTHONPATH="${PYTHONPATH:-$ROOT}" | |
| export PATH="${HOME}/.local/bin:${PATH}" | |
| GIB="${ETYMOLOGY_MEMLIMIT_GIB:-10}" | |
| if [[ "$GIB" != "0" ]]; then | |
| # ulimit -v is in KiB on Linux. | |
| KB="$(python3 -c "print(int(float('${GIB}') * 1024 * 1024))")" | |
| ulimit -v "$KB" | |
| echo "run_capped: ulimit -v ${KB} KiB (${GIB} GiB)" >&2 | |
| fi | |
| if [[ $# -eq 0 ]]; then | |
| echo "usage: $0 command [args...]" >&2 | |
| exit 2 | |
| fi | |
| exec "$@" | |