grimme-lab / dxtb

Efficient And Fully Differentiable Extended Tight-Binding
https://dxtb.readthedocs.io
Apache License 2.0
71 stars 11 forks source link

dxtb._src.timing.timer.TimerError: Timer 'Classicals' is running. Use `.stop()` to stop it. #175

Closed njzjz closed 2 months ago

njzjz commented 2 months ago

Hi, how can I prevent the following error? I don't explicitly use Timer in my code.

    energy = calc.energy(coordinates, total_charge)
  File "env/lib/python3.10/site-packages/dxtb/_src/calculators/types/decorators.py", line 259, in wrapper
    result = func(self, *args, **kwargs)
  File "env/lib/python3.10/site-packages/dxtb/_src/calculators/types/energy.py", line 386, in energy
    self.singlepoint(positions, chrg, spin, **kwargs)
  File "env/lib/python3.10/site-packages/dxtb/_src/calculators/types/energy.py", line 127, in singlepoint
    timer.start("Classicals")
  File "env/lib/python3.10/site-packages/dxtb/_src/timing/timer.py", line 300, in start
    self.timers[uid].start()
  File "env/lib/python3.10/site-packages/dxtb/_src/timing/timer.py", line 123, in start
    raise TimerError(
dxtb._src.timing.timer.TimerError: Timer 'Classicals' is running. Use `.stop()` to stop it.
marvinfriede commented 2 months ago
from dxtb import timer

timer.disable()

This will not start any timers afterwards. However, the global timer will still be running, as it is started upon import (see here).

If everything should stop, use

from dxtb import timer

timer.kill()
njzjz commented 2 months ago

Thanks. It works.