Skip to content

Commit

Permalink
[BugFix] MacOS testing
Browse files Browse the repository at this point in the history
  • Loading branch information
fedebotu committed Jul 19, 2024
1 parent a91a9af commit e7624d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
- name: Check out repository
uses: actions/checkout@v3

- name: Set environment variable for macOS
if: runner.os == 'macOS'
run: echo "MAC_OS_GITHUB_RUNNER=1" >> $GITHUB_ENV

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
10 changes: 9 additions & 1 deletion tests/training.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import os

from rl4co.utils.trainer import RL4COTrainer

from routefinder.envs.mtvrp import MTVRPEnv
from routefinder.models import RouteFinderBase, RouteFinderPolicy

# Get env variable MAC_OS_GITHUB_RUNNER and force CPU in that case
if "MAC_OS_GITHUB_RUNNER" in os.environ:
accelerator = "cpu"
else:
accelerator = "auto"


def test_training():
env = MTVRPEnv(generator_params={"num_loc": 10, "variant_preset": "all"})
Expand All @@ -20,7 +28,7 @@ def test_training():
max_epochs=1,
gradient_clip_val=None,
devices=1,
accelerator="auto",
accelerator=accelerator,
)
trainer.fit(model)
trainer.test(model)

0 comments on commit e7624d9

Please sign in to comment.