Change `init` from a function into a context manager
This PR changes plams.init from a function into a context manager.
In addition to calling it as a normal function, as could be done previously, plams.init can now be used on conjunction with the with statement. In the latter case plams.finish will be automatically called upon exiting the context manager.
Examples
>>> from scm.plams import Molecule, Settings, AMSJob, init, finish
>>> mol: Molecule = ...
>>> settings: Settings = ...
>>> with init():
... job1 = AMSJob(molecule=mol, settings=settings)
... result1 = job1.run()
# Equivalently:
>>> init()
>>> job2 = AMSJob(molecule=mol, settings=settings)
>>> result2 = job2.run()
>>> finish()
If possible it would be nice to have a unit test proving that both the context manager syntax and the normal syntax work.
If possible it would be nice to have a unit test proving that both the context manager syntax and the normal syntax work.
Sorry, but considering the PLAMS test suite (at least on github) currently lacks any sort of infrastructure for testing the likes of init, job managers or running actual jobs I'm going to have to decline here, as this would involve this would effectively require setting up a whole new suite of testing infrastructure.