CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-tensorboard

TensorBoard is a suite of web applications for inspecting and understanding your TensorFlow runs and graphs

Overview
Eval results
Files

errors.mddocs/

Error Handling

TensorBoard provides a structured exception hierarchy with HTTP-aware error classes designed for web application error handling. These errors automatically format HTTP responses with appropriate status codes and headers when raised in TensorBoard's web interface.

Capabilities

Base Error Class

Foundation class for all TensorBoard public-facing errors with HTTP response integration.

class PublicError(RuntimeError):
    """
    An error whose text does not contain sensitive information.
    
    Attributes:
        http_code (int): HTTP status code between 400-599 (default 500)
        headers (list): Additional HTTP headers as key-value pairs
    """
    
    http_code = 500
    
    def __init__(self, details):
        """
        Initialize a PublicError.
        
        Args:
            details: Error message details
        """

Invalid Argument Errors

HTTP 400 Bad Request errors for client-provided invalid arguments.

class InvalidArgumentError(PublicError):
    """
    Client specified an invalid argument.
    
    Corresponds to HTTP 400 Bad Request or Google error code INVALID_ARGUMENT.
    """
    
    http_code = 400
    
    def __init__(self, details=None):
        """
        Initialize an InvalidArgumentError.
        
        Args:
            details (str, optional): Public error message details
        """

Not Found Errors

HTTP 404 Not Found errors for missing resources.

class NotFoundError(PublicError):
    """
    Some requested entity (e.g., file or directory) was not found.
    
    Corresponds to HTTP 404 Not Found or Google error code NOT_FOUND.
    """
    
    http_code = 404
    
    def __init__(self, details=None):
        """
        Initialize a NotFoundError.
        
        Args:
            details (str, optional): Public error message details
        """

Authentication Errors

HTTP 401 Unauthorized errors for authentication failures.

class UnauthenticatedError(PublicError):
    """
    Request does not have valid authentication credentials for the operation.
    
    Corresponds to HTTP 401 Unauthorized or Google error code UNAUTHENTICATED.
    Automatically includes required WWW-Authenticate header.
    """
    
    http_code = 401
    
    def __init__(self, details=None, *, challenge):
        """
        Initialize an UnauthenticatedError.
        
        Args:
            details (str, optional): Public error message details
            challenge (str): WWW-Authenticate HTTP header value per RFC 7235
        """

Permission Denied Errors

HTTP 403 Forbidden errors for authorization failures.

class PermissionDeniedError(PublicError):
    """
    The caller does not have permission to execute the specified operation.
    
    Corresponds to HTTP 403 Forbidden or Google error code PERMISSION_DENIED.
    """
    
    http_code = 403
    
    def __init__(self, details=None):
        """
        Initialize a PermissionDeniedError.
        
        Args:
            details (str, optional): Public error message details
        """

Usage Examples

Basic Error Handling

from tensorboard.errors import NotFoundError, InvalidArgumentError

def load_run_data(run_name):
    if not run_name:
        raise InvalidArgumentError("Run name cannot be empty")
    
    if not os.path.exists(f"./logs/{run_name}"):
        raise NotFoundError(f"Run '{run_name}' not found in logs directory")
    
    # Load and return run data
    return load_data(f"./logs/{run_name}")

Authentication Error with Challenge

from tensorboard.errors import UnauthenticatedError

def protected_endpoint(request):
    auth_header = request.headers.get('Authorization')
    if not auth_header or not validate_token(auth_header):
        raise UnauthenticatedError(
            "Valid authentication token required",
            challenge='Bearer realm="TensorBoard"'
        )
    
    # Process authenticated request
    return process_request(request)

HTTP Integration

When these errors are raised in TensorBoard's web interface, they are automatically caught and converted to appropriate HTTP responses:

  • Error message becomes the response body
  • http_code becomes the HTTP status code
  • headers list is added to the HTTP response headers
  • All error text is considered safe for public display

This design enables consistent error handling across TensorBoard's web API while maintaining security by ensuring error messages don't contain sensitive information.

Install with Tessl CLI

npx tessl i tessl/pypi-tensorboard

docs

errors.md

index.md

manager.md

notebook.md

program.md

summary.md

tile.json