@@ -17,6 +17,7 @@ Optional arguments:
1717 --hf-namespace <user> Hugging Face username/organization (defaults to HF_USERNAME or meta-openenv)
1818 --staging-dir <path> Output directory for staging (defaults to hf-staging)
1919 --space-suffix <suffix> Suffix to add to space name (e.g., "-test" for test spaces)
20+ --private Deploy the space as private (default: public)
2021 --dry-run Prepare files without pushing to Hugging Face Spaces
2122 -h, --help Show this help message
2223
@@ -27,6 +28,7 @@ Positional compatibility:
2728Examples:
2829 scripts/deploy_to_hf.sh --env textarena_env --hf-namespace my-team
2930 scripts/deploy_to_hf.sh chat_env sha-0123456789abcdef
31+ scripts/deploy_to_hf.sh echo_env --private --hf-namespace my-org
3032EOF
3133}
3234
@@ -65,6 +67,7 @@ BASE_IMAGE_SHA=""
6567HF_NAMESPACE=" ${HF_NAMESPACE:- } " # Initialize from env var if set, otherwise empty
6668STAGING_DIR=" hf-staging"
6769SPACE_SUFFIX=" "
70+ PRIVATE=false
6871DRY_RUN=false
6972
7073while [[ $# -gt 0 ]]; do
@@ -89,6 +92,10 @@ while [[ $# -gt 0 ]]; do
8992 SPACE_SUFFIX=" $2 "
9093 shift 2
9194 ;;
95+ --private)
96+ PRIVATE=true
97+ shift
98+ ;;
9299 --dry-run)
93100 DRY_RUN=true
94101 shift
536543SPACE_REPO=" ${HF_NAMESPACE} /${ENV_NAME}${SPACE_SUFFIX} "
537544CURRENT_STAGING_DIR_ABS=$( cd " $CURRENT_STAGING_DIR " && pwd)
538545
546+ # Determine privacy flag (only add --private if needed, default is public)
547+ PRIVATE_FLAG=" "
548+ if [ " $PRIVATE " = true ]; then
549+ PRIVATE_FLAG=" --private"
550+ fi
551+
539552# create the space if it doesn't exist
540- hf repo create " $SPACE_REPO " --repo-type space --space_sdk docker --exist-ok --quiet > /dev/null 2>&1 || true
541- # upload the staged content
542- SPACE_UPLOAD_RESULT=$( hf upload --repo-type=space --quiet " $SPACE_REPO " " $CURRENT_STAGING_DIR_ABS " )
553+ hf repo create " $SPACE_REPO " --repo-type space --space_sdk docker --exist-ok $PRIVATE_FLAG --quiet > /dev/null 2>&1 || true
554+ # upload the staged content (if repo doesn't exist, it will be created with the privacy setting)
555+ SPACE_UPLOAD_RESULT=$( hf upload --repo-type=space $PRIVATE_FLAG --quiet " $SPACE_REPO " " $CURRENT_STAGING_DIR_ABS " )
543556if [ $? -ne 0 ]; then
544557 echo " ❌ Upload failed: $SPACE_UPLOAD_RESULT " >&2
545558 exit 1
0 commit comments