'Tee' object has no attribute 'isatty'

Hi!
I’m trying to restore a checkpoint with algo = Algorithm.from_checkpoint(checkpoint_path) to evaluate it. But when I try algo.evaluate() an error appears:

Traceback (most recent call last):
  File "c:\Users\grhen\Documents\GitHub\EP_RLlib\QMIX_init_simulation.py", line 209, in <module>
    algo = Algorithm.from_checkpoint(checkpoint_path)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\rllib\algorithms\algorithm.py", line 345, in from_checkpoint
    return Algorithm.from_state(state)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\rllib\algorithms\algorithm.py", line 375, in from_state
    new_algo.__setstate__(state)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\util\tracing\tracing_helper.py", line 470, in _resume_span
    return method(self, *_args, **_kwargs)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\rllib\algorithms\algorithm.py", line 2596, in __setstate__
    remote_state = ray.put(state["worker"])
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\_private\auto_init_hook.py", line 23, in auto_init_wrapper
    auto_init_ray()
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\_private\auto_init_hook.py", line 16, in auto_init_ray
    ray.init()
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\_private\client_mode_hook.py", line 103, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\_private\worker.py", line 1503, in init
    usage_lib.show_usage_stats_prompt(cli=False)
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\_private\usage\usage_lib.py", line 384, in show_usage_stats_prompt
    from ray.autoscaler._private.cli_logger import cli_logger
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\__init__.py", line 4, in <module>
    from ray.autoscaler import sdk
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\sdk\__init__.py", line 1, in <module>
    from ray.autoscaler.sdk.sdk import (
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\sdk\sdk.py", line 9, in <module>
    from ray.autoscaler._private import commands
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\_private\commands.py", line 22, in <module>
    from ray.autoscaler._private import subprocess_output_util as cmd_output_util
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\_private\subprocess_output_util.py", line 8, in <module>
    from ray.autoscaler._private.cli_logger import cf, cli_logger
  File "C:\Users\grhen\anaconda3\envs\ep_rllib261\lib\site-packages\ray\autoscaler\_private\cli_logger.py", line 61, in <module>
    import colorful as _cf
  File "C:\Users\grhen\AppData\Roaming\Python\Python39\site-packages\colorful\__init__.py", line 133, in <module>
    sys.modules[__name__] = ColorfulModule(Colorful(), __name__)
  File "C:\Users\grhen\AppData\Roaming\Python\Python39\site-packages\colorful\core.py", line 363, in __init__
    colormode = terminal.detect_color_support(env=os.environ)
  File "C:\Users\grhen\AppData\Roaming\Python\Python39\site-packages\colorful\terminal.py", line 48, in detect_color_support
    if not sys.stdout.isatty():
AttributeError: 'Tee' object has no attribute 'isatty'

The error is mine or is a bugg in the library? Thanks!

After try different things, I found a subtle “error” in the algorithm configuration. I was using the following syntax to define the algorithm:

algo = (
        QMixConfig()
        .training(
            train_batch_size = 144,
            gamma=0.7 if not tune_runner else tune.grid_search([0.7, 0.9, 0.99]),
            lr=0.001 if not tune_runner else tune.grid_search([0.001, 0.01, 0.1]),
            #QMixConig
            mixer = 'qmix',
        )
       .environment(
            env="EPEnv",
            env_config={
                "csv": False,
                "epw": EPW_PATH,
                "output": TemporaryDirectory().name,
                "idf": IDF_PATH,
                'beta': 0.5, 
                'E_max': 2.5/6, 
                'climatic_stads': CLIMATIC_STADS,
                "separate_state_space": True,
                "one_hot_state_encoding": True,
                'test': test,
            },
        )
       .framework(
            framework = 'torch',
        )
       .fault_tolerance(
            recreate_failed_workers = True,
        )
       .rollouts(
            num_rollout_workers = 0,
            create_env_on_local_worker=True,
            rollout_fragment_length = 10,
            enable_connectors = True,
            batch_mode="truncate_episodes",
            ).exploration(
            explore = True,
            exploration_config = {
                "type": 'EpsilonGreedy',
                "initial_epsilon": 1.0,
                "final_epsilon": 0.001,
                "epsilon_timesteps": 300000
            },
        )
       .reporting(
            min_sample_timesteps_per_iteration = 2400,
        )
       .checkpointing(
            export_native_model_files = True,
        )
       .debugging(
            log_level = "INFO",
            seed=7,
        )
       .resources(
            num_gpus = 0,
        )
       .evaluation(
            evaluation_interval = 100,
            evaluation_duration = 2,
            evaluation_duration_unit = 'episodes',
            evaluation_num_workers=0,
            evaluation_config={
                "explore": False,
            }
        )
)

which is suggest in different parts of the documentation (for example here.-,from,-ray.rllib.algorithms) )

But if you remove the global brackets () the error desappear. The following code represent the modification implemented:

algo = QMixConfig().training(
            train_batch_size = 144,
            gamma=0.7 if not tune_runner else tune.grid_search([0.7, 0.9, 0.99]),
            lr=0.001 if not tune_runner else tune.grid_search([0.001, 0.01, 0.1]),
            #QMixConig
            mixer = 'qmix',
        ).environment(
            env="EPEnv",
            env_config={
                "csv": False,
                "epw": EPW_PATH,
                "output": TemporaryDirectory().name,
                "idf": IDF_PATH,
                'beta': 0.5, 
                'E_max': 2.5/6, 
                'climatic_stads': CLIMATIC_STADS,
                "separate_state_space": True,
                "one_hot_state_encoding": True,
                'test': test,
            },
        ).framework(
            framework = 'torch',
        ).fault_tolerance(
            recreate_failed_workers = True,
        ).rollouts(
            num_rollout_workers = 0,
            create_env_on_local_worker=True,
            rollout_fragment_length = 10,
            enable_connectors = True,
            batch_mode="truncate_episodes",
            ).exploration(
            explore = True,
            exploration_config = {
                "type": 'EpsilonGreedy',
                "initial_epsilon": 1.0,
                "final_epsilon": 0.001,
                "epsilon_timesteps": 300000
            },
        ).reporting(
            min_sample_timesteps_per_iteration = 2400,
        ).checkpointing(
            export_native_model_files = True,
        ).debugging(
            log_level = "INFO",
            seed=7,
        ).resources(
            num_gpus = 0,
        ).evaluation(
            evaluation_interval = 100,
            evaluation_duration = 2,
            evaluation_duration_unit = 'episodes',
            evaluation_num_workers=0,
            evaluation_config={
                "explore": False,
            }
        )
1 Like