schrodinger.autoinstall.misc module

schrodinger.autoinstall.misc.prepare_dryrun_dump_dir(logger: Logger)

Removes any previous DRY_RUN_DUMP_DIR and creates a fresh empty one so each dry-run starts from a clean slate.

schrodinger.autoinstall.misc.log_dry_run(logger: Logger, message: str)

Logs a dry-run message at the custom DRY-RUN level. Use this for any “Would …” preview line so output is rendered with the dry-run level name (and its own color) instead of plain INFO.

Parameters:
  • logger – A logger instance.

  • message – The message body (without any [DRY-RUN] prefix).

class schrodinger.autoinstall.misc.OperatingSystem

Bases: Enum

An enumeration for supported operating systems.

UBUNTU = 'ubuntu'
ROCKY = 'rocky'
RHEL = 'rhel'
FEDORA = 'fedora'
UNSUPPORTED = 1
classmethod from_string(os_id_str: str)

Determines the OperatingSystem enum member from a distribution ID string.

Parameters:

os_id_str – The distribution ID string (e.g., ‘ubuntu’).

Returns:

The corresponding OperatingSystem enum member.

schrodinger.autoinstall.misc.generate_pw(length=20) str

Generates a random password of a specified length.

Parameters:

length – The desired length of the password.

Returns:

A string containing the generated password.

schrodinger.autoinstall.misc.extract_port(file_path: str) str | None

Extracts the port number from a systemd service file.

It searches for the -port argument in the ExecStart line.

Parameters:

file_path – The path to the systemd service file.

Returns:

The port number as an integer, or None if not found.

schrodinger.autoinstall.misc.check_slm_status(schrod_ipath: str) bool

Runs lictest -v MMLIBS to check if MMLIBS tokens can be checked out.

Parameters:

schrod_ipath – The path to the Schrodinger installation.

Returns:

True if MMLIBS tokens can be checked out, False otherwise.

schrodinger.autoinstall.misc.check_for_queue_execs() str | None

Checks if a known queuing system executable is in the user’s PATH.

Returns:

The name of the detected queueing system (e.g., ‘slurm’), or None if none is found.

schrodinger.autoinstall.misc.format_json_output(dictdata: dict) list

Takes a dictionary, converts it to a formatted JSON string, and cleans it.

Removes brackets, braces, quotation marks, and trailing commas.

Parameters:

dictdata – The dictionary to format.

Returns:

A list of formatted strings.

schrodinger.autoinstall.misc.get_max_cuda_cores(ipath: str) int

Queries for the maximum number of (discounted) CUDA cores available.

Parameters:

ipath – The path to the Schrodinger installation.

Returns:

The maximum number of discounted cores as an integer.

schrodinger.autoinstall.misc.get_host_entries(ipath: str, ncpu: int, ngpu: int, logger: Logger = None) str

Generates content for the hosts.yml file using a Jinja2 template.

Parameters:
  • ipath – The path to the Schrodinger installation.

  • ncpu – The number of CPU cores.

  • ngpu – The number of GPUs.

  • logger – An optional logger instance.

Returns:

The rendered content for the hosts.yml file.

schrodinger.autoinstall.misc.ident_release_by_installsource(installsource: str) str

Identifies the Schrödinger release version from the installer name or URL.

Parameters:

installsource – The installer name or download link.

Returns:

The identified release version string.

schrodinger.autoinstall.misc.ident_release_by_installpath(schrod_path: str) str

Identifies the Schrödinger release version from the version.txt file.

Parameters:

schrod_path – The path to the Schrodinger installation.

Returns:

The identified release version string.

schrodinger.autoinstall.misc.download_from_url(url: str, fpath: str, logger: Logger, read_only: bool = False)

Downloads a file from a URL to a specified local path.

Parameters:
  • url – The URL to download from.

  • fpath – The local file path to save the downloaded content.

  • logger – A logger instance for logging messages.

  • read_only – If True, the download proceeds even when DRY_RUN is enabled. Use this for downloads that the dry-run preview itself depends on (e.g. fetching the package list to compute a diff).

schrodinger.autoinstall.misc.run_shellcmd(command: list, logger: Logger, shellset: bool = False, read_only: bool = False)

Runs a shell command and logs its output in real-time.

If ORIGINAL_LD_LIBRARY_PATH is set, automatically resets LD_LIBRARY_PATH to original value before executing. For running ‘dnf’ package manager commands PYTHONHOME needs to be unset.

Parameters:
  • command – The command to run as a list of arguments.

  • logger – A logger instance for logging command execution and output.

  • shellset – If True, the command is executed through the shell.

  • read_only – If True, the command is executed even when DRY_RUN is enabled. Use this for commands that only query state (e.g. dpkg -l, rpm -qa) and that dry-run previews may depend on.

Returns:

None on success, or the CalledProcessError exception on failure.

schrodinger.autoinstall.misc.write_file(path: str, content: str, logger: Logger, mode: str = 'w')

Writes content to path. When DRY_RUN is set, the real write is skipped; the rendered content is dumped to ./<DRY_RUN_DUMP_DIR>/<basename> and a # write file: <path> comment line is logged at the DRY-RUN level instead.

Parameters:
  • path – The destination file path.

  • content – The content to write.

  • logger – A logger instance for logging messages.

  • mode – File mode passed to open() (default: 'w').

schrodinger.autoinstall.misc.write_json(path: str, data, logger: Logger, indent: int = 4)

Serializes data to path as JSON. When DRY_RUN is set, the real write is skipped; the rendered JSON is dumped to ./<DRY_RUN_DUMP_DIR>/<basename> and a # write file: <path> comment line is logged at the DRY-RUN level instead.

Parameters:
  • path – The destination file path.

  • data – The Python object to serialize.

  • logger – A logger instance for logging messages.

  • indent – Indentation passed to json.dump (default: 4).

schrodinger.autoinstall.misc.write_yaml(path: str, data, logger: Logger, **kwargs)

Serializes data to path as YAML. When DRY_RUN is set, the real write is skipped; the rendered YAML is dumped to ./<DRY_RUN_DUMP_DIR>/<basename> and a # write file: <path> comment line is logged at the DRY-RUN level instead.

Parameters:
  • path – The destination file path.

  • data – The Python object to serialize.

  • logger – A logger instance for logging messages.

  • kwargs – Additional keyword arguments forwarded to yaml.dump.

schrodinger.autoinstall.misc.makedirs(path: str, logger: Logger, exist_ok: bool = True)

Creates path (and any missing parents). When DRY_RUN is set, the operation is skipped and a mkdir -p <path> command is logged at the DRY-RUN level instead.

Parameters:
  • path – The directory to create.

  • logger – A logger instance for logging messages.

  • exist_ok – Forwarded to os.makedirs (default: True).

schrodinger.autoinstall.misc.copy(src: str, dst: str, logger: Logger)

Copies a file from src to dst via shutil.copy. When DRY_RUN is set, the real copy is skipped; src is copied into ./<DRY_RUN_DUMP_DIR>/<basename(dst)> so the rendered file can be inspected, and a cp <src> <dst> command is logged at the DRY-RUN level.

Parameters:
  • src – The source file path.

  • dst – The destination file path.

  • logger – A logger instance for logging messages.

schrodinger.autoinstall.misc.rename(src: str, dst: str, logger: Logger)

Renames src to dst via os.rename. When DRY_RUN is set, the rename is skipped and a mv <src> <dst> command is logged at the DRY-RUN level instead.

Parameters:
  • src – The source path.

  • dst – The destination path.

  • logger – A logger instance for logging messages.

schrodinger.autoinstall.misc.remove(path: str, logger: Logger)

Removes path via os.remove. When DRY_RUN is set, the deletion is skipped and a rm <path> command is logged at the DRY-RUN level instead.

Parameters:
  • path – The file path to remove.

  • logger – A logger instance for logging messages.

schrodinger.autoinstall.misc.chdir(path: str, logger: Logger)

Changes the current working directory to path. When DRY_RUN is set, the change is skipped and a cd <path> command is logged at the DRY-RUN level instead.

Parameters:
  • path – The destination directory.

  • logger – A logger instance for logging messages.

schrodinger.autoinstall.misc.get_logger(stagename: str = None) Logger

Returns a configured logger instance.

  • INFO and higher messages are logged to the console.

  • DEBUG and higher messages are logged to ‘autoinstall.log’.

If a stagename is provided, console logs will be colorized and include the stage name.

Parameters:

stagename – Optional stage name to include in the logs.

Returns:

A configured logger instance.