khanna-lab / cadre

Other
0 stars 0 forks source link

Error in dumping parameters #124

Open khanna7 opened 1 year ago

khanna7 commented 1 year ago

https://github.com/khanna-lab/cadre/blob/a1e70fcef22c1915bfe7307bc2788fcd97401ace/python/pycadre/cadre_model.py#L152-L155

I get the following errors when I run the model through EMEWS in this branch:

new_cadre_env_4) [akhann16@vscode1 swift]$ more turbine-output/instance_1/out.txt 
Running python3 -m pycadre /oscar/data/akhann16/akhann16/cadre_simulated_data/emews_experiments/testY/params.yaml {"random.seed": 1, "SMOKING_NETWORK_EFF
ECTS": {"ONSET": {"FIRST_DEGREE": 1.21}}, "ALCOHOL_NETWORK_EFFECTS": {"ONSET": {"FIRST_DEGREE": 1.1}}}
Random seed: 1
RNG:  Generator(PCG64)
RNG type: <class 'numpy.random._generator.Generator'>
---> Error in /gpfs/data/akhann16/sfw/tcl-8.6.12/bin/tclsh8.6 /oscar/data/akhann16/akhann16/cadre_simulated_data/emews_experiments/testY/swift-t-pytest.U
uE.tic testY cfgs/pycadre.cfg -f=/oscar/data/akhann16/akhann16/cadre_simulated_data/emews_experiments/testY/upf.txt -param_file=/oscar/data/akhann16/akha
nn16/cadre_simulated_data/emews_experiments/testY/params.yaml
(new_cadre_env_4) [akhann16@vscode1 swift]$ more turbine-output/instance_1/err.txt 
module: unloading 'python/2.7.12'
module: loading 'python/3.9.0'
OpenCL: Failed to get number of platforms with clGetPlatformIDs(): -1001
CUDA: Failed to get number of devices with cudaGetDeviceCount(): CUDA driver version is insufficient for CUDA runtime version
Traceback (most recent call last):
  File "/gpfs/runtime/opt/python/3.9.0/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/gpfs/runtime/opt/python/3.9.0/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/gpfs/home/akhann16/code/cadre/python/pycadre/__main__.py", line 36, in <module>
    main()
  File "/gpfs/home/akhann16/code/cadre/python/pycadre/__main__.py", line 29, in main
    model = cadre_model.Model(params=params_list, comm=MPI.COMM_WORLD)
  File "/gpfs/home/akhann16/code/cadre/python/pycadre/cadre_model.py", line 48, in __init__
    self.dump_parameters()
  File "/gpfs/home/akhann16/code/cadre/python/pycadre/cadre_model.py", line 154, in dump_parameters
    with open(params_file, 'w') as p:
FileNotFoundError: [Errno 2] No such file or directory: 'output/parameters.txt'
(new_cadre_env_4) [akhann16@vscode1 swift]$ 

I believe it is due to these lines? Note my output is sent to

(new_cadre_env_4) [akhann16@vscode1 swift]$ ls -ltr
...
lrwxrwxrwx 1 akhann16 akhann16   74 Oct  9 16:36 turbine-output -> /oscar/data/akhann16/akhann16/cadre_simulated_data/emews_experiments/testY
khanna7 commented 1 year ago

Chatgpt helped me implement a fix:

https://github.com/khanna-lab/cadre/blob/234e68e6e6afb02cb1e9da9f458467d814c9dec0/python/pycadre/cadre_model.py#L153-L185

How does this look?

ncollier commented 1 year ago

Yeah, I think the issue was that the output directory didn't exist. So, what you have above should work.