tdfs4ds.deployment¶
tdfs4ds.deployment
¶
Write a ready-to-run Docker folder for the tdfs4ds gateway.
:func:create_docker_deployment turns the configuration of the running session
(models, embeddings, vector store, MCP, feature store) into a folder holding a
docker-compose.yml, a Dockerfile, a .env, the environments the login
page offers, start scripts and a README. Nothing is started and nothing is sent
to a database.
Rules that shape the code:
- The database credentials of the person who runs it are never written.
People log in on the gateway's page with their own account. A service account
for the
/v1API is written only when asked for, under variable names the environments file points to. - A secret of the session (API key, token, ...) is written only with consent. Without it the line is commented and listed as missing.
- The classification of "is this a secret?" is
config._is_secret, never a second list. - Pure ASCII output; LF line endings except
start.ps1(CRLF).
_DROP_ALWAYS
module-attribute
¶
_DROP_ALWAYS = ('SKILLS_FOLDER', 'INSTALL_AGENT', 'CHROMA_PATH', 'CHROMA_MODE', 'CHROMA_HOST', 'CHROMA_PORT')
_FILE_PATH_SETTINGS
module-attribute
¶
_FILE_PATH_SETTINGS = ('INSTRUCT_MODEL_CA_BUNDLE', 'MCP_SERVER_CA_BUNDLE', 'VECTOR_STORE_AUTH_PEM_FILE')
_LF_FILES
module-attribute
¶
_LF_FILES = ('Dockerfile', 'docker-compose.yml', '.env', '.dockerignore', '.gitignore', 'start.sh', 'README.md', 'state/environments.json', 'config/check_hosts.py')
PAIR_BUILD_ARGS
module-attribute
¶
_PAIR_ARGS
module-attribute
¶
_PAIR_ARGS = "# Optional pin of the teradataml / teradatagenai pair (empty = pip's choice).\nARG TERADATAML_VERSION=\nARG TERADATAGENAI_VERSION=\n"
_PAIR_PIP
module-attribute
¶
_PAIR_PIP = 'PAIR=""; \\\n if [ -n "${TERADATAML_VERSION}" ]; then PAIR="$PAIR teradataml==${TERADATAML_VERSION}"; fi; \\\n if [ -n "${TERADATAGENAI_VERSION}" ]; then PAIR="$PAIR teradatagenai==${TERADATAGENAI_VERSION}"; fi; \\\n HTTP_PROXY="${HTTP_PROXY}" HTTPS_PROXY="${HTTPS_PROXY}" NO_PROXY="${NO_PROXY}" \\\n'
_PAIR_CHECK
module-attribute
¶
_PAIR_CHECK = '# Stops the build when teradataml and teradatagenai do not import together.\nRUN python -m tdfs4ds.utils.teradata_packages --image\n\n'
_COMPOSE_PAIR_ARGS
module-attribute
¶
_COMPOSE_PAIR_ARGS = " # teradataml / teradatagenai pair: empty = pip's choice; set both in .env\n # (TERADATAML_VERSION=..., TERADATAGENAI_VERSION=...) when the build reports\n # that they do not import together, then: docker compose build --no-cache\n TERADATAML_VERSION: ${TERADATAML_VERSION:-}\n TERADATAGENAI_VERSION: ${TERADATAGENAI_VERSION:-}\n"
_CHECK_HOSTS
module-attribute
¶
_CHECK_HOSTS = '"""Can the gateway container reach the databases? Run by start.ps1 -Check / start.sh --check."""\nimport json\nimport os\nimport socket\n\npaths = [os.environ.get("TDFS4DS_SERVE_ENVIRONMENTS", "/config/environments.yaml"),\n os.environ.get("TDFS4DS_SERVE_ENVIRONMENTS_STATE", "/state/environments.json")]\nhosts = {}\nfor path in paths:\n if not os.path.isfile(path):\n continue\n try:\n text = open(path, encoding="utf-8").read()\n if path.endswith((".yaml", ".yml")):\n import yaml\n data = yaml.safe_load(text)\n else:\n data = json.loads(text)\n except Exception as exc:\n print("cannot read %s: %s" % (path, exc))\n continue\n if isinstance(data, dict):\n data = data.get("environments", [])\n for env in data or []:\n if isinstance(env, dict) and env.get("host"):\n hosts[env["host"]] = env.get("label") or env.get("id")\nif not hosts:\n print("no environment found")\nfor host, label in sorted(hosts.items()):\n try:\n socket.create_connection((host, 1025), 5).close()\n print("OK %s (%s) port 1025" % (host, label))\n except Exception as exc:\n print("FAILED %s (%s) port 1025: %s" % (host, label, exc))\n'
_pypi_has_version
¶
True / False when PyPI answers, None when it cannot be reached.
_run_config_check
¶
Failed checks of the running session, as [(label, hint)]. Never raises.
_assistant_warnings
¶
What the deployed assistant will lack, from the session's settings (pure reads).
_compose_config_ok
¶
(True, '') or (False, message) for docker compose config -q in folder.
_render_value
¶
One .env value. A docker compose env_file interpolates $, so quote with ''.
_merge_environments
¶
Concatenate, renaming a repeated id with a numeric suffix only when the host differs.
_session_entries
¶
{ATTR: value} of the running session, from export_config (one classification).
create_docker_deployment
¶
create_docker_deployment(path='tdfs4ds-docker', *, environments=None, remembered=None, include_secrets='ask', source='pypi', version=None, port=8000, chroma='server', prompt=True, check=True, overwrite=False, force=False, wheel=None, min_profile=None)
Write a Docker folder that runs the tdfs4ds gateway. Starts nothing.
Parameters¶
path : str or Path
Folder to create (tdfs4ds-docker).
environments : list of dict, optional
Environments to offer on the login page (id, label, host,
logmechs, encrypt, database, databases_readonly, chroma,
env, api_key_var, service_user_var, service_password_var). The
connection of the running session is added first.
remembered : str or Path, optional
A gateway state/environments.json whose environments are merged in.
include_secrets : {'ask', True, False}
Whether secrets of the session (API keys, tokens) are written to .env.
'ask' asks (and means False without prompt). Without consent a
secret is written as a commented placeholder and listed in missing.
source : {'pypi', 'wheel', 'checkout'}
How the image gets tdfs4ds: the published package, a wheel copied into the
folder, or the source checkout as build context.
version : str, optional
tdfs4ds version (default: the running one).
port : int
Port published on 127.0.0.1.
chroma : {'server', 'local'}
'server' adds a Chroma service; 'local' keeps files in /data.
prompt : bool
Ask questions (notebook or terminal). False = defaults, nothing asked.
check : bool
Check environments, hosts (TCP 1025), the session configuration and
docker compose config before writing.
overwrite : bool
Replace existing files (an existing .env is patched, not replaced).
force : bool
Write even when a check found a problem.
min_profile : {'analyst', 'scientist', 'engineer', 'admin'}, optional
Written as min_profile on every environment without one: everybody who logs on gets at
least this profile (the pages and actions the app offers; their database rights are
unchanged). 'admin' for a personal computer; None keeps the database roles only.
wheel : str or Path, optional
Wheel to use with source='wheel' (default: dist/ of the checkout).
Returns¶
dict
path, files, preview (redacted), missing, warnings, problems, written,
next_steps.
_source_checkout
¶
The source checkout this package runs from (setup.py next to the package), or None.
_write_tree
¶
_write_tree(folder, files, certs, wheel_path, *, existing_env=False, env_updates=None, env_lines=None, consent=False, generated=None, extra_vars=None)
_patch_env
¶
Update an existing .env in place: keep comments and hand-added lines.