Configuration Module

The pyremotedata.config module provides configuration loading and access for PyRemoteData. Most users only need a small subset of the API.

What most users need

Public API

pyremotedata.config.get_config(validate: bool = True) dict | None[source]

Load configuration from disk, optionally validating against environment.

When validate is True, the loaded configuration is compared against the current environment variables. If a mismatch is found, the config file is removed and recreated from scratch to prevent stale settings.

Parameters:
validate: bool = True

Whether to validate against environment.

Returns:

The loaded configuration dictionary, or None if parsing fails.

pyremotedata.config.get_implicit_mount_config(**kwargs)[source]
pyremotedata.config.remove_config() None[source]

Delete the stored configuration file, if present.

Typical usage

Environment-first (non-interactive) setup:

import os
from pyremotedata.config import get_config

os.environ["PYREMOTEDATA_REMOTE_USERNAME"] = "username"
os.environ["PYREMOTEDATA_REMOTE_URI"] = "io.erda.au.dk"
os.environ["PYREMOTEDATA_LOCAL_DIRECTORY"] = "/tmp/pyremotedata"
os.environ["PYREMOTEDATA_REMOTE_DIRECTORY"] = "/project/data"
os.environ["PYREMOTEDATA_AUTO"] = "yes"  # disable prompts

cfg = get_config(validate=True)
print(cfg["implicit_mount"])  # dict with keys: user, remote, local_dir, default_remote_dir, lftp

Access the implicit mount configuration directly:

from pyremotedata.config import get_implicit_mount_config

implicit_cfg = get_implicit_mount_config(validate=True)
print(implicit_cfg["user"], implicit_cfg["remote"])  # username and server

Regenerate configuration (cleanup):

from pyremotedata.config import remove_config
remove_config()  # deletes the stored YAML; it will be recreated on next get_config()

Environment variables

The module recognizes these environment variables:

  • PYREMOTEDATA_REMOTE_USERNAME

  • PYREMOTEDATA_REMOTE_URI

  • PYREMOTEDATA_LOCAL_DIRECTORY

  • PYREMOTEDATA_REMOTE_DIRECTORY

  • PYREMOTEDATA_AUTO (set to “yes” to disable interactive prompts)

Advanced (optional)

These functions are primarily for advanced or programmatic setups and are not required for typical usage:

pyremotedata.config.create_default_config(interactive: bool = True) None[source]

Create a default YAML configuration file.

Values are sourced from the environment or prompted interactively depending on the interactive flag.

Parameters:
interactive: bool = True

Whether to prompt for missing values.

Notes

  • When validate=True, get_config compares the active environment to the stored config. If they differ, the config is removed and recreated to prevent stale settings.

  • The configuration file is stored next to the package installation by default.