[tune/rllib] Only disable ipython in remote actors (#18789)

This commit is contained in:
Kai Fricke 2021-09-22 11:05:06 +01:00 committed by Jiajun Yao
parent f71cfca439
commit e39b0f785e

View file

@ -76,7 +76,8 @@ class Trainable:
self.config = config or {}
trial_info = self.config.pop(TRIAL_INFO, None)
disable_ipython()
if self.is_actor():
disable_ipython()
self._result_logger = self._logdir = None
self._create_logger(self.config, logger_creator)
@ -153,6 +154,14 @@ class Trainable:
self._local_ip = ray.util.get_node_ip_address()
return self._local_ip
def is_actor(self):
try:
actor_id = ray.worker.global_worker.actor_id
return actor_id != actor_id.nil()
except Exception:
# If global_worker is not instantiated, we're not in an actor
return False
def train_buffered(self,
buffer_time_s: float,
max_buffer_length: int = 1000):