sweepai / evals

Apache License 2.0
0 stars 0 forks source link

Sweep: add comments and docstrings to main.py and api.py #11

Open wwzeng1 opened 1 year ago

wwzeng1 commented 1 year ago

Details

No response

Checklist - [X] Modify `src/main.py` ✓ https://github.com/sweepai/evals/commit/79c50514c76cc63da87009fa58909bf838a262c9 - [X] Ran sandbox for `src/main.py`. ✗ - [X] Modify `src/main.py` ✓ https://github.com/sweepai/evals/commit/daebccc8b909aede180964a8282ac887ee61e134 - [X] Ran sandbox for `src/main.py`. ✗ - [X] Modify `src/main.py` ✓ https://github.com/sweepai/evals/commit/129646e8b644a5578ec2941cccb851929ff65f05 - [X] Ran sandbox for `src/main.py`. ✗ - [X] Modify `src/main.py` ✓ https://github.com/sweepai/evals/commit/a411ef7e09586b7d1c4b5955627818260f25d8dd - [X] Ran sandbox for `src/main.py`. ✗ - [X] Modify `src/main.py` ✓ https://github.com/sweepai/evals/commit/fccd8513f449c3e5659fc31eea8aa475c67e6b3c - [X] Ran sandbox for `src/main.py`. ✓ https://github.com/sweepai/evals/commit/9909d51393e9b13a3ca4a53a3b5d8b06e57f220a - [X] Ran sandbox for `src/main.py`. ✓ - [X] Ran sandbox for `src/main.py`. ✓ - [ ] Ran sandbox for `src/main.py`. ⋯ - [ ] Ran sandbox for `src/main.py`. ▶ - [ ] Modify `src/api.py` ▶ ![Flowchart](https://raw.githubusercontent.com/sweepai/evals/sweep/assets/340abea792f736b4a97ae4fb88e99a7c800407c224a5cb1fa54e52eabf1f16d8_11_flowchart.svg)
sweep-nightly[bot] commented 1 year ago
Sweeping

50%
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: f1d7a25312)

![Docker Version Updated](https://img.shields.io/badge/Docker%20Version%20Updated-17%20minutes%20ago-blue)

Actions (click)

Sandbox Execution ✓

Here are the sandbox execution logs prior to making any changes:

Sandbox logs for 7284908
trunk fmt src/main.py || exit 0 1/2 ✓
  NOTICES  
 src/main.py  ignored empty file [black]
 Hint: use --force to check ignored files
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ✓
  NOTICES  
 src/main.py  ignored empty file [black]
 Hint: use --force to check ignored files
Checked 1 file
✔ No issues

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/sweepai/evals/blob/72849082ab1fcf90323a2d3b20d400de0d41ebd9/src/api.py#L1-L27 https://github.com/sweepai/evals/blob/72849082ab1fcf90323a2d3b20d400de0d41ebd9/src/main.py#L1-L46 https://github.com/sweepai/evals/blob/72849082ab1fcf90323a2d3b20d400de0d41ebd9/requirements.txt#L1-L15

Step 2: ⌨️ Coding

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

  FAILURES  
 black  src/main.py  .trunk/out/gZiT6.yaml
 black  src/main.py  .trunk/out/WAEJO.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:21:1
 21:1  high  SyntaxError: Expected 'Indent', but got 'trainloader'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/zhNAa.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/zhNAa.yaml
trunk_cli_version: 1.17.2
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/ApxtYx
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ApxtYx; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e HOME=/root VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d PYTHONUTF8=1 /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 21:0: trainloader = DataLoader(trainset, batch_size=64, shuffle=True)
    parser: |
      (none)

Next, correct the indentation of the code following the class definition of 'Net'. The code inside the class should be indented properly to indicate that it belongs to the class. The code after the class definition should be aligned with the class definition to indicate that it is not part of the class.

Finally, remove the duplicate lines of code at the end of the file. The lines for calculating the loss, performing backpropagation, stepping the optimizer, and saving the model state are repeated. Only one set of these lines is necessary for the training loop.

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

  FAILURES  
 black  src/main.py  .trunk/out/11VLF.yaml
 black  src/main.py  .trunk/out/hTFTf.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:51:1
 51:1  high  SyntaxError: Unexpected token Indent  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/U5E3I.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/U5E3I.yaml
trunk_cli_version: 1.17.2
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/3YLPKp
      timeout: 10m
      rerun: (cd /tmp/trunk-0/3YLPKp; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e PYTHONUTF8=1 HOME=/root VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 51:0:         loss = criterion(output, labels)
    parser: |
      (none)

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...

Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...

  ISSUES  
src/main.py:40:27
  1:17  high  `numpy` imported but unused                              ruff/F401
 39:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
 40:27  high  Undefined name `trainloader`                             ruff/F821
Checked 1 file
2 existing issues (2 auto-fixable)
✖ 1 new issue

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

  FAILURES  
 black  src/main.py  .trunk/out/34gAQ.yaml
 black  src/main.py  .trunk/out/ZMEEA.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:18:1
 18:1  high  SyntaxError: Expected 'Indent', but got 'trainloader'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/pDxgr.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/pDxgr.yaml
trunk_cli_version: 1.17.2
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/LDTJGO
      timeout: 10m
      rerun: (cd /tmp/trunk-0/LDTJGO; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e HOME=/root PYTHONUTF8=1 VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 18:0: trainloader = DataLoader(trainset, batch_size=64, shuffle=True)
    parser: |
      (none)

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...

Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ✓
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...

Checked 1 file
✔ No issues

trunk fmt src/main.py || exit 0 1/2 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ✓
Checked 1 file
✔ No issues

trunk fmt src/main.py || exit 0 1/2 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ✓
Checked 1 file
✔ No issues

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

  FAILURES  
 black  src/main.py  .trunk/out/11VLF.yaml
 black  src/main.py  .trunk/out/hTFTf.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:51:1
 51:1  high  SyntaxError: Unexpected token Indent  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/U5E3I.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/U5E3I.yaml
trunk_cli_version: 1.17.2
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/3YLPKp
      timeout: 10m
      rerun: (cd /tmp/trunk-0/3YLPKp; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e PYTHONUTF8=1 HOME=/root VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 51:0:         loss = criterion(output, labels)
    parser: |
      (none)

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

  FAILURES  
 black  src/main.py  .trunk/out/gZiT6.yaml
 black  src/main.py  .trunk/out/WAEJO.yaml
  NOTICES  
 Some tools failed to run. You can open the details yaml files for more information.
Checked 1 file
✖ No issues, 2 failures
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/2 ❌ (`1`)
  ISSUES  
src/main.py:21:1
 21:1  high  SyntaxError: Expected 'Indent', but got 'trainloader'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/zhNAa.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ 1 new issue
# .trunk/out/zhNAa.yaml
trunk_cli_version: 1.17.2
title: black exited with exit_code=123
report:
  - black exited with exit_code=123
  - linter:
      command: |
        /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py
      stdin_path: (none)
      run_from: /tmp/trunk-0/ApxtYx
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ApxtYx; env -i PATH=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin:/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/Scripts:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e/bin:/root/.cache/trunk/tools/python/3.10.8-b6e96641f2c120698c300f1bdd98bc0e HOME=/root VIRTUAL_ENV=/root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d PYTHONUTF8=1 /root/.cache/trunk/tools/black/23.9.1-183c0e64783085e12d1052afd073c73d/bin/black -q src/main.py)
      affects_cache:
        []
      direct_configs:
        []
      exit_status: exited
      exit_code: 123
      stdout: (none)
      stderr: |
        error: cannot format src/main.py: Cannot parse: 21:0: trainloader = DataLoader(trainset, batch_size=64, shuffle=True)
    parser: |
      (none)


Step 3: 🔁 Code Review

Working on it...


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord