Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter initialization error in fix_get_action_develop branch #253

Open
Davidwhw opened this issue Apr 10, 2023 · 1 comment
Open

Parameter initialization error in fix_get_action_develop branch #253

Davidwhw opened this issue Apr 10, 2023 · 1 comment

Comments

@Davidwhw
Copy link

I was trying to run an async workflow in fix_get_action_develop branch and had an error with parameter initialization.

In order to study the error of parameter initialization, I printed the parameter information in EXARL/exarl/utils/candleDriver.py and EXARL/exarl/utils/globals.py files respectively.

"""
EXARL/exarl/utils/candleDriver.py
"""

def initialize_parameters(params=None):
    ...
    print('initialize_parameters :: if params is None? ', params == None)
    ExaGlobals(params, candle.keras_default_config())
"""
EXARL/exarl/utils/globals.py
"""

def lookup_params(key):
    print(f'ExaGlobals Looking for {key} : run_params is None ? {ExaGlobals.__run_params == None}',)
    if ExaGlobals.__run_params is None:
        raise ExaGlobals.GlobalsNotInitialized(key)
    if key not in ExaGlobals.__run_params:
        raise ExaGlobals.GlobalDoesNotExist(ExaGlobals.__run_params, key)
    return ExaGlobals.__run_params[key]

For the 'agent' parameter shown below, the initialization in candleDriver.py is always normal. But in globals.py , sometimes the parameter is successfully found, and sometimes it is None.

initialize_parameters :: if params is None?  False
ExaGlobals Looking for log_level : run_params is None ? False
ExaGlobals Looking for agent : run_params is None ? False
ExaGlobals Looking for env : run_params is None ? False
ExaGlobals Looking for workflow : run_params is None ? False
ExaGlobals Looking for learner_procs : run_params is None ? False
ExaGlobals Looking for process_per_env : run_params is None ? False
ExaGlobals Looking for n_episodes : run_params is None ? False
ExaGlobals Looking for n_steps : run_params is None ? False
ExaGlobals Looking for action_type : run_params is None ? False
ExaGlobals Looking for output_dir : run_params is None ? False
ExaGlobals Looking for mpi4py_rc : run_params is None ? False
Turning mpi4py.rc.threads and mpi4py.rc.recv_mprobe to false!
ExaGlobals Looking for env : run_params is None ? False
ExaGlobals Looking for agent : run_params is None ? False
ExaGlobals Looking for env : run_params is None ? True
ExaGlobals Looking for agent : run_params is None ? False
ExaGlobals Looking for env : run_params is None ? False
ExaGlobals Looking for workflow : run_params is None ? False
ExaGlobals Looking for learner_procs : run_params is None ? False
ExaGlobals Looking for process_per_env : run_params is None ? False
ExaGlobals Looking for n_episodes : run_params is None ? False
ExaGlobals Looking for n_steps : run_params is None ? False
ExaGlobals Looking for action_type : run_params is None ? False
ExaGlobals Looking for output_dir : run_params is None ? False
ExaGlobals Looking for mpi4py_rc : run_params is None ? False
Turning mpi4py.rc.threads and mpi4py.rc.recv_mprobe to false!
ExaGlobals Looking for agent : run_params is None ? True
ExaGlobals Looking for env : run_params is None ? False
ExaGlobals Looking for agent : run_params is None ? False
ExaGlobals Looking for agent : run_params is None ? True
[Errno 2] No such file or directory: '/EXARL/results/EXP000/RUN012'
Could not load candle parameters.
Traceback (most recent call last):
  File "start.py", line 21, in <module>
    exa_learner = erl.ExaLearner(comm)
  File "/EXARL/exarl/base/learner_base.py", line 27, in __init__
    agent_id = ExaGlobals.lookup_params('agent')
  File "/EXARL/exarl/utils/globals.py", line 112, in lookup_params
    raise ExaGlobals.GlobalsNotInitialized(key)
exarl.utils.globals.GlobalsNotInitialized: ExaRL globals have not been set. Trying agent

How can I fix this mistake?

@Davidwhw
Copy link
Author

I think I've found the reason for the error. Sometimes it try to delete folder that don't exist in candlelib. I don't know what causes this, but it does come up all the time. When I remove shutil.rmtree(outdir), it works fine.

"""
/EXARL/exarl/candlelib/default_utils.py
"""
def directory_from_parameters(params, commonroot='Output'):
    ...
    if not os.path.exists(outdir):
        os.makedirs(outdir, exist_ok=True)
    else:
        shutil.rmtree(outdir)
        os.makedirs(outdir, exist_ok=True)

    return outdir
Traceback (most recent call last):
  File "start.py", line 5, in <module>
    import exarl.utils.analyze_reward as ar
  File "/EXARL/exarl/__init__.py", line 3, in <module>
    candleDriver.initialize_parameters()
  File "/EXARL/exarl/utils/candleDriver.py", line 92, in initialize_parameters
    params = candle.finalize_parameters(driver)
  File "/EXARL/exarl/candlelib/default_utils.py", line 365, in finalize_parameters
    gParameters = args_overwrite_config(args, fileParameters)
  File "/EXARL/exarl/candlelib/default_utils.py", line 621, in args_overwrite_config
    params['output_dir'] = directory_from_parameters(params, params['output_dir'])
  File "/EXARL/exarl/candlelib/default_utils.py", line 730, in directory_from_parameters
    shutil.rmtree(outdir)
  File "/public/software/apps/DeepLearning/TensorFlow/tf2.7.0-dtk21.10-build/lib/python3.6/shutil.py", line 490, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/public/software/apps/DeepLearning/TensorFlow/tf2.7.0-dtk21.10-build/lib/python3.6/shutil.py", line 488, in rmtree
    os.rmdir(path)
FileNotFoundError: [Errno 2] No such file or directory: '/EXARL/results/EXP000/RUN009'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant