Open m-k-S opened 1 month ago
They are intended to be developed locally, but running them in a Jupyter notebook is perhaps nontrivial since Parsl requires to wrap the whole execution inside a context manager, and psiflow therefore also adopts that structure.
def main():
# stuff
pass
if __name__ == '__main__':
with psiflow.load():
main()
From your error, it looks like the psiflow.load()
command was not executed in the notebook?
Sorry, yes, that was an oversight on my part. And ok, that makes sense re: Parsl. Is there any way to pass the contents of an equivalent YAML file to the main psiflow object in a Jupyter Notebook?
Also, even with the psiflow.load()
context, I still get the error:
AssertionError Traceback (most recent call last)
Cell In[40], [line 56](vscode-notebook-cell:?execution_count=40&line=56)
[53](vscode-notebook-cell:?execution_count=40&line=53) frequencies = compute_frequencies(hessian, minimum).result()
[54](vscode-notebook-cell:?execution_count=40&line=54) return frequencies[-1] * second / (100 * _c)
---> [56](vscode-notebook-cell:?execution_count=40&line=56) with psiflow.load():
[57](vscode-notebook-cell:?execution_count=40&line=57) geometry = Geometry.from_data(
[58](vscode-notebook-cell:?execution_count=40&line=58) numbers=np.ones(2),
[59](vscode-notebook-cell:?execution_count=40&line=59) positions=np.array([[0, 0, 0], [0.8, 0, 0]]),
[60](vscode-notebook-cell:?execution_count=40&line=60) cell=None,
[61](vscode-notebook-cell:?execution_count=40&line=61) )
[62](vscode-notebook-cell:?execution_count=40&line=62) mace = MACEHamiltonian.mace_mp0()
File ~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:586, in ExecutionContextLoader.load(cls, psiflow_config)
[584](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:584) assert len(sys.argv) == 2
[585](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:585) path_config = psiflow.resolve_and_check(Path(sys.argv[1]))
--> [586](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:586) assert path_config.exists()
[587](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:587) assert path_config.suffix in [".yaml", ".yml"], (
[588](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:588) "the execution configuration needs to be specified"
[589](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:589) " as a YAML file, but got {}".format(path_config)
[590](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:590) )
[591](https://file+.vscode-resource.vscode-cdn.net/Users/muon/Documents/materials/curie/~/miniforge3/envs/md/lib/python3.10/site-packages/psiflow/execution.py:591) with open(path_config, "r") as f:
AssertionError:
And this is with the following config file, note gpu explicitly marked as false. I believe the assertion expects gpu to always be set to True?
retries: 0
ModelEvaluation:
gpu: false
use_threadpool: true
max_simulation_time: 0.4```
Yes, you can just pass the contents of the YAML file as a dictionary to the psiflow.load()
call. In your case this would have to be:
import psiflow
if __name__ == '__main__':
config_dict = {
'retries': 0,
'ModelEvaluation': {
'gpu': False,
'use_threadpool': True,
'max_simulation_time': 0.4,
},
'ModelTraining': {
'gpu': True,
'use_threadpool': True,
},
}
with psiflow.load(config_dict):
print('test')
At the moment, users are forced to also specify ModelTraining
with gpu: true
-- which obviously doesn't make sense if no training is required. I'll fix this asap.
Does it raise any errors when you use the above config in your Jupyter environment? I'll talk to the people at Parsl to ask what the recommended way is for users to execute workflows in notebooks. We should put effort in making this more straightforward.
Hi, I'm very interested in using Psiflow to set up MD experiments but I'm trying to get it running on my local machine before plugging it into e.g. the HPC cluster I have access to. However, I have a lot of issues doing this. For example, when I try to run the H2 static/dynamic example, I get:
And when I try to run the basic geometry example, I get:
Are Psiflow scripts not intended to be developed locally? Is there any guide on how to get it working in a Jupyter notebook? I am running Python 3.10.15, a fresh Conda virtual env and installed Psiflow via pip.