sweepai / evals

Apache License 2.0
0 stars 0 forks source link

Add error logs to the training loop #140

Closed sweep-nightly[bot] closed 10 months ago

sweep-nightly[bot] commented 10 months ago

Description

This PR adds error logging functionality to the training loop in src/main.py. It uses Python's built-in logging module to log any exceptions that occur during training to a file named training.log.

Summary of Changes

Fixes #1.


🎉 Latest improvements to Sweep:


💡 To get Sweep to edit this pull request, you can:

sweep-nightly[bot] commented 10 months ago

Sandbox Executions

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

  FAILURES  
 black  src/main.py  .trunk/out/y1xWK.yaml
 black  src/main.py  .trunk/out/s2qNv.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:13:3
 13:3  high  SyntaxError: Unexpected token 'from'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/y0NlU.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/y0NlU.yaml
trunk_cli_version: 1.17.1
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/ByQlWN
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ByQlWN; 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: 13:2: ])from PIL import Image
    parser: |
      (none)

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ 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:2:13
  2:13  high  Undefined name `transforms`                              ruff/F821
  3:6   high  Undefined name `transforms`                              ruff/F821
  3:29  high  Undefined name `transforms`                              ruff/F821
  7:13  high  Undefined name `transforms`                              ruff/F821
  8:6   high  Undefined name `transforms`                              ruff/F821
  8:29  high  Undefined name `transforms`                              ruff/F821
 10:1   high  Module level import not at top of file                   ruff/E402
 14:12  high  Undefined name `datasets`                                ruff/F821
 15:15  high  Undefined name `DataLoader`                              ruff/F821
 19:11  high  Undefined name `nn`                                      ruff/F821
 22:20  high  Undefined name `nn`                                      ruff/F821
 23:20  high  Undefined name `nn`                                      ruff/F821
 24:20  high  Undefined name `nn`                                      ruff/F821
 28:13  high  Undefined name `nn`                                      ruff/F821
 29:13  high  Undefined name `nn`                                      ruff/F821
 31:16  high  Undefined name `nn`                                      ruff/F821
 36:13  high  Undefined name `optim`                                   ruff/F821
 37:13  high  Undefined name `nn`                                      ruff/F821
 41:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
 52:1   high  Undefined name `torch`                                   ruff/F821
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 19 new issues

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:16:1
 16:1  high  Module level import not at top of file                   ruff/E402
 47:5  high  Loop control variable `epoch` not used within loop body  ruff/B007
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 1 new issue

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:13:1
 13:1  high  Module level import not at top of file        ruff/E402
 13:8  high  Redefinition of unused `logging` from line 1  ruff/F811
Checked 1 file
✖ 2 new issues

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:13:1
 13:1  high  Module level import not at top of file  ruff/E402
Checked 1 file
✖ 1 new issue

trunk fmt src/main.py || exit 0 1/4 ✓
 ✔ 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/4 ✓
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...

Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)

trunk fmt src/main.py || exit 0 1/4 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)

trunk fmt src/main.py || exit 0 1/4 ✓
Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
Checked 1 file
✔ No issues
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)

pip install -r requirements.txt 1/1 ❌ (`1`)
Looking in links: https://download.pytorch.org/whl/torch_stable.html
DEPRECATION: The HTML index page being used (https://download.pytorch.org/whl/torch_stable.html) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip/issues/10825
Collecting annotated-types==0.6.0
  Downloading annotated_types-0.6.0-py3-none-any.whl (12 kB)
Collecting anyio==3.7.1
  Downloading anyio-3.7.1-py3-none-any.whl (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 KB 766.9 kB/s eta 0:00:00
Collecting astroid==3.0.1
  Downloading astroid-3.0.1-py3-none-any.whl (275 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 275.2/275.2 KB 3.4 MB/s eta 0:00:00
Collecting certifi==2022.12.7
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 4.4 MB/s eta 0:00:00
Collecting charset-normalizer==2.1.1
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Requirement already satisfied: click==8.1.7 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (8.1.7)
Collecting dill==0.3.
  Downloading dill-0.3.0.tar.gz (151 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.4/151.4 KB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils

pip install -r requirements.txt 1/1 ❌ (`1`)
Looking in links: https://download.pytorch.org/whl/torch_stable.html
DEPRECATION: The HTML index page being used (https://download.pytorch.org/whl/torch_stable.html) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip/issues/10825
Collecting annotated-types==0.6.0
  Downloading annotated_types-0.6.0-py3-none-any.whl (12 kB)
Collecting anyio==3.7.1
  Downloading anyio-3.7.1-py3-none-any.whl (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 KB 766.9 kB/s eta 0:00:00
Collecting astroid==3.0.1
  Downloading astroid-3.0.1-py3-none-any.whl (275 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 275.2/275.2 KB 3.4 MB/s eta 0:00:00
Collecting certifi==2022.12.7
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 4.4 MB/s eta 0:00:00
Collecting charset-normalizer==2.1.1
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Requirement already satisfied: click==8.1.7 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (8.1.7)
Collecting dill==0.3.
  Downloading dill-0.3.0.tar.gz (151 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.4/151.4 KB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils

trunk fmt src/main.py || exit 0 1/2 ✓
 ✔ 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:2:13
  2:13  high  Undefined name `transforms`                              ruff/F821
  3:6   high  Undefined name `transforms`                              ruff/F821
  3:29  high  Undefined name `transforms`                              ruff/F821
  7:13  high  Undefined name `transforms`                              ruff/F821
  8:6   high  Undefined name `transforms`                              ruff/F821
  8:29  high  Undefined name `transforms`                              ruff/F821
 10:1   high  Module level import not at top of file                   ruff/E402
 14:12  high  Undefined name `datasets`                                ruff/F821
 15:15  high  Undefined name `DataLoader`                              ruff/F821
 19:11  high  Undefined name `nn`                                      ruff/F821
 22:20  high  Undefined name `nn`                                      ruff/F821
 23:20  high  Undefined name `nn`                                      ruff/F821
 24:20  high  Undefined name `nn`                                      ruff/F821
 28:13  high  Undefined name `nn`                                      ruff/F821
 29:13  high  Undefined name `nn`                                      ruff/F821
 31:16  high  Undefined name `nn`                                      ruff/F821
 36:13  high  Undefined name `optim`                                   ruff/F821
 37:13  high  Undefined name `nn`                                      ruff/F821
 41:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
 52:1   high  Undefined name `torch`                                   ruff/F821
Checked 1 file
1 existing issue (1 auto-fixable)
✖ 19 new 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/y1xWK.yaml
 black  src/main.py  .trunk/out/s2qNv.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:13:3
 13:3  high  SyntaxError: Unexpected token 'from'  ruff/E999
  FAILURES  
 black  src/main.py  .trunk/out/y0NlU.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/y0NlU.yaml
trunk_cli_version: 1.17.1
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/ByQlWN
      timeout: 10m
      rerun: (cd /tmp/trunk-0/ByQlWN; 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: 13:2: ])from PIL import Image
    parser: |
      (none)

sweep-nightly[bot] commented 10 months ago

Apply Sweep Rules to your PR?