Configuration¶
Most of the choices that HyperShell makes about timing, task bundling, coordination, logging, and such are configurable by the user. This configuration is loaded when the program starts and is constructed from several sources including an ordered merger of files, environment variables, and command-line options.
In order of precedence (lowest to highest), three files are loaded for system, user and local configuration. See below the section on file system paths for more details.
On Linux (for example):
Site |
Path (Linux / POSIX) |
|---|---|
System |
|
User |
|
Local |
|
The TOML format is modern and minimal.
Every configurable option can be set in one of these files. Further, every option can also be set by an environment variable, where the name aligns to the path to that option, delimited by underscores.
For example, set the logging level at the user level with a command:
Set user-level configuration option
hs config set logging.level info --user
The file should now look something like this:
~/.hypershell/config.toml
# File automatically created on 2022-07-02 11:57:29.332993
# Settings here are merged automatically with defaults and environment variables
[logging]
level = "info"
Alternatively, you can set an environment variable and the runtime configuration would be equivalent:
Define environment variable
export HYPERSHELL_LOGGING_LEVEL=INFO
Finally, any option defined within a configuration file that ends with _env or _eval
is automatically expanded by the given environment variable or shell expression,
respectively. This is useful as both a dynamic feature but also as a means to
obfuscate sensitive information, such as database connection details.
~/.hypershell/config.toml
# File automatically created on 2022-07-02 11:57:29.332993
# Settings here are merged automatically with defaults and environment variables
[logging]
level = "info"
[database]
provider = "postgres"
database = "hypershell"
host = "my.instance.university.edu"
user = "me"
password_eval = "pass hypershell/database/password" # Decrypt using GNU Pass
The edit command makes it easy to open the correct configuration file path for your platform
using the default editor. Set the EDITOR environment variable (or VISUAL on Windows).
Open global user-level configuration file for editing
hs config edit --user
Filesystem Paths¶
The site refers to the locations on the file system from which configuration files are found and output files are written to. This entails a library (or lib) path for where to capture outputs; a log path for where to write logs and exceptions; and a config file path. There are two environment variables that play a role in modifying this behavior.
HYPERSHELL_SITEThe default site path for outputs is either the user or system site based on whether the program was run as root/admin. The local path is always the current working directory for the program. If this environment variable is set then it takes the place of the local site and used as the default.
HYPERSHELL_CONFIG_FILEUnder normal operations the program searches all three system, user, and local sites to load the full configuration in addition to all prefixed environment variables. This can actually cause issues for scenarios with many instances of the program running on the same file system, such as an HPC cluster. In order to protect against unintended crashes from incidental configuration changes, defining this environment variable specifies the one and only path to a configuration file and all others will be ignored. Setting this to empty results in no files being loaded (an environment only runtime).
The paths to these locations is platform specific. On Windows and macOS, the program abides by the conventions of that platform, just as on Linux (otherwise assumed POSIX). Below we have enumerated all variations with Library, Logs, and Config in each case.
- Windows
- System
%PROGRAMDATA%\HyperShell\Library%PROGRAMDATA%\HyperShell\Logs%PROGRAMDATA%\HyperShell\Config.toml
- User
%APPDATA%\HyperShell\Library%APPDATA%\HyperShell\Logs%APPDATA%\HyperShell\Config.toml
- Local
%HYPERSHELL_SITE%\Library%HYPERSHELL_SITE%\Logs%HYPERSHELL_SITE%\Config.toml
- macOS
- System
/Library/HyperShell/Library/HyperShell/Logs/Library/Preferences/HyperShell/config.toml
- User
$HOME/Library/HyperShell$HOME/Library/HyperShell/Logs$HOME/Library/Preferences/HyperShell/config.toml
- Local
$HYPERSHELL_SITE/Library$HYPERSHELL_SITE/Logs$HYPERSHELL_SITE/config.toml
- Linux / POSIX
- System
/var/lib/hypershell/var/log/hypershell/etc/hypershell.toml
- User
$HOME/.hypershell/lib$HOME/.hypershell/log$HOME/.hypershell/config.toml
- Local
$HYPERSHELL_SITE/lib$HYPERSHELL_SITE/log$HYPERSHELL_SITE/config.toml
Runtime Package Resolution¶
The following environment variable may be set to harden the installation against accidentally polluting the package resolution of HyperShell itself from user software.
HYPERSHELL_PYTHONPATHAs a Python application HyperShell may be exposed to
PYTHONPATH. This can happen in instances where the user tasks themselves are Python based. To avoid possible collisions we can guard HyperShell by explicitly setting the path list (sys.path). This environment variable may be set in a similar fashion as the standardPYTHONPATH. Or it may instead contain a file path, in which case the content of the file should have one path per line.
Parameter Reference¶
[logging]Logging configuration. See also logging section.
.levelOne of
TRACE,DEBUG,INFO,WARNING,ERROR, orCRITICAL(default:INFO)INFOlevel messages are reserved for clients when tasks begin running. There are numerous WARNING events (e.g., non-zero exit status of a task).DEBUGlevel messages signal component thread start/stop and individual task level behavior.TRACEcontains detailed information on all other behavior, particular iterative messages while components are waiting for something.ERRORmessages track when things fail but the application can continue; e.g., when command template expansion fails on an individual task.CRITICALmessages are emitted when the application will halt or crash. Some of these are expected (such as incorrect command-line arguments) but in the event of an uncaught exception within the application a full traceback is written to a file and logged..datefmtDate/time format, standard codes apply (default:
'%Y-%m-%d %H:%M:%S'`).formatLog message format.
Default set by the “default”
logging.style. See the available attributes defined by the underlying Python logging interface.Additional attributes provided beyond the standard include app_id, hostname, hostname_short, relative_name, time formats in elapsed, elapsed_ms, elapsed_delta, and elapsed_hms, as well as all ANSI colors and formats as ansi_x where x is one of reset, bold, faint, italic, underline, black, red, green, yellow, blue, magenta, cyan, white, and ansi_level contains the standard color for the current message severity level.
.stylePresets for
logging.formatwhich can be difficult to define correctly. Options are default, detailed, detailed-compact, system, and short..colorEnable ANSI color and formatting in console output (default:
true).Colors are emitted only when stderr is a TTY and are always stripped from file-based logs. See also the
NO_COLORandFORCE_COLORenvironment variables.[file]File-based logging (disabled unless at least one parameter is set). See the logging section for full details on rotation and compression.
As a shorthand,
logging.filemay be set directly to"enabled"(ortrue) to log to the default per-process file, or to a path to log there; both forms disable rotation and compression..pathDestination file path. Defaults to a per-process, host-scoped file in the site
logdirectory (e.g.server-<host>.log,client-<host>.log, ormain.log). Parent directories are created as needed..levelMinimum severity written to the file (default:
TRACE). Accepts the same names aslogging.level, independent of the console level..styleFormat preset for the file (default:
system). Accepts the same options aslogging.style; aformatmay be given instead. ANSI color is always stripped..rotateRotation policy (default:
never). Either a size threshold such as512MB(unitsKB/MB/GB/TB, powers of 1024; a bare number is bytes) or a cron expression such as@daily,@midnight, or0 1 * * 0(requires thecroniterpackage). SendingSIGHUProtates on demand..compressCompression for rotated files (default: none). One of
gzip,bzip,lzma, orzstd(the last requires the optionalzstandardpackage). Extensions.gz,.bz2,.xz, and.zstdrespectively..keepNumber of uncompressed rotated files to retain (default:
0). Only applies when compression is enabled; without compression, rotated files are never deleted.
[database]Database configuration and connection details. See also database section.
.urlFull database connection URL (default: none).
When provided, this takes precedence over and short-circuits the individual
.provider/.host/.port/.user/.passwordfields below..providerDatabase provider (default: ‘sqlite’). Supported alternatives include ‘postgres’ (or compatible). Support for other providers may be considered in the future.
.fileOnly applicable for SQLite provider. SQLite does not understand any other connection detail.
.databaseName for database. Not applicable for SQLite.
.schemaNot applicable for all RDMS providers. For Postgres the default schema is
public. Specifying the schema may be useful for having multiple instances within the same database..hostHostname or address of database server (default: localhost).
.portPort number to connect with database server. The default value depends on the provider, e.g., 5432 for Postgres.
.userUsername for databaser server account. If provided a
passwordmust also be provided. Default is the local account..passwordPassword for database server account. If provided a
usermust also be provided. Default is the local account.See also note on
_envand_eval..echoSpecial parameter enables verbose logging of all database transactions.
[connect_args]Specify additional connection details for the underlying SQL dialect provider, e.g.,
sqlite3orpsycopg.[pragmas]Specify one or more pragmas to apply to database connections (SQLite only). For example
pragmas = { journal_mode = "wal" }to enable WAL-mode.*Any additional arguments are forwarded to the provider, e.g.,
encoding = 'utf-8'.
[server]Section for server workflow parameters.
.bindBind address (default: localhost).
When running locally, the default is recommended. To allow remote clients to connect over the network, bind the server to 0.0.0.0.
.hostHost address that clients connect to (default: localhost).
Counterpart to
.bind: where.bindis the local address the server listens on,.hostis the address that client instances and queue-directsubmit --queuedial to reach the server. Set this to the server’s reachable hostname or address when running clients on other machines..portPort number (default: 50001).
This is an arbitrary choice and simply must be an available port. The default option chosen here is typically available on most platforms and is not expected by any known major software.
.authCryptographic authentication key to connect with server (default: <not-secure>).
The default KEY used by the server and client is not secure and only a place holder. It is expected that the user choose a secure KEY. The cluster automatically generates a secure one-time KEY.
.queuesizeMaximum number of task bundles on the shared queue (default: 1).
This blocks the next bundle from being published by the scheduler until a client has taken the current prepared bundle. On smaller scales this is probably best and is only of modest performance impact, limiting the scheduler from getting so far ahead of the currently running tasks.
On large scale workflows with many clients (e.g., 100) it may be advantageous to allow the scheduler to work ahead in selecting new tasks.
.bundlesizeSize of task bundle (default: 1).
The default value allows for greater concurrency and responsiveness on small scales. This is used by the submit thread to accumulate bundles for either database commits and/or publishing to the queue. If a database is in use, the scheduler thread selects tasks from the database in batches of this size.
Using larger bundles is a good idea for large distributed workflows; specifically, it is best to coordinate bundle size with the number of executors in use by each client.
See also
-b/--bundlesizecommand-line option..attemptsAttempts for auto-retry on failed tasks (default: 1).
If a database is in use, then there is an opportunity to automatically retry failed tasks. A task is considered to have failed if it has a non-zero exit status. The original is not over-written, a new task is submitted and later scheduled.
Counterpart to the
-r/--max-retriescommand-line option. Setting--max-retries 1is equivalent to setting.attemptsto 2.See also
.eager..eagerSchedule failed tasks before new tasks (default: false).
If
.attemptsis greater than one, this option defines the appetite for re-submitting failed tasks. By default, failed tasks will only be scheduled when there are no more remaining novel tasks..pollMaximum polling interval in seconds between database queries when no tasks are available (default: 30).
The scheduler backs off exponentially from a small floor, doubling the wait after each empty query up to this ceiling. This waiting only occurs when no tasks are returned by the query.
See also
-Q/--pollcommand-line option..evictEviction period in seconds for clients (default: 600).
If a client fails to register a heartbeat after this period of time it is considered defunct and is evicted. When there are no more tasks to schedule the server sends a disconnect request to all registered clients, and waits until a confirmation is returned for each. If a client is defunct, this will hang the shutdown process.
[tls]Transport-layer security for queue connections. Enabled by default; every key below is also exposed as an environment variable (e.g.,
HYPERSHELL_SERVER_TLS_ENABLED) with the usual precedence. See the built-in TLS section for the full model, including peer verification modes and limitations..enabledUse TLS on the queue interface (default: true).
Disabling (
enabled = falseor the--no-tlsoption) sends task bundles and results in the clear and is not recommended outside a trusted, isolated network..certPath to the server certificate, or
<auto>(default: <auto>).With
<auto>a self-signed certificate is generated once on first server start and stored under the sitelibdirectory (<site>/lib/tls)..keyPath to the server private key, or
<auto>(default: <auto>).Paired with
.cert. The auto-generated key is written owner-only (0600); a user-provided key file should be protected the same way..cafileTrust anchor used by the client to verify the server (default: <auto>).
With
<auto>the client trusts the server’s own certificate directly, which works out of the box only on a single host or a shared filesystem. Provide a PEM bundle PATH (together with.servername) to verify peers across hosts..fingerprintPinned peer certificate fingerprint, e.g.
SHA256:AB:CD:...(default: none).When set, the client completes the handshake without CA validation and rejects the connection unless the certificate fingerprint matches. Takes precedence over
.cafile. Convenient for self-signed certificates and small clusters..insecureDisable peer verification entirely (default: false).
The transport is still encrypted, but the peer identity is not authenticated and a warning is logged on every connection. Suitable only for transient local debugging on a trusted host; never use it on an untrusted network.
.min_versionMinimum TLS protocol version (default: TLSv1.2). Either
TLSv1.2orTLSv1.3..ciphersOpenSSL cipher string to restrict the negotiated ciphers (default: none).
.servernameExpected server name for identity verification / SNI override (default: none).
Required alongside
.cafilefor true server-identity verification: with a trust anchor set but no.servername, the client checks only that the certificate chains to the anchor, not which host presented it.
[client]Section for client workflow parameters.
.bundlesizeSize of task bundle (default: 1).
The default value allows for greater concurrency and responsiveness on small scales.
Using larger bundles is a good idea for larger distributed workflows; specifically, it is best to coordinate bundle size with the number of executors in use by each client. It is also a good idea to coordinate bundle size between the client and server so that the client returns the same sized bundles that it receives.
See also
-b/--bundlesizecommand-line option..bundlewaitSeconds to wait before flushing task bundle (default: 5).
If this period of time expires since the previous bundle was returned to the server, the current group of finished tasks will be pushed regardless of bundlesize.
For larger distributed workflows it is a good idea to make this waiting period sufficiently long so that most bundles are returned whole.
See also
-w/--bundlewaitcommand-line option..heartrateInterval in seconds between heartbeats sent to server (default 10).
Even on the largest scales the default interval should be fine.
.timeoutTimeout in seconds for client. Automatically shutdown if no tasks received (default: never).
This feature allows for gracefully scaling down a cluster when task throughput subsides.
.coresClient-level limit on CPU cores available for running tasks (default: all available).
A value of
0means unconstrained (use all detected cores). Set a lower value to partition a node between multiple clients.See also
-C/--client-corescommand-line option..memoryClient-level limit on memory (in bytes) available for running tasks (default: all available).
A value of
0means unconstrained. Set a lower value to partition a node’s memory between multiple clients.See also
-M/--client-memorycommand-line option..ratelimitMaximum number of tasks started per second (default: no limit).
A value of
0disables rate limiting. Useful to throttle very short tasks so that task launch does not overwhelm a shared resource.See also
-R/--ratelimitcommand-line option.
[submit]Section for submit workflow parameters.
.bundlesizeSize of task bundle (default: 1).
The default value allows for greater concurrency and responsiveness on small scales. Using larger bundles is a good idea for large distributed workflows; specifically, it is best to coordinate bundle size with the number of executors in use by each client.
See also
-b/--bundlesizecommand-line option..bundlewaitSeconds to wait before flushing tasks (default: 5).
If this period of time expires since the previous bundle was pushed to the database, the current bundle will be pushed regardless of how many tasks have been accumulated.
See also
-w/--bundlewaitcommand-line option.
[task]Section for task runtime settings.
.cwdExplicitly set the working directory for all tasks.
.coresDefault cores required per task (default: unconstrained).
A value of
0means unconstrained. Used with resource-aware scheduling and backfill; individual tasks may override this inline (e.g.,# HYPERSHELL: cores:8).See also
-c/--corescommand-line option..memoryDefault memory (in bytes) required per task (default: unconstrained).
A value of
0means unconstrained. Used with resource-aware scheduling and backfill; individual tasks may override this inline (e.g.,# HYPERSHELL: memory:8GB).See also
-m/--memorycommand-line option..timeoutTask-level walltime limit (default: none).
Executors will send a progression of SIGINT, SIGTERM, and SIGKILL. If the process still persists the executor itself will shutdown.
.signalwaitWait period in seconds between signal escalation on task cancellation (default: 10).
See also
-S,--signalwaitcommand-line option.
[ssh]SSH configuration section.
.configPath to the SSH client configuration file (default:
~/.ssh/config).Host entries defined there are honored when connecting to nodes in
ssh.nodelist..argsSSH connection arguments; e.g.,
-i ~/.ssh/some.key. It is preferable to configure SSH directly however, in~/.ssh/config.[nodelist]This can be a single list of hostnames or a section when multiple named lists. Reference named groups from the command-line with
--ssh-group.Such as,
.mycluster = ['mycluster-01', 'mycluster-02', 'mycluster-03']
[autoscale]Define an autoscaling policy and parameters.
.policyEither fixed or dynamic.
A fixed policy will seek to maintain a definite size and allows for recovery in the event that clients halt for some reason (e.g., due to expected faults or timeouts).
A dynamic policy maintains a minimum size and grows up to some maximum size depending on the observed task pressure given the specified scaling factor.
See also
.factor,.period,.size.init,.size.min, and.size.max..factorScaling factor (default: 1).
A dimensionless quantity used by the dynamic policy. This value expresses some multiple of the average task duration in seconds.
The autoscaler periodically checks
toc / (factor x avg_duration), wheretocis the estimated time of completion for all remaining tasks given current throughput of active clients. This ratio is referred to as task pressure, and if it exceeds 1, the pressure is considered high and we will add another client if we are not already at the maximum size of the cluster.For example, if the average task length is 30 minutes, and we set
factor = 2, then if the estimated time of completion of remaining tasks given currently connected executors exceeds 1 hour, we will scale up by one unit.See also
.period..periodScaling period in seconds (default: 60).
The autoscaler waits for this period of time in between checks and scaling events. A shorter period makes the scaling behavior more responsive but can effect database performance if checks happen too rapidly.
.launcherCommand prefix used to launch each client as a scaling unit (default: none).
An empty value launches clients directly as
hs client .... Set a launcher such as an MPI or SLURM command (e.g.,srun) to bring up each client through your resource manager. Counterpart to the cluster--launcheroption used with--autoscaling.[size].initInitial size of cluster (default: 1).
When the the cluster starts, this number of clients will be launched. For a fixed policy cluster, this should be given with a
.minsize, and likely the same value..minMinimum size of cluster (default: 0).
Regardless of autoscaling policy, if the number of launched clients drops below this value we will scale up by one. Allowing
min = 0is an important feature for efficient use of computing resources in the absence of tasks..maxMaximum size of cluster (default: 1).
For a dynamic autoscaling policy, this sets an upper limit on the number of launched clients. When this number is reached, scaling stops regardless of task pressure.
[console]Rich text display and output parameters.
.themeColor scheme to use by default in output (default: monokai), such as with
hs infoandhs search.This option is passed to the rich library.
[export]Any variable defined here is injected as an environment variable for tasks.
Example,
foo = 1The environment variable
FOO=1would be defined for all tasks.
Task Environment¶
A few common environment variables are defined for every task.
TASK_IDUniversal identifier (UUID) for the current task.
TASK_ARGSOriginal input command-line argument line. Equivalent to
{}, see templates section.TASK_SUBMIT_IDUniversal identifier (UUID) for submitting application instance.
TASK_SUBMIT_HOSTHostname of submitting application instance.
TASK_SUBMIT_TIMETimestamp task was submitted.
TASK_SERVER_IDUniversal identifier (UUID) for server application instance.
TASK_SERVER_HOSTHostname of server application instance.
TASK_SCHEDULE_TIMETimestamp task was scheduled by server.
TASK_CLIENT_IDUniversal identifier (UUID) for client application instance.
TASK_CLIENT_HOSTHostname of client application instance.
TASK_COMMANDFinal command line for task.
TASK_ATTEMPTInteger number of attempts for current task (starts at 1).
TASK_PREVIOUS_IDUniversal identifier (UUID) for previous attempt (if any).
TASK_CWDCurrent working directory for the current task.
TASK_START_TIMETimestamp task began execution.
TASK_WAITEDTime in seconds between task submit time and schedule time.
TASK_OUTPATHAbsolute file path where standard output is directed (if defined).
TASK_ERRPATHAbsolute file path where standard error is directed (if defined).
Any user-defined tags are included as environment variables as well with
TASK_TAG_ as a prefix. For example, some tag site:us-west-1 would be
exposed as TASK_TAG_SITE=us-west-1.
Further, any environment variable defined by the user with HYPERSHELL_EXPORT_ will be
injected into the task environment sans prefix; e.g., HYPERSHELL_EXPORT_FOO would define
FOO in the task environment. You can also define such variables in the export
section of your configuration file(s); e.g.,
~/.hypershell/config.toml
# File automatically created on 2022-07-02 11:57:29.332993
# Settings here are merged automatically with defaults and environment variables
[logging]
level = "info"
# Options defined as a list will be joined with a ":" on BSD/Linux or ";" on Windows
# Environment variables will be in all-caps (e.g., FOO and PATH).
[export]
foo = "value"
path = ["/some/bin", "/some/other/bin"]
We also respect setting the following environment variables to force disable/enable the use of colors in all console output.
NO_COLORIf this variable is set to anything but a blank string, all colors are disabled. See no-color.org for details.
FORCE_COLORIf this variable is set to anything but a blank string, colors will be enabled regardless of whether stdout or stderr are a TTY.
Signals¶
HyperShell traps the following UNIX signals (does not apply on Microsoft Windows).
SIGUSR1Sending the
SIGUSR1signal will trigger the schedulers to halt and begin shutdown procedures. On the client side, this means that all current tasks (and any in the local queue) will be allowed to complete, but the system will drain and shutdown at the completion of these tasks.SIGUSR2Sending the
SIGUSR2signal implies the same, but on the client side will set a flag to send local interrupts to tasks to come down faster. As described in the previous release with regard to thetask.timeoutfeature, we sendSIGINT,SIGTERM, andSIGKILLin an escalating fashion to halt running tasks.SIGHUPSending the
SIGHUPsignal triggers an immediate rotation of the process’s log file, when file-based logging is enabled. This is the conventional way to rotate logs on demand from an external tool. See the logging section.