Skip to content

tdfs4ds.utils.install_extra

tdfs4ds.utils.install_extra

Install the assistant's packages (tdfs4ds[agent]) from inside Python.

install_agent_extra runs pip with an argument list (never a shell string), prints the exact command first, asks before running it when someone can answer, and never raises. offer_agent_install is the one decision shared by launch_app, configure_interactively and generate_ai_studio_env: install only when the configuration says the assistant is wanted and its packages are missing.

AGENT_ALL_MODULES module-attribute

AGENT_ALL_MODULES = AGENT_MODULES + ('langchain_openai', 'chromadb', 'gradio')

logger module-attribute

logger = logging.getLogger('tdfs4ds')

_RESTART_NOTE module-attribute

_RESTART_NOTE = 'A kernel that is already running may need a restart to import the agent in the notebook itself; the app (a separate process) sees the packages at once.'

agent_wanted

agent_wanted(config=None)

Does the configuration say the assistant is wanted? -> (bool, [names]).

config is a dict of resolved settings ({"INSTRUCT_MODEL_MODEL": "x", ...}; a TDFS4DS_ prefix is accepted). Pure: nothing is read when it is given. Without it, the environment (TDFS4DS_*) and the model / MCP / tracing attributes of the module are read (the module's own defaults, which are never a choice, are not). The names returned are the variables that say so (TDFS4DS_...), never values.

install_hint

install_hint(extra='agent')

missing_modules

missing_modules(modules=AGENT_MODULES)

_say

_say(text='')

_source_install

_source_install()

True when tdfs4ds was not installed from an index: an editable / source checkout, or a local path or wheel (direct_url.json). Then tdfs4ds[agent]==<version> would ask the index for a build that may not exist, or replace the user's checkout.

agent_requirements

agent_requirements()

The requirement strings of the agent extra, from the installed metadata ([] when unreadable).

_writable

_writable()

_in_virtualenv

_in_virtualenv()

build_commands

build_commands(*, version=None, user=None, index_url=None)

The pip commands to try, in order: [(label, argv), ...]. Pure apart from reading the install metadata.

_run

_run(argv)

Run pip and stream its output; returns the exit code. Replaced in tests.

_quote

_quote(argv)

install_agent_extra

install_agent_extra(*, version=None, user=None, index_url=None, dry_run=False, prompt=True)

Install the packages of the assistant (tdfs4ds[agent]).

Runs <python> -m pip install tdfs4ds[agent]==<this version>. When tdfs4ds is an editable / source / local-wheel install, or when that pinned install fails (this version is not on the index), the requirements of the extra are installed instead, so the running tdfs4ds is never replaced. --user is added when the environment is not writable (a read-only conda, for example).

Parameters

version : str, optional Pin another tdfs4ds version (default: the running one). user : bool, optional --user; default: automatic. index_url : str, optional An alternative package index. dry_run : bool Print the command, run nothing. prompt : bool True (default): print the command and ask before running it; with nobody to ask, nothing is installed and the hint is logged. False: install without asking.

Returns

dict ok, command (the one that ran, or would), returncode, missing_after, skipped (why nothing ran), fallback (True when the requirement list was used). Never raises.

install_mode

install_mode(install_agent=None)

'ask' | 'yes' | 'no': the call argument wins, then TDFS4DS_INSTALL_AGENT.

offer_agent_install

offer_agent_install(config=None, *, install_agent=None, interactive=None)

Offer the install when the configuration wants the assistant and its packages are missing.

Returns None when nothing applies (not wanted, installed, or switched off), else the :func:install_agent_extra report (skipped says why nothing ran). Never raises.

settings_of

settings_of(path=None)

{NAME: value} (no prefix) of the TDFS4DS_* environment overlaid by the .env at path (what a process started with that file would read). Values are never shown.