Quickstart¶
This quickstart walks through the main pkg_infra workflow: initialize a
session, inspect the merged configuration, and retrieve integration-specific
settings.
1. Import the package¶
from pathlib import Path
from pkg_infra import get_session
2. Create the session¶
session = get_session(
workspace=Path("."),
include_location=False,
)
get_session(...) returns a process-wide singleton. On the first call it will:
- Load the merged configuration
- Validate the configuration schema
- Configure logging
- Capture runtime metadata for the current process
Subsequent calls reuse the same session object.
3. Inspect runtime metadata¶
print(session.hostname)
print(session.username)
print(session.workspace)
print(session.started_at_utc)
If location lookup is enabled, session.location is resolved lazily on first
access.
4. Inspect the merged configuration¶
config_dict = session.get_config_dict()
print(config_dict["app"])
If the underlying config is still represented as OmegaConf, you can also render it as YAML:
print(session.get_config_yaml())
5. Read settings for a downstream package¶
Integration-specific settings live under the integrations section of the
merged configuration.
corneto_settings = session.get_conf("corneto")
print(corneto_settings)
If the named package is unknown or has no settings section, get_conf(...)
returns an empty dictionary.
6. Understand configuration precedence¶
pkg_infra merges configuration sources in this order:
- Ecosystem defaults
- Packaged default settings
- User-level config
- Working-directory config
- Config path from the
PKG_INFRA_CONFIGenvironment variable - Explicit custom config path passed to
get_session(...)
Later sources override earlier ones.
7. Next steps¶
- Read the Core Concepts explanation for the main ideas
- Explore the Explanations section for config and logging behavior
- Use the Reference section for API details