🔍 Code Extractor

class AnalysisStatus

Maturity: 47

An enumeration class that defines the possible status states for statistical analysis operations.

File:
/tf/active/vicechatdev/vice_ai/models.py
Lines:
1690 - 1697
Complexity:
simple

Purpose

AnalysisStatus is an Enum class that provides a standardized set of status values to track the lifecycle of statistical analysis operations. It defines six distinct states: PENDING (analysis queued but not started), PROCESSING (analysis in progress), DATA_LOADED (data successfully loaded and ready for analysis), COMPLETED (analysis finished successfully), FAILED (analysis encountered an error), and DEBUGGING (analysis in debug mode). This enum ensures type-safe status tracking and prevents invalid status values from being used throughout the application.

Source Code

class AnalysisStatus(Enum):
    """Status of statistical analysis"""
    PENDING = "pending"
    PROCESSING = "processing"
    DATA_LOADED = "data_loaded"
    COMPLETED = "completed"
    FAILED = "failed"
    DEBUGGING = "debugging"

Parameters

Name Type Default Kind
bases Enum -

Parameter Details

bases: Inherits from Enum base class, which provides enumeration functionality. No constructor parameters are needed as this is an Enum class with predefined values.

Return Value

Instantiation returns an AnalysisStatus enum member. Each member has a name (e.g., 'PENDING') and a value (e.g., 'pending'). Accessing members returns the enum instance itself, which can be compared for equality and used in conditional logic.

Class Interface

Attributes

Name Type Description Scope
PENDING AnalysisStatus Represents an analysis that is queued but has not yet started processing. Value: 'pending' class
PROCESSING AnalysisStatus Represents an analysis that is currently being executed. Value: 'processing' class
DATA_LOADED AnalysisStatus Represents an analysis where data has been successfully loaded and is ready for processing. Value: 'data_loaded' class
COMPLETED AnalysisStatus Represents an analysis that has finished successfully. Value: 'completed' class
FAILED AnalysisStatus Represents an analysis that encountered an error and could not complete. Value: 'failed' class
DEBUGGING AnalysisStatus Represents an analysis in debug mode for troubleshooting purposes. Value: 'debugging' class

Dependencies

  • enum

Required Imports

from enum import Enum

Usage Example

from enum import Enum

class AnalysisStatus(Enum):
    PENDING = "pending"
    PROCESSING = "processing"
    DATA_LOADED = "data_loaded"
    COMPLETED = "completed"
    FAILED = "failed"
    DEBUGGING = "debugging"

# Access enum members
status = AnalysisStatus.PENDING
print(status)  # AnalysisStatus.PENDING
print(status.value)  # 'pending'
print(status.name)  # 'PENDING'

# Compare statuses
if status == AnalysisStatus.PENDING:
    print("Analysis is pending")

# Get status from string value
status_from_value = AnalysisStatus("processing")
print(status_from_value)  # AnalysisStatus.PROCESSING

# Iterate over all statuses
for status in AnalysisStatus:
    print(f"{status.name}: {status.value}")

# Use in state machine or workflow
def process_analysis(current_status: AnalysisStatus) -> AnalysisStatus:
    if current_status == AnalysisStatus.PENDING:
        return AnalysisStatus.PROCESSING
    elif current_status == AnalysisStatus.PROCESSING:
        return AnalysisStatus.DATA_LOADED
    elif current_status == AnalysisStatus.DATA_LOADED:
        return AnalysisStatus.COMPLETED
    return current_status

Best Practices

  • Use enum members directly (e.g., AnalysisStatus.PENDING) rather than string values for type safety
  • Compare enum members using identity (==) or 'is' operator for efficiency
  • Access the string value using .value property when needed for serialization or display
  • Use AnalysisStatus(string_value) to convert string values back to enum members
  • Leverage enum members in type hints to enforce valid status values: def set_status(status: AnalysisStatus)
  • Enum members are immutable and singleton - each member is created once and reused
  • Use in match/case statements (Python 3.10+) or if/elif chains for state transitions
  • Consider the logical flow: PENDING -> PROCESSING -> DATA_LOADED -> COMPLETED (or FAILED at any point)
  • DEBUGGING status can be used as a special state for troubleshooting without affecting normal workflow
  • Store enum values (strings) in databases, but convert back to enum members when loading

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class AnalysisStatus_v1 96.9% similar

    An enumeration class that defines the possible status values for statistical analysis operations.

    From: /tf/active/vicechatdev/smartstat/models.py
  • class AnalysisType 70.9% similar

    An enumeration class that defines standardized types of statistical analyses available in the system.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class ContentStatus 67.5% similar

    An enumeration class that defines the possible status values for content generation and editing workflows.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class AnalysisStep 59.9% similar

    A dataclass representing an individual step in an analysis process, tracking execution details, scripts, outputs, and metadata for each step in a data analysis workflow.

    From: /tf/active/vicechatdev/vice_ai/smartstat_models.py
  • class AnalysisStep_v1 59.6% similar

    A dataclass representing an individual step in an analysis process, tracking execution details, scripts, outputs, and errors for a specific analysis operation.

    From: /tf/active/vicechatdev/smartstat/models.py
← Back to Browse