materialsproject / fireworks

The Fireworks Workflow Management Repo.
https://materialsproject.github.io/fireworks
Other
362 stars 185 forks source link

AttributeError: "safe_load()" has been removed with ruamel.yaml 0.18.5 #516

Closed ikondov closed 8 months ago

ikondov commented 10 months ago

Please accept my apologies for bypassing https://discuss.matsci.org/c/fireworks but what is below is obviously an issue and no help request.

I have a fresh fireworks install in a fresh virtual environment (either conda or venv) with python 3.10 (python==3.10.12, ruamel.yaml==0.18.5, FireWorks==2.0.3) or newer python, I have issues with any use of fireworks related to a removed function in the ruamel.yaml package. For example, a simple lpad get_wflows -d count yields this error message:

Traceback (most recent call last):
  File "test/lib/python3.10/site-packages/fireworks/scripts/lpad_run.py", line 108, in get_lp
    lp = LaunchPad.from_file(args.launchpad_file)
  File "test/lib/python3.10/site-packages/fireworks/utilities/fw_serializers.py", line 292, in from_file
    return cls.from_format(f.read(), f_format=f_format)
  File "test/lib/python3.10/site-packages/fireworks/utilities/fw_serializers.py", line 257, in from_format
    dct = yaml.safe_load(f_str)
  File "test/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1105, in safe_load
    error_deprecation('safe_load', 'load', arg="typ='safe', pure=True")
  File "test/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1039, in error_deprecation
    raise AttributeError(s, name=None)
AttributeError:
"safe_load()" has been removed, use

  yaml = YAML(typ='safe', pure=True)
  yaml.load(...)

instead of file "test/lib/python3.10/site-packages/fireworks/utilities/fw_serializers.py", line 257

            dct = yaml.safe_load(f_str)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test/bin/lpad", line 8, in <module>
    sys.exit(lpad())
  File "test/lib/python3.10/site-packages/fireworks/scripts/lpad_run.py", line 1555, in lpad
    args.func(args)
  File "test/lib/python3.10/site-packages/fireworks/scripts/lpad_run.py", line 421, in get_wfs
    lp = get_lp(args)
  File "test/lib/python3.10/site-packages/fireworks/scripts/lpad_run.py", line 122, in get_lp
    f"FireWorks was not able to connect to MongoDB at {lp.host}:{lp.port}. Is the server running? "
UnboundLocalError: local variable 'lp' referenced before assignment

Using both the latest release (2.0.3) and the main branch results in the same behavior.

The workaround is to downgrade ruamel.yaml manually that is unfortunately an insufficient solution for the users of our software that uses fireworks as backend.

ikondov commented 10 months ago

Just to complete the picture, with ruamel 0.17.40 I get this warning:

  test-venv/lib/python3.10/site-packages/fireworks/utilities/fw_serializers.py:256: PendingDeprecationWarning:
  safe_load will be removed, use

    yaml=YAML(typ='safe', pure=True)
    yaml.load(...)

  instead
    dct = yaml.safe_load(f_str)