sweepai / evals

Apache License 2.0
0 stars 0 forks source link

Refactor training loop from script to class #134

Closed sweep-nightly[bot] closed 1 year ago

sweep-nightly[bot] commented 1 year ago

Description

This PR refactors the training loop from a script to a class in order to improve code organization and reusability. It introduces a new Trainer class in the src/trainer.py file that encapsulates the training loop logic. The Trainer class takes the model, dataloader, and optimizer as inputs and provides a train method to train the model.

Summary of Changes

Fixes #6.


🎉 Latest improvements to Sweep:


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

sweep-nightly[bot] commented 1 year ago

Sandbox Executions

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

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

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

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...

  ISSUES  
src/main.py:1:17
 1:17  high  `numpy` imported but unused  ruff/F401
Checked 1 file
1 existing issue (1 auto-fixable)
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)

sweep-nightly[bot] commented 1 year ago

Apply Sweep Rules to your PR?