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

[BUG] UnboundLocalError: cannot access local variable 'stepbindex' where it is not associated with a value #1490

Open
PenguinW1105 opened this issue Mar 22, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@PenguinW1105
Copy link

Bug summary

When I used dpgen init_reaction to build my dataset in WSL2(Ubuntu 20.04), I met with the error "Unbound Local Error: cannot access local variable 'stepbindex' where it is not associated with a value". At first, in order to learn how to solve this problem, I used the same file and runed it on the Windows, but the problem did not appear. The specific message was shown in the part of "Steps to Reproduce"

DP-GEN Version

0.12.0

Platform, Python Version, Remote Platform, etc

WSL2(Ubuntu 20.04), python 3.11.4

Input Files, Running Commands, Error Log, etc.

Input files has been uploaded [param.json] [machine.json]
machine.json
param.json

Running Commands: dpgen init_reaction param.json machine.json

Error Log:
Traceback (most recent call last):
File "/home/penguinw/anaconda3/bin/datasetbuilder", line 8, in
sys.exit(_commandline())
^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/mddatasetbuilder/datasetbuilder.py", line 711, in _commandline
DatasetBuilder(
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/mddatasetbuilder/datasetbuilder.py", line 109, in init
self.crddetector = Detect.gettype("dump")(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/mddatasetbuilder/detect.py", line 23, in init
self.steplinenum = self._readN()
^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/mddatasetbuilder/detect.py", line 168, in _readN
steplinenum = stepbindex - stepaindex
^^^^^^^^^^
UnboundLocalError: cannot access local variable 'stepbindex' where it is not associated with a value

Steps to Reproduce

Firstly, I used the command "dpgen init_reaction param.json machine.json" and then the error appeared.
Secondly, I used another simple file to run lammps and produce the lammpstrj and bond file. And then I used the files to run the command " datasetbuilder -d pyrolysis.lammpstrj -b pyrolysis.bonds.out -a C H N O S -np 4 -c 6 -s 5000 -n pyrolysis" on the Windows Platform by anaconda prompt, and it did not appear any error.
Thirdly, I used the file which was the same one used in the second path to run the command "dpgen init_reaction param.json machine.json", but the error still appeared.

Further Information, Files, and Links

No response

@PenguinW1105 PenguinW1105 added the bug Something isn't working label Mar 22, 2024
@njzjz
Copy link
Member

njzjz commented Mar 22, 2024

Please check two things and may post here:

(1) the final command you ran, which should be in *.sub.run file in the remote root;
(2) the lammps dump file in the remote root is not broken.

@njzjz njzjz self-assigned this Mar 22, 2024
@PenguinW1105
Copy link
Author

Please check two things and may post here:

(1) the final command you ran, which should be in *.sub.run file in the remote root; (2) the lammps dump file in the remote root is not broken.

Thank you very much for your answer, but the error still appeared. In fact, I used a local computer to run the dpgen. But if there was not "remote_root" in the machine json, it would generate a new error whose log was shown below:
Traceback (most recent call last):
File "/home/penguinw/anaconda3/bin/dpgen", line 10, in
sys.exit(main())
^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpgen/main.py", line 255, in main
args.func(args)
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpgen/data/reaction.py", line 237, in gen_init_reaction
run_build_dataset(jdata, mdata)
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpgen/data/reaction.py", line 137, in run_build_dataset
make_submission_compat(
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpgen/dispatcher/Dispatcher.py", line 145, in make_submission_compat
submission = make_submission(
^^^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpgen/dispatcher/Dispatcher.py", line 30, in make_submission
machine = Machine.load_from_dict(abs_mdata_machine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpdispatcher/machine.py", line 150, in load_from_dict
context = BaseContext.load_from_dict(machine_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpdispatcher/base_context.py", line 45, in load_from_dict
context = context_class.load_from_dict(context_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/penguinw/anaconda3/lib/python3.11/site-packages/dpdispatcher/contexts/local_context.py", line 67, in load_from_dict
remote_root = context_dict["remote_root"]
~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'remote_root'

@PenguinW1105
Copy link
Author

Please check two things and may post here:

(1) the final command you ran, which should be in *.sub.run file in the remote root; (2) the lammps dump file in the remote root is not broken.

I seem to know what generates this problem. The lammpstrj in the 01.build/task.000 seem to be broken, and the specific message of the sub.run file was here:
cd $REMOTE_ROOT
cd task.000
test $? -ne 0 && exit 1
if [ ! -f 9307c5b04012a935431bbe1f56d6e3dd6d103dc0_task_tag_finished ] ;then
( datasetbuilder -n dpgen_init -a C H O N S -d lammpstrj -c 6.0 -s 5000 -k "force m062x/6-31g** Geom=PrintInputOrient" --nprocjob 1 --nproc 1 ) 1>>build_log 2>>build_log
if test $? -eq 0; then touch 9307c5b04012a935431bbe1f56d6e3dd6d103dc0_task_tag_finished; else echo 1 > $REMOTE_ROOT/ab1afb0fe00ed3fd28f23039df670e0ad1d79aa2_flag_if_job_task_fail;tail -v -c 1000 $REMOTE_ROOT/task.000/build_log > $REMOTE_ROOT/ab1afb0fe00ed3fd28f23039df670e0ad1d79aa2_last_err_file;fi
fi &
wait

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

No branches or pull requests

2 participants