class DataSourceType_v2
An enumeration class that defines the different types of data sources available in the system.
/tf/active/vicechatdev/vice_ai/models.py
1889 - 1894
simple
Purpose
DataSourceType is an Enum class that provides a standardized set of constants representing different methods of data ingestion. It ensures type safety and consistency when specifying how data is being sourced in the application. The four types cover file-based uploads, direct SQL queries, AI-assisted SQL workflow generation, 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" # 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 members.
Return Value
Instantiation returns an Enum member. Each member has a name (e.g., 'FILE_UPLOAD') and a value (e.g., 'file_upload'). Accessing members returns the specific DataSourceType enum instance.
Class Interface
Methods
Inherited from Enum, not directly called
Purpose: Enum members are created at class definition time, not through explicit instantiation
Returns: N/A - Enum members are accessed as class attributes
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
FILE_UPLOAD |
DataSourceType | Represents data sourced from file uploads. Value: 'file_upload' | class |
SQL_QUERY |
DataSourceType | Represents data sourced from direct SQL query execution. Value: 'sql_query' | class |
SQL_WORKFLOW |
DataSourceType | Represents data sourced through an AI-assisted workflow where user queries are converted to SQL by an LLM and then executed. Value: 'sql_workflow' | class |
MANUAL_INPUT |
DataSourceType | Represents data that is manually entered by users. Value: 'manual_input' | class |
name |
str | Inherited property from Enum that returns the member name (e.g., 'FILE_UPLOAD') | instance |
value |
str | Inherited property from Enum that returns the member value (e.g., 'file_upload') | instance |
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.name) # Output: 'FILE_UPLOAD'
print(data_source.value) # Output: '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) # Output: DataSourceType.SQL_QUERY
# Iterate over all members
for source in DataSourceType:
print(f"{source.name}: {source.value}")
Best Practices
- Use enum members directly (e.g., DataSourceType.FILE_UPLOAD) rather than string values for type safety
- When storing in databases or JSON, use the .value property to get the string representation
- When deserializing, use DataSourceType(string_value) to convert back to enum member
- Do not modify enum members at runtime as they are immutable
- Use identity comparison (is) or equality comparison (==) when checking enum values
- Enums are singletons - the same member instance is returned each time it's accessed
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class DataSourceType_v1 97.8% similar
-
class DataSourceType 96.0% similar
-
class DataSource 72.6% similar
-
class DataSource_v2 70.2% similar
-
class DataSource_v1 69.8% similar