version_control.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. checkout_eval_branch() {
  2. if [ -z "$COMMIT_HASH" ]; then
  3. echo "Commit hash not specified, use current git commit"
  4. build_sandbox
  5. return 0
  6. fi
  7. if git diff --quiet $COMMIT_HASH HEAD; then
  8. echo "The given hash is equivalent to the current HEAD"
  9. build_sandbox
  10. return 0
  11. fi
  12. echo "Start to checkout opendevin version to $COMMIT_HASH, but keep current evaluation harness"
  13. if ! git diff-index --quiet HEAD --; then
  14. echo "There are uncommitted changes, please stash or commit them first"
  15. exit 1
  16. fi
  17. current_branch=$(git rev-parse --abbrev-ref HEAD)
  18. echo "Current version is: $current_branch"
  19. echo "Check out OpenDevin to version: $COMMIT_HASH"
  20. if ! git checkout $COMMIT_HASH; then
  21. echo "Failed to check out to $COMMIT_HASH"
  22. exit 1
  23. fi
  24. echo "Revert changes in evaluation folder"
  25. git checkout $current_branch -- evaluation
  26. # Trap the EXIT signal to checkout original branch
  27. trap checkout_original_branch EXIT
  28. build_sandbox
  29. }
  30. build_sandbox() {
  31. echo "Build sandbox locally"
  32. docker build -t eval-sandbox -f containers/sandbox/Dockerfile /tmp
  33. export SANDBOX_CONTAINER_IMAGE="eval-sandbox"
  34. }
  35. checkout_original_branch() {
  36. if [ -z "$current_branch" ]; then
  37. return 0
  38. fi
  39. echo "Checkout back to original branch $current_branch"
  40. git checkout $current_branch
  41. }
  42. get_agent_version() {
  43. # IMPORTANT: Because Agent's prompt changes fairly often in the rapidly evolving codebase of OpenDevin
  44. # We need to track the version of Agent in the evaluation to make sure results are comparable
  45. AGENT_VERSION=v$(poetry run python -c "import agenthub; from opendevin.controller.agent import Agent; print(Agent.get_cls('$AGENT').VERSION)")
  46. }