🔍 Code Extractor

class DataSourceType_v1

Maturity: 41

An enumeration class that defines the different types of data sources available in the system.

File:
/tf/active/vicechatdev/vice_ai/smartstat_models.py
Lines:
28 - 33
Complexity:
simple

Purpose

DataSourceType is an Enum that provides a standardized set of constants representing different methods of data input/sourcing. It ensures type safety and consistency when specifying how data is being provided to the system. The enum includes file uploads, direct SQL queries, LLM-assisted SQL workflow (where user queries are converted to SQL), and manual data entry.

Source Code

class DataSourceType(Enum):
    """Type of data source"""
    FILE_UPLOAD = "file_upload"
    SQL_QUERY = "sql_query"
    SQL_WORKFLOW = "sql_workflow"  # New: User query -> LLM generates SQL -> Execute
    MANUAL_INPUT = "manual_input"

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 a DataSourceType enum member. Each member has a string value associated with it (e.g., 'file_upload', 'sql_query'). Accessing a member returns the enum instance, and accessing its .value property returns the associated string.

Class Interface

Attributes

Name Type Description Scope
FILE_UPLOAD DataSourceType Represents data sourced from a file upload operation. Value: 'file_upload' class
SQL_QUERY DataSourceType Represents data sourced from a direct SQL query execution. Value: 'sql_query' class
SQL_WORKFLOW DataSourceType Represents data sourced through an LLM-assisted workflow where user queries are converted to SQL and then executed. Value: 'sql_workflow' class
MANUAL_INPUT DataSourceType Represents data that is manually entered by the user. Value: 'manual_input' class

Dependencies

  • enum

Required Imports

from enum import Enum

Usage Example

from enum import Enum

class DataSourceType(Enum):
    FILE_UPLOAD = "file_upload"
    SQL_QUERY = "sql_query"
    SQL_WORKFLOW = "sql_workflow"
    MANUAL_INPUT = "manual_input"

# Access enum members
data_source = DataSourceType.FILE_UPLOAD
print(data_source)  # DataSourceType.FILE_UPLOAD
print(data_source.value)  # 'file_upload'

# Compare enum members
if data_source == DataSourceType.FILE_UPLOAD:
    print("Data is from file upload")

# Get enum by value
source_type = DataSourceType("sql_query")
print(source_type)  # DataSourceType.SQL_QUERY

# Iterate over all types
for source in DataSourceType:
    print(f"{source.name}: {source.value}")

Best Practices

  • Use DataSourceType members for type checking and comparison rather than raw strings to ensure type safety
  • Access the string value using the .value property when needed for serialization or storage
  • Use the .name property to get the member name as a string (e.g., 'FILE_UPLOAD')
  • Enum members are singletons and should be compared using == or 'is' operators
  • When deserializing, use DataSourceType(value_string) to convert string values back to enum members
  • Do not instantiate DataSourceType directly; use the predefined class attributes
  • SQL_WORKFLOW represents an LLM-assisted workflow where natural language queries are converted to SQL before execution

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class DataSourceType_v2 97.8% similar

    An enumeration class that defines the different types of data sources available in the system.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class DataSourceType 96.3% similar

    An enumeration class that defines the different types of data sources available in the system.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class DataSource_v2 72.8% similar

    A dataclass that encapsulates configuration for various data sources including files, SQL databases, and SQL workflow metadata.

    From: /tf/active/vicechatdev/vice_ai/smartstat_models.py
  • class DataSource 72.2% similar

    A dataclass that represents configuration for various data sources, supporting file-based, SQL database, and query-based data access patterns.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class DataSource_v1 71.2% similar

    A dataclass that encapsulates configuration for various data sources used in analysis, supporting file-based, SQL database, and query-based data sources.

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