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

maximum recursion depth exceeded while calling a Python object #1184

Open
JanStreffing opened this issue May 28, 2024 · 5 comments
Open

maximum recursion depth exceeded while calling a Python object #1184

JanStreffing opened this issue May 28, 2024 · 5 comments
Assignees
Labels
awicm bug Something isn't working error handling better error output required

Comments

@JanStreffing
Copy link
Contributor

I added a new model version, something I have done quite a few times before. I must have made a silly mistake, but I can't seem to spot it.

Here is the work I have done so far: https://github.com/esm-tools/esm_tools/pull/1183/files

The error I get is:

 esm_master install-awicm3-v3.2.2
Traceback (most recent call last):
  File "/home/a/a270092/.local/bin/esm_master", line 33, in <module>
    sys.exit(load_entry_point('esm-tools', 'console_scripts', 'esm_master')())
  File "/home/a/a270092/esm_tools/src/esm_master/cli.py", line 103, in main
    main_flow(parsed_args, target)
  File "/home/a/a270092/esm_tools/src/esm_master/esm_master.py", line 55, in main_flow
    complete_setup = SimulationSetup(user_config=user_config)
  File "/home/a/a270092/esm_tools/src/esm_runscripts/sim_objects.py", line 105, in __init__
    self.config = prepare.run_job(self.config)
  File "/home/a/a270092/esm_tools/src/esm_runscripts/prepare.py", line 19, in run_job
    helpers.evaluate(config, "prepare", "prepare_recipe")
  File "/home/a/a270092/esm_tools/src/esm_runscripts/helpers.py", line 71, in evaluate
    config = esm_plugin_manager.work_through_recipe(
  File "/home/a/a270092/esm_tools/src/esm_plugin_manager/esm_plugin_manager.py", line 159, in work_through_recipe
    config = getattr(submodule, workitem)(config)
  File "/home/a/a270092/esm_tools/src/esm_runscripts/prepare.py", line 791, in finalize_config
    config.finalize()
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 3163, in finalize
    self.run_recursive_functions(self)
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 3170, in run_recursive_functions
    recursive_run_function(
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1906, in recursive_run_function
    right[key] = recursive_run_function(
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1906, in recursive_run_function
    right[key] = recursive_run_function(
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1873, in recursive_run_function
    right = func(tree + [None], right, *args, **kwargs)
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1979, in find_variable
    var_result = find_variable(
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1979, in find_variable
    var_result = find_variable(
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1979, in find_variable
    var_result = find_variable(
  [Previous line repeated 976 more times]
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1975, in find_variable
    var_result, var_attrs = actually_find_variable(tree, var, full_config)
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 2050, in actually_find_variable
    var_result = recursive_get(full_config, config_elements)
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1951, in recursive_get
    return recursive_get(result, my_config_elements)
  File "/home/a/a270092/esm_tools/src/esm_parser/esm_parser.py", line 1938, in recursive_get
    my_config_elements = copy.deepcopy(config_elements)
  File "/sw/spack-levante/mambaforge-4.11.0-0-Linux-x86_64-sobz6z/lib/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/sw/spack-levante/mambaforge-4.11.0-0-Linux-x86_64-sobz6z/lib/python3.9/copy.py", line 205, in _deepcopy_list
    append(deepcopy(a, memo))
  File "/sw/spack-levante/mambaforge-4.11.0-0-Linux-x86_64-sobz6z/lib/python3.9/copy.py", line 137, in deepcopy
    d = id(x)
RecursionError: maximum recursion depth exceeded while calling a Python object
@JanStreffing JanStreffing added bug Something isn't working awicm labels May 28, 2024
@chrisdane
Copy link
Contributor

chrisdane commented May 28, 2024

Doesn't the coupling file need indents?

@JanStreffing
Copy link
Contributor Author

@pgierz and I looked into this.

The problem is, that when one makes a component model version, like so

choose_version:
  "2.5":
    branch: "2.5"

  "2.5-paleodyn":
    branch: "2.5.1_paleo"
    destination: "fesom-2.5"
    git-repository:
    - https://github.com/FESOM/fesom2.git # LA: only temporarily
    wiso_code: true
    icb_code: true
    namelist_dir: "${model_dir}/config/"

  '2.5-awicm-3.2':
    branch: "AWI-CM3_v3.2"

everything before the - is used to find the name of the fesom-${version}.yaml file name. If one does not use a -, the whole name is used to find the yaml file name. If that yaml file name does not exist, esm_master falls back onto the default fesom.yaml. This does not contain a tidy recipe. Which causes the esm_parser called from the esm_plugin_manager to spew out the error above.

The workaround is the stick to the nameing convention that puts a - after the version that is used in the yaml filename. So no version 2.5.2, but 2.5-2 ;-)

@JanStreffing
Copy link
Contributor Author

I suggest this issue should stay open until the behaviour is documented, and then closed. A fix does not look plausible without a major rewrite of esm_master.

@mandresm mandresm added the error handling better error output required label May 31, 2024
@mandresm
Copy link
Contributor

Even better than just documentation, a proper error on top of docs explaining what's going wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awicm bug Something isn't working error handling better error output required
Projects
None yet
Development

No branches or pull requests

3 participants