ray/rllib/tests/test_dependency.py
Sven Mika 4fd8977eaf
[RLlib] Minor cleanup in preparation to tf2.x support. (#9130)
* WIP.

* Fixes.

* LINT.

* Fixes.

* Fixes and LINT.

* WIP.
2020-06-25 19:01:32 +02:00

27 lines
677 B
Python

#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
# Do not import tf for testing purposes.
os.environ["RLLIB_TEST_NO_TF_IMPORT"] = "1"
from ray.rllib.agents.a3c import A2CTrainer
assert "tensorflow" not in sys.modules, \
"TF initially present, when it shouldn't."
# note: no ray.init(), to test it works without Ray
trainer = A2CTrainer(
env="CartPole-v0", config={
"framework": "torch",
"num_workers": 0
})
trainer.train()
assert "tensorflow" not in sys.modules, "TF should not be imported"
# Clean up.
del os.environ["RLLIB_TEST_NO_TF_IMPORT"]
print("ok")