-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rllib] Add test case that we don't have a hard torch dependency (#7926)
- Loading branch information
Showing
4 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
# Do not import torch for testing purposes. | ||
os.environ["RLLIB_TEST_NO_TORCH_IMPORT"] = "1" | ||
|
||
from ray.rllib.agents.a3c import A2CTrainer | ||
assert "torch" not in sys.modules, \ | ||
"Torch initially present, when it shouldn't." | ||
|
||
# note: no ray.init(), to test it works without Ray | ||
trainer = A2CTrainer( | ||
env="CartPole-v0", config={ | ||
"use_pytorch": False, | ||
"num_workers": 0 | ||
}) | ||
trainer.train() | ||
|
||
assert "torch" not in sys.modules, "Torch should not be imported" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters