princeton-nlp / SWE-agent

SWE-agent takes a GitHub issue and tries to automatically fix it, using GPT-4, or your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
https://princeton-nlp.github.io/SWE-agent/
MIT License
13.49k stars 1.35k forks source link

Astropy environment setup issues #669

Closed rookielyb closed 2 months ago

rookielyb commented 3 months ago

Describe the issue

~python run.py --model_name gpt4 --instance_filter astropy__astropy-14182 --config_file config/roles/default.yml ~

Edit @klieret : actually need to run:

 python run.py --model_name instant_empty_submit --instance_filter astropy__astropy-14182 --config_file config/default.yaml --split test 

Optional: Relevant documentation page

No response

rookielyb commented 3 months ago

After checking the logs, I found that errors occurred when installing packages after creating the Python environment.
image image However, when I manually create a Docker container and run the following commands, it succeeds!!! docker run -it --rm --name sweagent-swe-agent-latest-b9808c3a3c sweagent/swe-agent:latest

conda create --name astropyastropy5.1 --clone python3.9

source activate astropyastropy5.1 && pip install attrs==23.1.0 exceptiongroup==1.1.3 execnet==2.0.2 hypothesis==6.82.6 iniconfig==2.0.0 numpy==1.25.2 packaging==23.1 pluggy==1.3.0 psutil==5.9.5 pyerfa==2.0.0.3 pytest-arraydiff==0.5.0 pytest-astropy-header==0.2.2 pytest-astropy==0.10.0 pytest-cov==4.1.0 pytest-doctestplus==1.0.0 pytest-filter-subpackage==0.1.2 pytest-mock==3.11.1 pytest-openfiles==0.5.0 pytest-remotedata==0.4.0 pytest-xdist==3.3.1 pytest==7.4.0 PyYAML==6.0.1 setuptools==68.0.0 sortedcontainers==2.4.0 tomli==2.0.1

image

rookielyb commented 3 months ago

when I change 'pip install' to 'conda install' , also fail, The same error occurs, but the error message is different. image I use mac,Looking forward to your response.

adazhng commented 3 months ago

same mistake, looks like this bug relevant to https://github.com/princeton-nlp/SWE-bench/pull/130/files/708ca5b2538ba9614b8cbb58a1c88de41accc6c5#diff-85aea2e353bd26d60ba79c7eadb877870f9f6adb2b1df9718dc327e497f0a34d

klieret commented 3 months ago

So this is mostly going to be a SWE-bench issue, however currently we have capped the SWE-bench version because we haven't updated SWE-agent to use the new SWE-bench (see #624)

rookielyb commented 3 months ago

Thank you very much for your response. Since this issue is occurring with multiple tasks, how should I resolve this problem now? Should I wait for your latest release of swe-agent? Thanks! image

klieret commented 3 months ago

I'll update swe-agent today to remove the swe-bench version cap. Then, let's update swe-bench to the latest version and see if this still persists.

rookielyb commented 3 months ago

I'll update swe-agent today to remove the swe-bench version cap. Then, let's update swe-bench to the latest version and see if this still persists.

Thank you for your hard work, I am very much looking forward to it!

rookielyb commented 3 months ago

I reviewed your related code changes and used your recently modified code. After updating the swebench version, the error still occurs. Is the code update for this issue still ongoing?

I'll update swe-agent today to remove the swe-bench version cap. Then, let's update swe-bench to the latest version and see if this still persists.

rookielyb commented 3 months ago

Using the latest code swebench==2.0.11 solved the issue regarding astropyastropy-14182, but I encountered two new issues. One involves matplotlibmatplotlib-25433 (refer to Figure 1), and the other is pydata__xarray-4094. The command conda env update -f /root/environment.yml failed, and conda install cdms2 failed as well. The failure of conda install might not be limited to just this one package (refer to Figures 2 and 3). This seems to be a series of issues. image image image

klieret commented 3 months ago

please copy the full output of the commands as text, not as a screenshot.

When you last wrote, the swe-bench PR that supposedly addresses this wasn't fixed.

I'm trying right now with the updated SWE-bench.

klieret commented 3 months ago

Also good practice to add export SWE_AGENT_LOG_STREAM_LEVEL="TRACE" so we see the actual commands. Also if you're just testing whether the installation works, you can use --model instant_empty_submit to not use any LM credits.

klieret commented 3 months ago

It works for me on the astropy issue with the latest updates:

out.log

rookielyb commented 3 months ago

when I run python run.py --model_name gpt4 --instance_filter matplotlib__matplotlib-25433 --config_file config/roles/default.yml --split test

INFO matplotlibmatplotlib not found in container, cloning...
DEBUG Falling back to full cloning method due to multiple instances or persistent container
TRACE Input:
git clone https://github.com/swe-bench/matplotlib
matplotlib.git matplotlibmatplotlib
TRACE Output:
Cloning into 'matplotlib
matplotlib'...
INFO Successfully cloned the repository on attempt 1
TRACE Input:
echo -n > /root/files_to_edit.txt
TRACE Output:

TRACE Input:
cd matplotlib__matplotlib
TRACE Output:

TRACE Input:
export ROOT=$(pwd -P)
TRACE Output:

TRACE Input:
git status
TRACE Output:
On branch main
Your branch is up to date with 'origin/main'.

     nothing to commit, working tree clean                                                                            

TRACE Input:
git restore .
TRACE Output:

TRACE Input:
git reset --hard 7eafdd8af3c523c1c77b027d378fb337dd489f18
TRACE Output:
HEAD is now at 7eafdd8af3 Merge pull request #25423 from jklymak/bld-pst013-compat
TRACE Input:
git clean -fdxq
TRACE Output:

TRACE Input:
export CURRENT_FILE=""
TRACE Output:

TRACE Input:
export CURRENT_LINE=0
TRACE Output:

TRACE Input:
export SEARCH_RESULTS=()
TRACE Output:

TRACE Input:
export SEARCH_FILES=()
TRACE Output:

TRACE Input:
export SEARCH_INDEX=0
TRACE Output:

TRACE Input:
source /root/miniconda3/etc/profile.d/conda.sh
TRACE Output:

TRACE Input:
uname -s
TRACE Output:
Linux
TRACE Input:
uname -m
TRACE Output:
aarch64
INFO install_configs:
{'python': '3.11', 'packages': 'environment.yml', 'install': 'python -m pip install -e .', 'pre_install':
['apt-get -y update && apt-get -y upgrade && apt-get install -y imagemagick ffmpeg texlive texlive-latex-extra
texlive-fonts-recommended texlive-xetex texlive-luatex cm-super dvipng'], 'pip_packages': ['contourpy==1.1.0',
'cycler==0.11.0', 'fonttools==4.42.1', 'ghostscript', 'kiwisolver==1.4.5', 'numpy==1.25.2', 'packaging==23.1',
'pillow==10.0.0', 'pikepdf', 'pyparsing==3.0.9', 'python-dateutil==2.8.2', 'six==1.16.0', 'setuptools==68.1.2',
'setuptools-scm==7.1.0', 'typing-extensions==4.7.1'], 'test_cmd': 'pytest -rA'}
TRACE Input:
conda env list | grep matplotlibmatplotlib3.7
TRACE Output:

INFO matplotlibmatplotlib3.7 conda env not found, creating...
WARNING ❌ Failed on matplotlib__matplotlib-25433: get_environment_yml() got an unexpected keyword argument
'python_version'
INFO Beginning environment shutdown...
INFO Agent container stopped
INFO Found image sweagent/swe-agent:latest with tags: ['sweagent/swe-agent:latest'], created:
2024-07-08T00:21:16.073900454Z for linux arm64.
DEBUG Starting container with command: docker run -i --rm --name sweagent-swe-agent-latest-59b02cf574
sweagent/swe-agent:latest /bin/bash -l
INFO 🌱 Environment Initialized
TRACE Input:
source /root/.bashrc
TRACE Output:

TRACE Input:
mkdir -p /root/commands
TRACE Output:

TRACE Input:
touch /root/commands/init.py
TRACE Output:

TRACE Input:
export PATH=$PATH:/root/commands
TRACE Output:

rookielyb commented 3 months ago

It works for me on the astropy issue with the latest updates:

out.log

Thanks to your previous modifications, I successfully ran astropy. However, I am currently encountering other errors when running different cases.

rookielyb commented 3 months ago

when I run python run.py --model_name gpt4 --instance_filter pydata__xarray-4094 --config_file config/roles/default.yml --split test

INFO install_configs:
{'python': '3.10', 'packages': 'environment.yml', 'install': 'python -m pip install -e .', 'pip_packages':
['numpy==1.23.0', 'packaging==23.1', 'pandas==1.5.3', 'pytest==7.4.0', 'python-dateutil==2.8.2', 'pytz==2023.3', 'six==1.16.0', 'scipy==1.11.1', 'setuptools==68.0.0'], 'no_use_env': True, 'test_cmd': 'pytest -rA'}
TRACE Input:
conda env list | grep pydataxarray0.12
TRACE Output:

INFO pydataxarray0.12 conda env not found, creating...
INFO content_env_yml name: pydataxarray0.12
channels:

DEBUG Created conda environment
INFO 存在environment.yml时安装包:
conda env update -f /root/environment.yml
TRACE Input:
conda env update -f /root/environment.yml
TRACE Output:
Channels:

ERROR Failed to install environment.yml: Channels:

INFO Beginning environment shutdown...
INFO Agent container stopped
WARNING ❌ Failed on pydata__xarray-4094: Failed to install environment.yml: Channels:

rookielyb commented 3 months ago

I am not sure if the information I provided is sufficient, but I hope it can help you identify the issue

klieret commented 2 months ago

Could you create a new issue for xarray? I want to close this because it was originally for astropy

Also which OS are you on? pydata works fine for me on Linux (I think there are some few known cases where things don't properly set up on OSX)

klieret commented 2 months ago

I created an issue for the matplotlib one that I can reproduce (#689)