datarobot_genai.drtools.files_api.common_utils
common_utils
Shared helpers for the Files API tool modules.
FilesApiLocalSettings
Bases: DataRobotAppFrameworkBaseSettings
Settings governing local-disk access for the Files API tools.
Resolves from env vars, .env, file secrets, and MLOPS_RUNTIME_PARAM_
runtime parameters by field name (files_api_local_allowed_roots reads
FILES_API_LOCAL_ALLOWED_ROOTS). Defined here, rather than in the drmcp
config, so the drtools layer stays independent of the server package.
Source code in datarobot_genai/drtools/files_api/common_utils.py
ensure_local_path_allowed
Validate local_path against the allowlist and return its resolved real path.
Resolves .. and symlinks before checking so a path cannot escape an
allowed root. Raises :class:ToolError when local access is disabled (no
roots configured) or the path falls outside every allowed root.
Source code in datarobot_genai/drtools/files_api/common_utils.py
get_store
Return the filesystem store. Indirection keeps tools easy to patch in tests.
require_file_path
Validate a path that must reference something under a catalog item, not the root.
Source code in datarobot_genai/drtools/files_api/common_utils.py
resolve_local_sources
async
resolve_local_sources(local_path: str, *, recursive: bool, maxdepth: int | None) -> list[tuple[str, int]]
Expand a local file/dir/glob to a manifest of (path, size) tuples.
Mirrors the expansion the upload backend performs, so callers can validate that something will actually be uploaded and report an accurate file count and byte total. Runs in a worker thread.
Source code in datarobot_genai/drtools/files_api/common_utils.py
decode_content
Decode tool-supplied content to bytes per encoding ('utf-8' or 'base64').