hydra.overlay.python.lib.system module

Python implementations of hydra.overlay.python.lib.system primitives.

These are real system-interface primitives. In Python the Hydra type effect<t> is transparent (effect<t> = t), so each primitive performs its effect eagerly. Fallible primitives return an Either[SystemError, T]: a failure to launch (or perform the call) is returned as Left(error); success is returned as Right(value). Infallible primitives (get_environment, get_environment_variable, get_time) return their value directly. This mirrors the Haskell reference implementation in Hydra.Haskell.Lib.System. For #498.

hydra.overlay.python.lib.system.execute(command: Command) object

Run a program to completion and capture its result.

A child that runs and exits non-zero is returned as Right(result) with that exit code; only a failure to launch is Left(error). No shell is invoked; the program is executed directly.

hydra.overlay.python.lib.system.exit(code: StatusCode) None

Terminate the current process with the given status code. Does not return.

hydra.overlay.python.lib.system.get_environment()

Get the full set of environment variables, as a map from variable name to value.

hydra.overlay.python.lib.system.get_environment_variable(name: EnvironmentVariable)

Look up a single environment variable by name; none if it is not set.

Returns a Hydra optional (Given(value) or None_()).

hydra.overlay.python.lib.system.get_time() Timespec

Get the current wall-clock time as a Timespec (seconds and nanoseconds since the Unix epoch).

hydra.overlay.python.lib.system.get_working_directory() object

Get the current working directory as a FilePath.

hydra.overlay.python.lib.system.read_stdin() object

Read standard input until end-of-file, returning the complete contents as raw bytes.

hydra.overlay.python.lib.system.write_stderr(data: bytes) object

Write bytes to standard error.

hydra.overlay.python.lib.system.write_stdout(data: bytes) object

Write bytes to standard output.