Recent changes to config has created some notable breaking changes
Checklist
-
The issue remains in the development version of ASE. -
An minimal example is provided to reproduce the issue.
Pinging @askhl, @Mads-Peter.
The Problem
from ase.calculators.dftb import Dftb
Dftb()
This simple command breaks in master
with the following traceback:
File ~\github\ase\ase\calculators\dftb.py:122, in Dftb.__init__(self, restart, ignore_bad_restart_file, label, atoms, kpts, slako_dir, profile, **kw)
119 self.do_forces = False
120 self.outfilename = 'dftb.out'
--> 122 super().__init__(restart, ignore_bad_restart_file,
123 label, atoms, profile=profile,
124 **kwargs)
126 # Determine number of spin channels
127 try:
File ~\github\ase\ase\calculators\calculator.py:1033, in FileIOCalculator.__init__(self, restart, ignore_bad_restart_file, label, atoms, command, pr)
1031 profile = ArgvProfile(self.name, section.getargv('argv'))
1032 else:
-> 1033 raise EnvironmentError(
1034 f'No configuration of {self.name}. '
1035 f'Missing section [{self.name}] in configuration'
1036 )
1037 else:
1038 profile = OldShellProfile(self.name, command, self.prefix)
EnvironmentError: No configuration of dftb. Missing section [dftb] in configuration
The same is true for several other calculators.
The Explanation
This fails because the calculator is expecting the ASE_DFTB_COMMAND
environment variable. However, this is not appropriate because not everyone needs to set this environment variable. It is optional. The default command, shown below, is perfectly suitable for most users. So, for users relying on not setting any environment variable at all, things now break.
if 'DFTB_COMMAND' in FileIOCalculator.cfg:
command = FileIOCalculator.cfg['DFTB_COMMAND'] + ' > PREFIX.out'
else:
command = 'dftb+ > PREFIX.out'
In addition, the error message being raised right now is far too ambiguous for such a crucial user-facing problem.
Like I said above, this is not just DFTB+ and influences users in different ways.
We need better behavior when profile=None
is being passed.