payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
19 stars 26 forks source link

archive step assumed LD_LIBRARY_PATH populated #307

Closed aidanheerdegen closed 1 year ago

aidanheerdegen commented 3 years ago

In the archive step payu assumed LD_LIBRARY_PATH is populated and errors if it doesn't:

https://github.com/payu-org/payu/blob/master/payu/experiment.py#L781

Traceback (most recent call last):
  File "/g/data3/hh5/public/apps/miniconda3/envs/analysis3-21.07/bin/payu", line 10, in <module>                                          
    sys.exit(parse())
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-21.07/lib/python3.9/site-packages/payu/cli.py", line 42, in parse               
    run_cmd(**args)
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-21.07/lib/python3.9/site-packages/payu/subcommands/archive_cmd.py", line 18, in runcmd
    expt.archive()
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-21.07/lib/python3.9/site-packages/payu/experiment.py", line 781, in archive     
    ld_libpaths = os.environ['LD_LIBRARY_PATH']
  File "/g/data/hh5/public/apps/miniconda3/envs/analysis3-21.07/lib/python3.9/os.py", line 679, in __getitem__                            
    raise KeyError(key) from None

Should use get and supply an appropriate default if it doesn't exist.

marshallward commented 3 years ago

os.environ.get('LD_LIBRARY_PATH', '') looks like it might work here. I agree this was an oversight.

(I think at the time, it would have not been possible to use Python without some sort of active module.)