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:
objectSimplified loader for ToolUniverse Profile 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 viasnapshot_download-https://github.com/user/repo[/tree/branch]: zip downloaded & extracted - Otherhttp(s)://URL: single file downloaded; its parent dir returnedThe result is always a
Pathto an existing directory.
- static get_tool_files_from_dir(dir_path)[source]¶
Scan
dir_pathfor Python tool files and JSON config files.Follows the same layout convention as
_get_user_tool_files(): - Flat:*.py/*.jsondirectly in the directory - Organised:tools/*.pyanddata/*.json/configs/*.jsonprofile.yaml/profile.jsonare excluded (handled separately).__init__.pyis excluded (not a tool file).
- 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.
- tooluniverse.profile.validate_with_schema(yaml_content, fill_defaults_flag=True)[source]¶
Validate YAML content using JSON Schema and optionally fill default values.
- 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.
- 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.
- tooluniverse.profile.validate_yaml_file(file_path)[source]¶
Validate a YAML file by comparing against default template format.
- tooluniverse.profile.fill_defaults(data, schema)[source]¶
Recursively fill default values from JSON schema.
- exception tooluniverse.profile.ValidationError[source]¶
Bases:
ExceptionRaised 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:
objectSimplified loader for ToolUniverse Profile 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 viasnapshot_download-https://github.com/user/repo[/tree/branch]: zip downloaded & extracted - Otherhttp(s)://URL: single file downloaded; its parent dir returnedThe result is always a
Pathto an existing directory.
- static get_tool_files_from_dir(dir_path)[source]¶
Scan
dir_pathfor Python tool files and JSON config files.Follows the same layout convention as
_get_user_tool_files(): - Flat:*.py/*.jsondirectly in the directory - Organised:tools/*.pyanddata/*.json/configs/*.jsonprofile.yaml/profile.jsonare excluded (handled separately).__init__.pyis excluded (not a tool file).
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:
ExceptionRaised 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.
- 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.
- tooluniverse.profile.validator.validate_yaml_file(file_path)[source]¶
Validate a YAML file by comparing against default template format.
- tooluniverse.profile.validator.fill_defaults(data, schema)[source]¶
Recursively fill default values from JSON schema.
- tooluniverse.profile.validator.validate_with_schema(yaml_content, fill_defaults_flag=True)[source]¶
Validate YAML content using JSON Schema and optionally fill default values.