tooluniverse.profile package

ToolUniverse Profile Configuration Management

This module provides tools for loading, validating, and managing ToolUniverse Profile configurations. Profile allows users to define collections of tools with specific configurations, LLM settings, and hooks for advanced scientific workflows.

Main Components: - ProfileLoader: Loads Profile configurations from various sources (HuggingFace, local files, URLs) - ProfileValidator: Validates Profile configurations using JSON Schema - ValidationError: Exception raised when configuration validation fails

Usage:

from tooluniverse.profile import ProfileLoader, validate_profile_config

# Load a Profile configuration loader = ProfileLoader() config = loader.load(“hf:user/repo”)

# Validate a configuration is_valid, errors = validate_profile_config(config)

class tooluniverse.profile.ProfileLoader[source]

Bases: object

Simplified loader for ToolUniverse Profile configurations.

__init__(cache_dir=None)[source]

Initialize the Profile loader.

Parameters:

cache_dir (str | Path | None) – Directory for caching downloaded configurations

load(uri)[source]

Load Profile configuration from URI.

Parameters:

uri (str) – Profile URI (e.g., “hf:user/repo”, “./config.yaml”, “https://example.com/config.yaml”)

Returns

Loaded configuration dictionary

Raises:

ValueError – If URI is unsupported or configuration is invalid

resolve_to_local_dir(uri)[source]

Resolve any URI to a local directory that contains Profile tool files.

Supported URI forms: - Local path (file or directory): returned as a Path (file → parent) - hf:user/repo: full repo downloaded via snapshot_download - https://github.com/user/repo[/tree/branch]: zip downloaded & extracted - Other http(s):// URL: single file downloaded; its parent dir returned

The result is always a Path to an existing directory.

static get_tool_files_from_dir(dir_path)[source]

Scan dir_path for Python tool files and JSON config files.

Follows the same layout convention as _get_user_tool_files(): - Flat: *.py / *.json directly in the directory - Organised: tools/*.py and data/*.json / configs/*.json

profile.yaml / profile.json are excluded (handled separately). __init__.py is excluded (not a tool file).

Returns:

(python_files, json_files) — both are lists of Path objects.

Return type:

Tuple[List[Path], List[Path]]

tooluniverse.profile.validate_profile_config(config)[source]

Validate a Profile configuration using JSON Schema.

This is a legacy function that now uses the JSON Schema validation system. For new code, use validate_with_schema() instead.

Parameters:

config (Dict[str, Any]) – Configuration dictionary

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.validate_with_schema(yaml_content, fill_defaults_flag=True)[source]

Validate YAML content using JSON Schema and optionally fill default values.

Parameters:
  • yaml_content (str) – YAML content string

  • fill_defaults_flag (bool) – Whether to fill default values

Returns:

Tuple of (is_valid, list_of_errors, processed_config)

Return type:

Tuple[bool, List[str], Dict[str, Any]]

tooluniverse.profile.validate_yaml_file_with_schema(file_path, fill_defaults_flag=True)[source]

Validate a YAML file using JSON Schema and optionally fill default values.

Parameters:
  • file_path (str) – Path to YAML file

  • fill_defaults_flag (bool) – Whether to fill default values

Returns:

Tuple of (is_valid, list_of_errors, processed_config)

Return type:

Tuple[bool, List[str], Dict[str, Any]]

tooluniverse.profile.validate_yaml_format_by_template(yaml_content)[source]

Validate YAML format by comparing against default template format.

This method uses the JSON Schema as a reference to validate the structure and content of Profile YAML configurations.

Parameters:

yaml_content (str) – YAML content string

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.validate_yaml_file(file_path)[source]

Validate a YAML file by comparing against default template format.

Parameters:

file_path (str) – Path to YAML file

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.fill_defaults(data, schema)[source]

Recursively fill default values from JSON schema.

Parameters:
  • data (Dict[str, Any]) – Configuration data

  • schema (Dict[str, Any]) – JSON schema with default values

Returns:

Configuration with default values filled

Return type:

Dict[str, Any]

exception tooluniverse.profile.ValidationError[source]

Bases: Exception

Raised when configuration validation fails.

Submodules

tooluniverse.profile.loader module

ToolUniverse Profile Configuration Loader

Simplified loader supporting HuggingFace, local files, and HTTP/HTTPS.

class tooluniverse.profile.loader.ProfileLoader[source]

Bases: object

Simplified loader for ToolUniverse Profile configurations.

__init__(cache_dir=None)[source]

Initialize the Profile loader.

Parameters:

cache_dir (str | Path | None) – Directory for caching downloaded configurations

load(uri)[source]

Load Profile configuration from URI.

Parameters:

uri (str) – Profile URI (e.g., “hf:user/repo”, “./config.yaml”, “https://example.com/config.yaml”)

Returns

Loaded configuration dictionary

Raises:

ValueError – If URI is unsupported or configuration is invalid

resolve_to_local_dir(uri)[source]

Resolve any URI to a local directory that contains Profile tool files.

Supported URI forms: - Local path (file or directory): returned as a Path (file → parent) - hf:user/repo: full repo downloaded via snapshot_download - https://github.com/user/repo[/tree/branch]: zip downloaded & extracted - Other http(s):// URL: single file downloaded; its parent dir returned

The result is always a Path to an existing directory.

static get_tool_files_from_dir(dir_path)[source]

Scan dir_path for Python tool files and JSON config files.

Follows the same layout convention as _get_user_tool_files(): - Flat: *.py / *.json directly in the directory - Organised: tools/*.py and data/*.json / configs/*.json

profile.yaml / profile.json are excluded (handled separately). __init__.py is excluded (not a tool file).

Returns:

(python_files, json_files) — both are lists of Path objects.

Return type:

Tuple[List[Path], List[Path]]

tooluniverse.profile.validator module

Profile Configuration Validator

Comprehensive validation for Profile configurations using JSON Schema. Supports validation, default value filling, and structure checking for Profile YAML files.

The validation system is based on a comprehensive JSON Schema that defines: - All possible fields and their types - Default values for optional fields - Required fields and validation rules - Enum values for specific fields - Nested object structures and arrays

This provides a robust, flexible, and maintainable validation system that can: 1. Validate YAML structure and content 2. Fill in missing default values automatically 3. Provide detailed error messages for validation failures 4. Support both simple tool collections and complex workspaces

exception tooluniverse.profile.validator.ValidationError[source]

Bases: Exception

Raised when configuration validation fails.

tooluniverse.profile.validator.validate_profile_config(config)[source]

Validate a Profile configuration using JSON Schema.

This is a legacy function that now uses the JSON Schema validation system. For new code, use validate_with_schema() instead.

Parameters:

config (Dict[str, Any]) – Configuration dictionary

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.validator.validate_yaml_format_by_template(yaml_content)[source]

Validate YAML format by comparing against default template format.

This method uses the JSON Schema as a reference to validate the structure and content of Profile YAML configurations.

Parameters:

yaml_content (str) – YAML content string

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.validator.validate_yaml_file(file_path)[source]

Validate a YAML file by comparing against default template format.

Parameters:

file_path (str) – Path to YAML file

Returns:

Tuple of (is_valid, list_of_errors)

Return type:

Tuple[bool, List[str]]

tooluniverse.profile.validator.fill_defaults(data, schema)[source]

Recursively fill default values from JSON schema.

Parameters:
  • data (Dict[str, Any]) – Configuration data

  • schema (Dict[str, Any]) – JSON schema with default values

Returns:

Configuration with default values filled

Return type:

Dict[str, Any]

tooluniverse.profile.validator.validate_with_schema(yaml_content, fill_defaults_flag=True)[source]

Validate YAML content using JSON Schema and optionally fill default values.

Parameters:
  • yaml_content (str) – YAML content string

  • fill_defaults_flag (bool) – Whether to fill default values

Returns:

Tuple of (is_valid, list_of_errors, processed_config)

Return type:

Tuple[bool, List[str], Dict[str, Any]]

tooluniverse.profile.validator.validate_yaml_file_with_schema(file_path, fill_defaults_flag=True)[source]

Validate a YAML file using JSON Schema and optionally fill default values.

Parameters:
  • file_path (str) – Path to YAML file

  • fill_defaults_flag (bool) – Whether to fill default values

Returns:

Tuple of (is_valid, list_of_errors, processed_config)

Return type:

Tuple[bool, List[str], Dict[str, Any]]