2019-05-10 20:36:18 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-02-19 21:18:45 +01:00
|
|
|
# Do not import tf for testing purposes.
|
2020-02-11 00:22:07 +01:00
|
|
|
os.environ["RLLIB_TEST_NO_TF_IMPORT"] = "1"
|
|
|
|
|
2019-05-10 20:36:18 -07:00
|
|
|
from ray.rllib.agents.a3c import A2CTrainer
|
2020-02-11 00:22:07 +01:00
|
|
|
assert "tensorflow" not in sys.modules, \
|
2021-04-24 08:13:41 +02:00
|
|
|
"`tensorflow` initially present, when it shouldn't!"
|
2019-05-10 20:36:18 -07:00
|
|
|
|
2021-04-24 08:13:41 +02:00
|
|
|
# Note: No ray.init(), to test it works without Ray
|
2019-05-10 20:36:18 -07:00
|
|
|
trainer = A2CTrainer(
|
|
|
|
env="CartPole-v0", config={
|
2020-05-27 16:19:13 +02:00
|
|
|
"framework": "torch",
|
2019-05-10 20:36:18 -07:00
|
|
|
"num_workers": 0
|
|
|
|
})
|
|
|
|
trainer.train()
|
|
|
|
|
2021-04-24 08:13:41 +02:00
|
|
|
assert "tensorflow" not in sys.modules, \
|
|
|
|
"`tensorflow` should not be imported after creating and " \
|
|
|
|
"training A3CTrainer!"
|
2020-02-11 00:22:07 +01:00
|
|
|
|
|
|
|
# Clean up.
|
|
|
|
del os.environ["RLLIB_TEST_NO_TF_IMPORT"]
|
2020-06-25 19:01:32 +02:00
|
|
|
|
|
|
|
print("ok")
|