class DataSourceType
An enumeration class that defines the different types of data sources available in the system.
/tf/active/vicechatdev/vice_ai/models.py
1699 - 1704
simple
Purpose
DataSourceType is an Enum class 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, whether through file uploads, SQL queries, SQL workflows, or manual input. This enum is typically used in data processing pipelines, configuration settings, and validation logic to distinguish between different data acquisition methods.
Source Code
class DataSourceType(Enum):
"""Type of data source"""
FILE_UPLOAD = "file_upload"
SQL_QUERY = "sql_query"
SQL_WORKFLOW = "sql_workflow"
MANUAL_INPUT = "manual_input"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Enum | - |
Parameter Details
bases: Inherits from Enum base class, which provides enumeration functionality. No custom __init__ parameters are defined as this is a standard Enum implementation.
Return Value
Instantiation returns a DataSourceType enum member. Each member has a name (e.g., 'FILE_UPLOAD') and a value (e.g., 'file_upload'). 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 |
|---|---|---|---|
FILE_UPLOAD |
DataSourceType | Represents data sourced from a file upload operation. Value: 'file_upload' | class |
SQL_QUERY |
DataSourceType | Represents data sourced from a SQL query execution. Value: 'sql_query' | class |
SQL_WORKFLOW |
DataSourceType | Represents data sourced from a SQL workflow process. Value: 'sql_workflow' | class |
MANUAL_INPUT |
DataSourceType | Represents data that is manually entered by a 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"
print(data_source.name) # "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 members
for source in DataSourceType:
print(f"{source.name}: {source.value}")
# Use in function parameters
def process_data(source_type: DataSourceType):
if source_type == DataSourceType.SQL_QUERY:
return "Processing SQL query"
elif source_type == DataSourceType.FILE_UPLOAD:
return "Processing file upload"
return "Processing other source"
result = process_data(DataSourceType.SQL_QUERY)
Best Practices
- Use enum members directly (e.g., DataSourceType.FILE_UPLOAD) rather than string values for type safety
- Compare enum members using identity (==) or 'is' operator, not by comparing their string values
- Access the string value using the .value property when needed for serialization or storage
- Use type hints (e.g., source_type: DataSourceType) in function signatures for better code documentation
- When deserializing from strings, use DataSourceType(string_value) to convert back to enum member
- Enums are immutable and singleton - each member is instantiated only once
- Do not attempt to modify enum members or add new members at runtime
- Use in match/case statements (Python 3.10+) or if/elif chains for handling different source types
- Consider using enum members in database schemas or API contracts for consistent data source identification
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class DataSourceType_v1 96.3% similar
-
class DataSourceType_v2 96.0% similar
-
class DataSource 72.9% similar
-
class DataSource_v2 68.9% similar
-
class DataSource_v1 66.6% similar