diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8da4649 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: pyright + +on: + pull_request: + branches: [ main ] + +jobs: + pyright: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + + - name: Set up Python + run: uv python install + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Run pyright + run: pyright \ No newline at end of file diff --git a/README.md b/README.md index 0ef5608..fae9040 100644 --- a/README.md +++ b/README.md @@ -136,16 +136,19 @@ For a complete example of a ComputerInterface implementation, you can refer to t ### Best Practices 1. **Resource Management** + - Implement proper cleanup in your interface - Handle container/VM lifecycle appropriately - Clean up temporary files 2. **Security** + - Implement proper isolation between tasks - Handle sensitive data appropriately - Control network access 3. **Scalability** + - Consider implementing a pool of compute resources - Handle concurrent task execution - Implement proper resource limits @@ -157,4 +160,4 @@ For a complete example of a ComputerInterface implementation, you can refer to t ## Contributing -For questions or contributions, please open an issue or pull request. \ No newline at end of file +For questions or contributions, please open an issue or pull request. diff --git a/project/alcatraz/alcatraz/clusters/local.py b/project/alcatraz/alcatraz/clusters/local.py index 64e2fe6..3f68813 100644 --- a/project/alcatraz/alcatraz/clusters/local.py +++ b/project/alcatraz/alcatraz/clusters/local.py @@ -1355,7 +1355,7 @@ async def commit_and_push( max_pool_size=1000, timeout=self.limits["docker_client_timeout_seconds"], ) - res = docker_client_push.images.push(repository=repository, tag=tag) + res = docker_client_push.images.push(repository=repository, tag=tag) # type: ignore logger.info(f"pushed {repository}:{tag}") final_res = json.loads(res.strip().split("\n")[-1]) if "error" in final_res: diff --git a/project/nanoeval/nanoeval/solvers/computer_tasks/solver.py b/project/nanoeval/nanoeval/solvers/computer_tasks/solver.py index 96bf264..aeed194 100644 --- a/project/nanoeval/nanoeval/solvers/computer_tasks/solver.py +++ b/project/nanoeval/nanoeval/solvers/computer_tasks/solver.py @@ -348,7 +348,7 @@ def _get_convo_len_stats( # compute percentiles convo_lens = np.array(convo_lens) percentiles = np.percentile(convo_lens, [25, 50, 75]) - summary_dict["convo_len_percentiles"] = percentiles.tolist() + summary_dict["convo_len_percentiles"] = percentiles.tolist() # type: ignore return { "frac_correct": frac_correct, diff --git a/project/nanoeval/pyproject.toml b/project/nanoeval/pyproject.toml index 6649464..d0e7f9a 100644 --- a/project/nanoeval/pyproject.toml +++ b/project/nanoeval/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ "ptpython", "ipython", "structlog", + "pandas-stubs>=2.2.3.241126", ] [tool.setuptools.packages.find] diff --git a/pyproject.toml b/pyproject.toml index 6bf2e19..7b07bb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,10 @@ version = "0.1.0" dependencies = [ "alcatraz", "nanoeval", - "nanoeval-alcatraz", + "nanoeval_alcatraz", "python-dotenv>=1.0.1", "tiktoken>=0.9.0", + "pyright", ] requires-python = ">=3.11" @@ -16,4 +17,4 @@ packages = ["swelancer"] [tool.uv.sources] nanoeval = { path = "project/nanoeval", editable = true } alcatraz = { path = "project/alcatraz", editable = true } -nanoeval-alcatraz = { path = "project/nanoeval_alcatraz", editable = true } +nanoeval_alcatraz = { path = "project/nanoeval_alcatraz", editable = true } diff --git a/swelancer.py b/swelancer.py index eadfb8a..6397ada 100644 --- a/swelancer.py +++ b/swelancer.py @@ -331,7 +331,7 @@ async def get_tasks(self) -> list[SWELancerTask]: del task['price_limit'] del task['canary'] - swelancer_tasks.append(SWELancerTask(**task, attempt_id=str(i), environment=SWEFL_ENV, grade_every_step=False, docker_image=docker_image, instance=SwelancerInstance(repo="expensify"))) + swelancer_tasks.append(SWELancerTask(**task, attempt_id=str(i), environment=SWEFL_ENV, grade_every_step=False, docker_image=docker_image, instance=SwelancerInstance(repo="expensify"))) # type: ignore i += 1 return swelancer_tasks diff --git a/swelancer_agent.py b/swelancer_agent.py index 70ba806..9fe0500 100644 --- a/swelancer_agent.py +++ b/swelancer_agent.py @@ -69,10 +69,10 @@ def get_model_response(messages: list[dict[str, Any]]) -> str: messages = trim_messages(messages, 110000) chat_completion = client.chat.completions.create( - messages=messages, + messages=messages, # type: ignore model="gpt-4o", ) - return chat_completion.choices[0].message.content + return chat_completion.choices[0].message.content # type: ignore @chz.chz @@ -105,7 +105,7 @@ async def run(self, task: ComputerTask) -> AsyncGenerator[Step | FinalResult, No for prompt_message in task.prompt: messages.append({ "role": "user", - "content": str(prompt_message["content"]) + "content": str(prompt_message["content"]) # type: ignore }) messages.append({"role": "user", "content": """The repository is cloned in your CWD. You must send Python code in backticks in each response to me, and I will execute the code and send you back the result, for example: diff --git a/uv.lock b/uv.lock index 7f3d14e..7828682 100644 --- a/uv.lock +++ b/uv.lock @@ -1642,6 +1642,7 @@ dependencies = [ { name = "numpy" }, { name = "openai" }, { name = "pandas" }, + { name = "pandas-stubs" }, { name = "psutil" }, { name = "ptpython" }, { name = "pyarrow" }, @@ -1671,6 +1672,7 @@ requires-dist = [ { name = "numpy" }, { name = "openai" }, { name = "pandas" }, + { name = "pandas-stubs", specifier = ">=2.2.3.241126" }, { name = "psutil" }, { name = "ptpython" }, { name = "pyarrow" }, @@ -1718,6 +1720,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a0/c4/c2971a3ba4c6103a3d10c4b0f24f461ddc027f0f09763220cf35ca1401b3/nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c", size = 5195 }, ] +[[package]] +name = "nodeenv" +version = "1.9.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314 }, +] + [[package]] name = "numpy" version = "2.2.2" @@ -1835,6 +1846,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ab/5f/b38085618b950b79d2d9164a711c52b10aefc0ae6833b96f626b7021b2ed/pandas-2.2.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ad5b65698ab28ed8d7f18790a0dc58005c7629f227be9ecc1072aa74c0c1d43a", size = 13098436 }, ] +[[package]] +name = "pandas-stubs" +version = "2.2.3.241126" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, + { name = "types-pytz" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/90/86/93c545d149c3e1fe1c4c55478cc3a69859d0ea3467e1d9892e9eb28cb1e7/pandas_stubs-2.2.3.241126.tar.gz", hash = "sha256:cf819383c6d9ae7d4dabf34cd47e1e45525bb2f312e6ad2939c2c204cb708acd", size = 104204 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/ab/ed42acf15bab2e86e5c49fad4aa038315233c4c2d22f41b49faa4d837516/pandas_stubs-2.2.3.241126-py3-none-any.whl", hash = "sha256:74aa79c167af374fe97068acc90776c0ebec5266a6e5c69fe11e9c2cf51f2267", size = 158280 }, +] + [[package]] name = "parso" version = "0.8.4" @@ -2249,6 +2273,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/1c/a7/c8a2d361bf89c0d9577c934ebb7421b25dc84bf3a8e3ac0a40aed9acc547/pyparsing-3.2.1-py3-none-any.whl", hash = "sha256:506ff4f4386c4cec0590ec19e6302d3aedb992fdc02c761e90416f158dacf8e1", size = 107716 }, ] +[[package]] +name = "pyright" +version = "1.1.394" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "nodeenv" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/e4/79f4d8a342eed6790fdebdb500e95062f319ee3d7d75ae27304ff995ae8c/pyright-1.1.394.tar.gz", hash = "sha256:56f2a3ab88c5214a451eb71d8f2792b7700434f841ea219119ade7f42ca93608", size = 3809348 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d6/4c/50c74e3d589517a9712a61a26143b587dba6285434a17aebf2ce6b82d2c3/pyright-1.1.394-py3-none-any.whl", hash = "sha256:5f74cce0a795a295fb768759bbeeec62561215dea657edcaab48a932b031ddbb", size = 5679540 }, +] + [[package]] name = "pytest" version = "8.3.4" @@ -2691,6 +2728,7 @@ dependencies = [ { name = "alcatraz" }, { name = "nanoeval" }, { name = "nanoeval-alcatraz" }, + { name = "pyright" }, { name = "python-dotenv" }, { name = "tiktoken" }, ] @@ -2700,6 +2738,7 @@ requires-dist = [ { name = "alcatraz", editable = "project/alcatraz" }, { name = "nanoeval", editable = "project/nanoeval" }, { name = "nanoeval-alcatraz", editable = "project/nanoeval_alcatraz" }, + { name = "pyright" }, { name = "python-dotenv", specifier = ">=1.0.1" }, { name = "tiktoken", specifier = ">=0.9.0" }, ] @@ -2850,6 +2889,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/70/53/a50654eb9c63da0df2b5dca8ec27656a88b7edd798de5ffad55353203874/twisted-24.11.0-py3-none-any.whl", hash = "sha256:fe403076c71f04d5d2d789a755b687c5637ec3bcd3b2b8252d76f2ba65f54261", size = 3188667 }, ] +[[package]] +name = "types-pytz" +version = "2025.1.0.20250204" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b3/d2/2190c54d53c04491ad72a1df019c5dfa692e6ab6c2dba1be7b6c9d530e30/types_pytz-2025.1.0.20250204.tar.gz", hash = "sha256:00f750132769f1c65a4f7240bc84f13985b4da774bd17dfbe5d9cd442746bd49", size = 10352 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/be/50/65ffad73746f1d8b15992c030e0fd22965fd5ae2c0206dc28873343b3230/types_pytz-2025.1.0.20250204-py3-none-any.whl", hash = "sha256:32ca4a35430e8b94f6603b35beb7f56c32260ddddd4f4bb305fdf8f92358b87e", size = 10059 }, +] + [[package]] name = "typing-extensions" version = "4.12.2"