Treasury Analytics Core
  • Home
  • API Reference
  • Examples
  • Credentials
  • Global Settings
  1. API Reference
  2. Configuration
  3. settings_factory
  • Overview
    • Treasury Analytics Core
  • Credential Management
    • Secure Credential Management
    • Global Settings
  • Examples
    • Example Projects
  • API Reference
    • Function reference
    • Core Components
      • FinanceDataEngine
      • engine_factory
      • engine
      • database
      • cache
      • processor
      • analyzer
    • Configuration
      • settings
      • settings_factory
      • global_settings_manager
    • Utilities
      • credentials
      • dataframe_utils
      • setup_logging
      • env_checker
      • query_timer
      • setup_helper
      • logging
      • constants
      • types
    • Scripts
      • configure_db
      • create_project
      • manage_settings

On this page

  • settings_factory
    • Classes
      • SettingsFactory

Other Formats

  • Github (GFM)
  1. API Reference
  2. Configuration
  3. settings_factory

settings_factory

config.settings_factory

Factory for creating Settings instances with different credential sources.

Classes

Name Description
SettingsFactory Factory for creating Settings instances with different credential sources.

SettingsFactory

config.settings_factory.SettingsFactory()

Factory for creating Settings instances with different credential sources.

This factory provides methods to create Settings instances from different credential sources, including environment variables, credential files, and secure credential stores.

Methods

Name Description
create_settings_with_env_credentials Create settings using credentials from environment variables and provided username/password.
from_credential_path Create settings from a credential directory.
from_env Create settings from an environment file.
from_global_settings Create settings from global settings file.
from_global_settings_with_credentials Create settings by combining global settings with credentials.
from_keyring Create settings using credentials from system keyring.
load_global_settings_to_env Load global settings from YAML and set as environment variables.
create_settings_with_env_credentials
config.settings_factory.SettingsFactory.create_settings_with_env_credentials(
    project_root=None,
    sql_dir=None,
    cache_dir=None,
    output_dir=None,
    data_dir=None,
    batch_size=10000,
    username=None,
    password=None,
    **kwargs,
)

Create settings using credentials from environment variables and provided username/password.

This method is designed to be used when environment credentials have already been set up, typically by CredentialManager.ensure_credentials_in_environment().

Parameters
Name Type Description Default
project_root Optional[Path] Project root path None
sql_dir Optional[Path] SQL directory path None
cache_dir Optional[Path] Cache directory path None
output_dir Optional[Path] Output directory path None
data_dir Optional[Path] Data directory path None
batch_size int Batch size for processing, by default 10000 10000
username Optional[str] Database username, overrides environment variable None
password Optional[str] Database password, overrides environment variable None
Returns
Name Type Description
Settings Settings instance with credentials from environment variables and provided credentials
from_credential_path
config.settings_factory.SettingsFactory.from_credential_path(
    cred_path,
    **kwargs,
)

Create settings from a credential directory.

Parameters
Name Type Description Default
cred_path str Path to directory containing credentials file required
Returns
Name Type Description
Settings Settings instance with values from credential file
from_env
config.settings_factory.SettingsFactory.from_env(env_file='.env', **kwargs)

Create settings from an environment file.

Parameters
Name Type Description Default
env_file str Path to environment file. Defaults to โ€œ.envโ€ in the current directory. Environment variables take precedence over values in this file. '.env'
Returns
Name Type Description
Settings Settings instance with values from environment file and environment variables
from_global_settings
config.settings_factory.SettingsFactory.from_global_settings(
    custom_path=None,
    **kwargs,
)

Create settings from global settings file.

This method loads settings from the global settings file located in the userโ€™s home directory (~/.nova_fde/settings.yaml).

Parameters
Name Type Description Default
custom_path Optional[Path] Custom path to the global settings file. If None, the default location (~/.nova_fde/settings.yaml) is used. None
**kwargs Additional settings to override values from the global settings. {}
Returns
Name Type Description
Settings Settings instance with values from global settings file
from_global_settings_with_credentials
config.settings_factory.SettingsFactory.from_global_settings_with_credentials(
    username=None,
    password=None,
    project_root=None,
    custom_path=None,
    console=None,
    **kwargs,
)

Create settings by combining global settings with credentials.

Parameters
Name Type Description Default
username Optional[str] Database username None
password Optional[str] Database password None
project_root Optional[Union[str, Path]] Project root path None
custom_path Optional[Path] Custom path to the global settings file None
console Optional Console for displaying messages None
Returns
Name Type Description
Settings Settings instance with database configuration from global settings and credentials from parameters
from_keyring
config.settings_factory.SettingsFactory.from_keyring(
    service_name='nova_fde',
    username=None,
    **kwargs,
)

Create settings using credentials from system keyring.

Parameters
Name Type Description Default
service_name str Service name for keyring 'nova_fde'
username Optional[str] Username to look up in keyring None
Returns
Name Type Description
Settings Settings instance with credentials from keyring
load_global_settings_to_env
config.settings_factory.SettingsFactory.load_global_settings_to_env(
    custom_path=None,
)

Load global settings from YAML and set as environment variables.

This method loads the global settings file and sets database configuration values as environment variables for use with other methods that rely on environment variables.

Parameters
Name Type Description Default
custom_path Optional[Path] Custom path to the global settings file. If None, the default location (~/.nova_fde/settings.yaml) is used. None
Returns
Name Type Description
Dict[str, str] Dictionary of environment variables that were set
settings
global_settings_manager
 
 
  • Built with [Quarto](https://quarto.org/) and [quartodoc](https://machow.github.io/quartodoc/)