tdfs4ds.serve.environments¶
tdfs4ds.serve.environments
¶
Environments of the gateway (0.3.8.2): the Teradata systems a person can log on to.
Two sources, one list:
- the administrator's file (
TDFS4DS_SERVE_ENVIRONMENTS, default/config/environments.yaml, or.json): read-only here, never rewritten; - the remembered environments (
/state/environments.json,TDFS4DS_SERVE_ENVIRONMENTS_STATE): added by a person who typed a "New environment" on the login page and logged on to it successfully. The file holds the label, host, logon mechanism, encryption flag and database; never a user name's password or token.
With neither file, one environment default comes from TDFS4DS_TD_HOST /
_LOGMECH / _ENCRYPT / _DATABASE.
Entry schema of the administrator's file (a list, or {"environments": [...]})::
id slug, required, unique
label shown on the login page (default: id)
host required
logmechs subset of TD2 / LDAP / TDNEGO / JWT (default ["TD2"])
encrypt bool (default true)
database the feature store's database (optional)
databases_readonly list (optional)
chroma "server" | "local" (optional)
env extra settings of the worker: ``TDFS4DS_X`` or ``X``; a registered
variable, never a secret
min_profile analyst | scientist | engineer | admin: everybody who logs on here gets at
least this profile (the roles can still grant a higher one). It decides
which pages and actions the app offers; the database rights of the
person's own login are unchanged
api_key_var NAME of the environment variable holding the bearer key of /v1
service_user_var / service_password_var
NAMES of the variables holding the service account of /v1
DEFAULT_FILES
module-attribute
¶
DEFAULT_FILES = ('/config/environments.yaml', '/config/environments.yml', '/config/environments.json')
_KNOWN_KEYS
module-attribute
¶
_KNOWN_KEYS = {'id', 'label', 'host', 'logmechs', 'encrypt', 'database', 'databases_readonly', 'chroma', 'env', 'min_profile', 'api_key_var', 'service_user_var', 'service_password_var'}
EnvironmentsError
¶
Bases: ValueError
The environments file cannot be used. The message names the file.
Environment
dataclass
¶
logmechs
class-attribute
instance-attribute
¶
databases_readonly
class-attribute
instance-attribute
¶
service_password_var
class-attribute
instance-attribute
¶
__init__
¶
__init__(id: str, host: str, label: str = '', logmechs: List[str] = (lambda: ['TD2'])(), encrypt: bool = True, database: Optional[str] = None, databases_readonly: List[str] = list(), chroma: Optional[str] = None, env: dict = dict(), min_profile: Optional[str] = None, api_key_var: Optional[str] = None, service_user_var: Optional[str] = None, service_password_var: Optional[str] = None, source: str = 'file', added_by: str = '', added_at: str = '', last_used_at: str = '') -> None
EnvironmentRegistry
¶
The administrator's environments plus the remembered ones.
The remembered file is re-read when its modification time changes; a file that cannot
be parsed is moved to <file>.bad, error says so, and the list is empty.
state_path
instance-attribute
¶
list
¶
Administrator's entries first, then the remembered ones (most recently used first); a remembered entry for a target the administrator already offers is hidden.
remember
¶
remember(*, label: str, host: str, logmech: str, encrypt: bool, database: Optional[str], added_by: str) -> Environment
Record an environment a person just logged on to. Returns the environment (the administrator's when it offers the same target, the remembered one otherwise).
forget
¶
Remove a remembered environment. An administrator's entry cannot be forgotten.
validate_environments
¶
Every problem of the file content, all at once (an empty list = usable).
environments_path
¶
The file to read: the argument, else TDFS4DS_SERVE_ENVIRONMENTS, else the first default that exists. An explicit path that does not exist is an error (None only when there is nothing configured and no default exists).
load_environments
¶
The administrator's environments (or the single default one). Raises
:class:EnvironmentsError, naming the file, when the file is unusable.