Proposal: ASE site configuration file
@askhl brought up the idea of an ASE configuration file in !1777 (merged), specifically with a focus on running tests. I think this idea can be generalized to any custom user-provided data used within ASE, such as:
- Location of Calculator executables
- Directives for running multi-processing jobs (e.g.
'mpirun -np NPROC COMMAND'
) - Location of data files such as pseudopotentials
- Global information, such as the location of scratch space in which to run calculations.
- Any other Calculator-specific settings that the Calculator has defined.
In !1777 (merged), the suggestion was to use json, but if we want it to be a sort of global ASE configuration file, then I think it would be better to use Python's native configparser utility, which has an INI-like syntax. Here's a hypothetical config file (GitLab's INI file highlighting doesn't like spaces in key names, but Python's configparser
doesn't care about that):
[DEFAULT]
# Global settings for all calculators
scratch=/scratch/$USER
# We can support multiprocessing by encoding an `nproc` keyword common to all
# calculators into a user-provided command
parallel=srun -A MyCoolProject -n NPROC
[vasp]
exe=/opt/vasp5.4/vasp_std
pseudo dir=/opt/vasp5.4/potPAW_PBE
# Codes that support parallelism through command line arguments can define
# their commands with PARALLEL, which will be replaced by the "parallel"
# settings
command=PARALLEL EXE > PREFIX.log
# This determines the name of the file that is written to by
# FileIOCalculator.write_input
inputname=POSCAR
# This determines the name of the file that is read by
# FileIOCalculator.read_output
outputname=OUTCAR
[vasp_gam]
# Special calculator "profiles" are specified with an underscore in the section
# name. All settings are inherited from the "base" profile (if it is present)
# unless explicitly overridden
# These profiles can be invoked e.g. by `calc = VASP(profile='gam', ...)`.
exe=/opt/vasp5.4/vasp_gam
[vasp_otherproject]
# Global settings can be overridden by local settings
parallel=srun -A SomeOtherProject -n NPROC
[gaussian]
exe=/opt/gaussian/g16/g16
# For codes that determine parallelism based on the input file, rather than
# command-line options, we can translate a top-level `nproc` keyword into
# a Calculator-specific keyword:
nproc keyword=nprocshared
# if "nproc keyword" is present, then NPROC should not be in "command".
# "command" can be written with INPUTNAME and OUTPUTNAME, which will be
# replaced by the values of "inputname" and "outputname", respectively.
inputname=PREFIX.com
outputname=PREFIX.log
command=EXE < INPUTNAME > OUTPUTNAME
Here's the same thing with the comments removed:
[DEFAULT]
scratch=/scratch/$USER
parallel=srun -A MyCoolProject -n NPROC
[vasp]
exe=/opt/vasp5.4/vasp_std
pseudo dir=/opt/vasp5.4/potPAW_PBE
command=PARALLEL EXE > PREFIX.log
inputname=POSCAR
outputname=OUTCAR
[vasp_gam]
exe=/opt/vasp5.4/vasp_gam
[vasp_otherproject]
parallel=srun -A SomeOtherProject -n NPROC
[gaussian]
exe=/opt/gaussian/g16/g16
nproc keyword=nprocshared
inputname=PREFIX.com
outputname=PREFIX.log
command=EXE < INPUTNAME > OUTPUTNAME
This config file can be present both in /etc
(e.g. /etc/ase.conf
) or some other global space, or in a user's home directory (e.g. /home/$USER/.config/ase
), with settings in the latter overriding those in the former. Global configuration allows compute cluster sysadmins to configure ASE to work with all of the codes installed on the cluster with zero effort on the part of the user.
Additionally, the config file should be completely optional. The Calculators are responsible for being able to function even if no configuration file is present.