Client
The main entry point for interacting with the ViewAI platform. The ViewAIClient class provides a unified interface to all ViewAI services following the Facade pattern.
Overview
The ViewAIClient class is the primary interface for all ViewAI SDK operations. It provides:
Service-Oriented Architecture: Access to specialized services for different operations
Convenience Methods: Simplified access to common operations
Context Management: Support for Python's
withstatementLazy Loading: Services are initialized only when accessed
Configuration Management: Flexible configuration with validation
Class Reference
class ViewAIClient:
"""Enterprise-grade ViewAI SDK client with service-oriented architecture."""Initialization
init(api_key, config, **kwargs)
Initialize the ViewAI client with authentication and configuration.
Parameters:
api_key(str, optional): API authentication key. Required ifconfignot provided.config(ClientConfiguration, optional): Configuration object with full settings.**kwargs: Additional configuration options used ifconfignot provided.base_url(str): API base URLtimeout(int): Request timeout in secondsmax_retries(int): Maximum retry attemptsdefault_workspace(str): Default workspace namedefault_project(str): Default project namedefault_model_id(str): Default model ID
Raises:
ValueError: If neitherapi_keynorconfigis provided
Examples:
Service Properties
These properties provide access to specialized services. Services are lazy-loaded on first access.
workspace_manager
Access workspace management service.
Returns: WorkspaceManager instance
Example:
See Also: WorkspaceManager
project_manager
Access project management service.
Returns: ProjectManager instance
Example:
See Also: ProjectManager
prediction_service
Access prediction/inference service.
Returns: PredictionService instance
Example:
See Also: PredictionService
training_service
Access model training service.
Returns: ModelTrainingService instance
Example:
See Also: ModelTrainingService
health
Access health monitoring service.
Returns: HealthChecker instance
Example:
See Also: HealthChecker
registry
Access model registry service.
Returns: ModelRegistry instance
Example:
See Also: ModelRegistry
version
Access version checking service.
Returns: VersionChecker instance
Example:
schema_validator
Access schema validation service.
Returns: SchemaValidator instance
Example:
Convenience Methods - Workspace
retrieve_default_workspace()
Retrieve the default workspace for the authenticated user.
Returns: Workspace or None
Example:
retrieve_workspace_by_name(workspace_name)
Retrieve workspace by name.
Parameters:
workspace_name(str): Name of workspace to retrieve
Returns: Workspace or None
Example:
list_accessible_workspaces()
List all accessible workspaces.
Returns: List[Workspace]
Example:
Convenience Methods - Project
retrieve_project_by_name(project_name)
Retrieve project by name.
Parameters:
project_name(str): Name of project to retrieve
Returns: Project or None
Example:
list_accessible_projects(workspace_id=None)
List all accessible projects, optionally filtered by workspace.
Parameters:
workspace_id(str, optional): Workspace ID to filter projects
Returns: List[Project]
Example:
Convenience Methods - Prediction
execute_prediction(data, model_id=None)
Execute prediction (automatically routes to single or batch based on data type).
Parameters:
data(dict or list): Data to predict (dict for single, list for batch)model_id(str, optional): Model ID to use. Uses default if not provided.
Returns: Prediction (for single) or BatchPredictionJob (for batch) or None
Raises:
ValueError: If model_id not provided and no default set
Examples:
execute_single_point_prediction(data, model_id=None)
Execute prediction for a single data point.
Parameters:
data(dict): Single data point as dictionarymodel_id(str, optional): Model ID to use
Returns: Prediction or None
Example:
execute_batch_prediction(data, model_id=None, wait_for_completion=True)
Execute prediction for multiple data points (batch).
Parameters:
data(list or DataFrame): List of data points or DataFramemodel_id(str, optional): Model ID to usewait_for_completion(bool): Whether to wait for job completion
Returns: BatchPredictionJob or None
Example:
Convenience Methods - Training
initiate_training_job(...)
Initiate a model training job.
Parameters:
dataset(DataFrame): Training data DataFrametarget_column(str): Name of target columnworkspace(Workspace or str, optional): Workspace object/IDproject(Project or str, optional): Optional project object/IDmodel_name(str): Name for the model (default: "Default Model")description(str): Model description (default: "No description provided")wait_for_completion(bool): Whether to wait for training completion (default: True)
Returns: TrainingJob or None
Raises:
ValueError: If workspace not provided and no default set
Example:
Model Deployment
create_deployable_model(...)
Create a deployable model object from a trained model.
Parameters:
model(Any): Trained model object (sklearn, xgboost, etc.)dataset(DataFrame): Training datasettarget_column(str): Target column nameschema(dict, optional): Optional schema definitionmodel_name(str): Name for deployed model (default: "Deployed Model")workspace(Workspace or str, optional): Workspace object/IDproject(Project or str, optional): Optional project object/ID
Returns: Model object ready for deployment
Raises:
ValueError: If workspace not provided and no default set
Example:
See Also: Model Class
Configuration & Info
configure_logging_level(level)
Configure logging level for the SDK.
Parameters:
level(int): Logging level (e.g., logging.DEBUG, logging.INFO)
Example:
retrieve_client_configuration()
Retrieve current client configuration.
Returns: Dictionary with configuration details
Example:
retrieve_version_information()
Retrieve SDK and server version information.
Returns: Dictionary with version details
Example:
Health & Diagnostics
execute_comprehensive_diagnostics()
Execute comprehensive health diagnostics.
Returns: Dictionary with diagnostic results
Example:
verify_api_connectivity()
Verify API connectivity.
Returns: Dictionary with connection status
Example:
Context Management
set_current_workspace(workspace)
Set current workspace context.
Parameters:
workspace(Workspace or str): Workspace object or name
Example:
set_current_project(project)
Set current project context.
Parameters:
project(Project or str): Project object or name
Example:
Resource Cleanup
cleanup_resources()
Cleanup all resources held by the client.
Example:
Note: Automatically called when using context manager.
Context Manager Support
The ViewAIClient supports Python's context manager protocol for automatic resource cleanup.
Example:
Complete Usage Example
See Also
Service Classes - Detailed service class documentation
Model Classes - Model deployment and prediction classes
Configuration - Configuration options and validation
Exceptions - Exception handling
Was this helpful?