cape.capeconfig: Interface to user-specific CAPE configuration¶
This file reads the settings file in either ~/.capeconfig.json
or $CAPE_CONFIGFILE, as controlled by cape.sysutils. It
provides the class CapeConfig. The purpose of this
configuration file is to set user-specific preferences and SSH paths.
For example, on Linux, the user may specify a preferred PDF reader
application. Users may also inform the user of their local workstation
so that commands like cape open-pdf $PDFFILE will first send them
from an HPC login node to a local workstation and open it there.
- class cape.capeconfig.CapeConfig(*args, **kw)¶
Bases:
OptionsDict- check_local() bool¶
Check if the current host is “local”
- Call:
>>> q = opts.check_local()
- Inputs:
- opts:
CapeConfig Cape configuration options instance
- opts:
- Outputs:
- q:
True|False Whether current host is “local”
- q:
- check_remote() bool¶
Check if the current host is “remote”
- Call:
>>> q = opts.check_remote()
- Inputs:
- opts:
CapeConfig Cape configuration options instance
- opts:
- Outputs:
- q:
True|False Whether current host is “remote”
- q:
- get_CacheDir(j=None, i=None, **kw)¶
Get Location for CAPE to cache files
- Call:
>>> CacheDir = opts.get_CacheDir(j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- j: {
None} |int Phase index; use
Noneto just return v- i: {
None} |int|np.ndarray opts.x index(es) to use with
@expr,@map, etc.- vdef: {
None} |object Manual default
- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- ring: {opts._optring[key]} |
True|False Override option to loop through phase inputs
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- x: {
None} |dict Ref conditions to use with
@expr,@map, etc.; often a run matrix; used in combination with i- sample: {
True} |False Apply j, i, and other settings recursively if output is a
listordict
- Outputs:
- CacheDir: {
'~/.cache/cape'} |str Location for CAPE to cache files
- CacheDir: {
- get_JumpHost() str | None¶
Get name of SSH JumpHost needed to transfer files
The result is based on the name of the current host
- Call:
>>> jumphost = opts.get_JumpHost()
- Inputs:
- opts:
CapeConfig Cape configuration options instance
- opts:
- Outputs:
- jumphost:
None|str Name of jump host, if any
- jumphost:
- get_LocalHost(j=None, i=None, **kw)¶
Get Name of ‘local’ machine; CAPE on remote systems will transfer files to this location for easier viewing. Override with
$CAPE_LOCAL_HOST- Call:
>>> LocalHost = opts.get_LocalHost(j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- j: {
None} |int Phase index; use
Noneto just return v- i: {
None} |int|np.ndarray opts.x index(es) to use with
@expr,@map, etc.- vdef: {
None} |object Manual default
- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- ring: {opts._optring[key]} |
True|False Override option to loop through phase inputs
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- x: {
None} |dict Ref conditions to use with
@expr,@map, etc.; often a run matrix; used in combination with i- sample: {
True} |False Apply j, i, and other settings recursively if output is a
listordict
- Outputs:
- LocalHost: {
None} |str Name of ‘local’ machine; CAPE on remote systems will transfer files to this location for easier viewing. Override with
$CAPE_LOCAL_HOST
- LocalHost: {
- get_LocalHostPatterns(j=None, i=None, **kw)¶
Get List of regexes to tell CAPE that current host is ‘local.’
- Call:
>>> LocalHostPatterns = opts.get_LocalHostPatterns(j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- j: {
None} |int Phase index; use
Noneto just return v- i: {
None} |int|np.ndarray opts.x index(es) to use with
@expr,@map, etc.- vdef: {
None} |object Manual default
- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- ring: {opts._optring[key]} |
True|False Override option to loop through phase inputs
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- x: {
None} |dict Ref conditions to use with
@expr,@map, etc.; often a run matrix; used in combination with i- sample: {
True} |False Apply j, i, and other settings recursively if output is a
listordict
- Outputs:
- get_RemoteHost(j=None, i=None, **kw)¶
Get Remote host for
cape receive-fileto get files from. Override with$CAPE_REMOTE_HOST.- Call:
>>> RemoteHost = opts.get_RemoteHost(j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- j: {
None} |int Phase index; use
Noneto just return v- i: {
None} |int|np.ndarray opts.x index(es) to use with
@expr,@map, etc.- vdef: {
None} |object Manual default
- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- ring: {opts._optring[key]} |
True|False Override option to loop through phase inputs
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- x: {
None} |dict Ref conditions to use with
@expr,@map, etc.; often a run matrix; used in combination with i- sample: {
True} |False Apply j, i, and other settings recursively if output is a
listordict
- Outputs:
- RemoteHost: {
None} |str Remote host for
cape receive-fileto get files from. Override with$CAPE_REMOTE_HOST.
- RemoteHost: {
- get_RemoteHostPatterns(j=None, i=None, **kw)¶
Get List of regexes for host names to tell CAPE that current host is ‘remote’;
cape post-fileandcape receive-filewill not transfer files.- Call:
>>> RemoteHostPatterns = opts.get_RemoteHostPatterns(j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- j: {
None} |int Phase index; use
Noneto just return v- i: {
None} |int|np.ndarray opts.x index(es) to use with
@expr,@map, etc.- vdef: {
None} |object Manual default
- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- ring: {opts._optring[key]} |
True|False Override option to loop through phase inputs
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- x: {
None} |dict Ref conditions to use with
@expr,@map, etc.; often a run matrix; used in combination with i- sample: {
True} |False Apply j, i, and other settings recursively if output is a
listordict
- Outputs:
- get_opt(opt: str, vdef=None, **kw) Any¶
Get value of an option with environment var override
- Call:
>>> v = opts.get_opt(opt, vdef=None)
- Inputs:
- opts:
CapeConfig Cape configuration options instance
- vdef: {
None} | any Default value
- opts:
- Outputs:
- v: any
Option value, with following order of importance
Environment variable
Value set in
~/.capeconfigDefault value from class
vdef
- set_CacheDir(v, j=None, mode=None)¶
Get Location for CAPE to cache files
- Call:
>>> opts.set_CacheDir(CacheDir, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- CacheDir: {
'~/.cache/cape'} |str Location for CAPE to cache files
- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_LocalHost(v, j=None, mode=None)¶
Get Name of ‘local’ machine; CAPE on remote systems will transfer files to this location for easier viewing. Override with
$CAPE_LOCAL_HOST- Call:
>>> opts.set_LocalHost(LocalHost, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- LocalHost: {
None} |str Name of ‘local’ machine; CAPE on remote systems will transfer files to this location for easier viewing. Override with
$CAPE_LOCAL_HOST- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_LocalHostPatterns(v, j=None, mode=None)¶
Get List of regexes to tell CAPE that current host is ‘local.’
- Call:
>>> opts.set_LocalHostPatterns(LocalHostPatterns, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- LocalHostPatterns: {
None} |list[str] List of regexes to tell CAPE that current host is ‘local.’
- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_PDFReader(v, j=None, mode=None)¶
Get Preferred PDF reader. Override with
$CAPE_PDF_READER.- Call:
>>> opts.set_PDFReader(PDFReader, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- PDFReader: {
None} |str Preferred PDF reader. Override with
$CAPE_PDF_READER.- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_PNGReader(v, j=None, mode=None)¶
Get Preferred PNG image viewer. Override with
$CAPE_PNG_READER.- Call:
>>> opts.set_PNGReader(PNGReader, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- PNGReader: {
None} |str Preferred PNG image viewer. Override with
$CAPE_PNG_READER.- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_RemoteHost(v, j=None, mode=None)¶
Get Remote host for
cape receive-fileto get files from. Override with$CAPE_REMOTE_HOST.- Call:
>>> opts.set_RemoteHost(RemoteHost, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- RemoteHost: {
None} |str Remote host for
cape receive-fileto get files from. Override with$CAPE_REMOTE_HOST.- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- set_RemoteHostPatterns(v, j=None, mode=None)¶
Get List of regexes for host names to tell CAPE that current host is ‘remote’;
cape post-fileandcape receive-filewill not transfer files.- Call:
>>> opts.set_RemoteHostPatterns(RemoteHostPatterns, j=None, i=None, **kw)
- Inputs:
- opts: CapeConfig
options interface
- RemoteHostPatterns: {
None} |list[str] List of regexes for host names to tell CAPE that current host is ‘remote’;
cape post-fileandcape receive-filewill not transfer files.- j: {
None} |int Phase index; use
Noneto just return v- mode: {
None} |0|1|2|3 Warning mode code
0:no checks
1:validate silently
2:validate and show warnings
3:raise an exception if invalid
- listdepth: {
0} |int> 0 Depth of list to treat as a scalar
- class cape.capeconfig.JumpHostConfig(*args, **kw)¶
Bases:
OptionsDict
- cape.capeconfig.check_cape_local() bool¶
Check if the current host is “local”
- Call:
>>> q = check_cape_local()
- Outputs:
- q:
True|False Whether current host is “local”
- q:
- cape.capeconfig.check_cape_remote() bool¶
Check if the current host is “remote”
- Call:
>>> q = check_cape_remote()
- Outputs:
- q:
True|False Whether current host is “remote”
- q:
- cape.capeconfig.get_cape_cachedir() str¶
Get (and create) cache folder
The order of precedence is
The environment variable
$CAPE_CACHE_DIRThe CacheDir setting in
~/.capeconfig.jsonThe global default
~/.cache/cape/
- Call:
>>> cachedir = get_cape_cachedir()
- Outputs:
- cachedir:
str Location of cache to use for temporary CAPE files
- cachedir:
- cape.capeconfig.get_cape_jumphost() str | None¶
Get JumpHost for SSH to reach intended target, based on $HOST
- Call:
>>> jumphost = get_cape_jumphost()
- Outputs:
- jumphost:
None|str Name of SSH JumpHost needed, if needed
- jumphost:
- cape.capeconfig.get_pdf_viewer() str¶
Get the preferred PDF viewer application based on system
- Call:
>>> viewer = get_pdf_viewer()
- Outputs:
- viewer:
str Name of application to open PDF
- viewer:
- Versions:
2026-08-07
@ddalle: v1.0
- cape.capeconfig.get_png_viewer() str¶
Get the preferred PNG viewer application based on system
- Call:
>>> viewer = get_png_viewer()
- Outputs:
- viewer:
str Name of application to open PNG
- viewer:
- Versions:
2026-08-31
@ddalle: v1.0
- cape.capeconfig.read_cape_config() CapeConfig¶
Read config from
~/.capeconfig.jsonor$CAPE_CONFIG_FILE- Call:
>>> opts = read_cape_config()
- Outputs:
- opts:
CapeConfig CAPE user settings
- opts: