instance_swe_entry.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. source ~/.bashrc
  3. SWEUTIL_DIR=/swe_util
  4. # FIXME: Cannot read SWE_INSTANCE_ID from the environment variable
  5. # SWE_INSTANCE_ID=django__django-11099
  6. if [ -z "$SWE_INSTANCE_ID" ]; then
  7. echo "Error: SWE_INSTANCE_ID is not set." >&2
  8. exit 1
  9. fi
  10. # Read the swe-bench-test-lite.json file and extract the required item based on instance_id
  11. item=$(jq --arg INSTANCE_ID "$SWE_INSTANCE_ID" '.[] | select(.instance_id == $INSTANCE_ID)' $SWEUTIL_DIR/eval_data/instances/swe-bench-instance.json)
  12. if [[ -z "$item" ]]; then
  13. echo "No item found for the provided instance ID."
  14. exit 1
  15. fi
  16. WORKSPACE_NAME=$(echo "$item" | jq -r '(.repo | tostring) + "__" + (.version | tostring) | gsub("/"; "__")')
  17. echo "WORKSPACE_NAME: $WORKSPACE_NAME"
  18. # Clear the workspace
  19. if [ -d /workspace ]; then
  20. rm -rf /workspace/*
  21. else
  22. mkdir /workspace
  23. fi
  24. # Copy repo to workspace
  25. if [ -d /workspace/$WORKSPACE_NAME ]; then
  26. rm -rf /workspace/$WORKSPACE_NAME
  27. fi
  28. mkdir -p /workspace
  29. ln -s /testbed /workspace/$WORKSPACE_NAME
  30. # Activate instance-specific environment
  31. . /opt/miniconda3/etc/profile.d/conda.sh
  32. conda activate testbed