Skip to content

Commit

Permalink
chore: use singular style in config class name (#5489)
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 authored Jun 22, 2024
1 parent 9a5c423 commit 8890978
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 82 deletions.
4 changes: 2 additions & 2 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from configs.app_configs import DifyConfigs
from configs.app_config import DifyConfig

if not os.environ.get("DEBUG") or os.environ.get("DEBUG", "false").lower() != 'true':
from gevent import monkey
Expand Down Expand Up @@ -83,7 +83,7 @@ def create_flask_app_with_configs() -> Flask:
"""
dify_app = DifyApp(__name__)
dify_app.config.from_object(Config())
dify_app.config.from_mapping(DifyConfigs().model_dump())
dify_app.config.from_mapping(DifyConfig().model_dump())
return dify_app


Expand Down
22 changes: 11 additions & 11 deletions api/configs/app_configs.py → api/configs/app_config.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

from configs.deploy import DeploymentConfigs
from configs.enterprise import EnterpriseFeatureConfigs
from configs.extra import ExtraServiceConfigs
from configs.feature import FeatureConfigs
from configs.middleware import MiddlewareConfigs
from configs.deploy import DeploymentConfig
from configs.enterprise import EnterpriseFeatureConfig
from configs.extra import ExtraServiceConfig
from configs.feature import FeatureConfig
from configs.middleware import MiddlewareConfig
from configs.packaging import PackagingInfo


class DifyConfigs(
class DifyConfig(
# based on pydantic-settings
BaseSettings,

# Packaging info
PackagingInfo,

# Deployment configs
DeploymentConfigs,
DeploymentConfig,

# Feature configs
FeatureConfigs,
FeatureConfig,

# Middleware configs
MiddlewareConfigs,
MiddlewareConfig,

# Extra service configs
ExtraServiceConfigs,
ExtraServiceConfig,

# Enterprise feature configs
# **Before using, please contact [email protected] by email to inquire about licensing matters.**
EnterpriseFeatureConfigs,
EnterpriseFeatureConfig,
):

model_config = SettingsConfigDict(
Expand Down
2 changes: 1 addition & 1 deletion api/configs/deploy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import BaseModel, Field


class DeploymentConfigs(BaseModel):
class DeploymentConfig(BaseModel):
"""
Deployment configs
"""
Expand Down
2 changes: 1 addition & 1 deletion api/configs/enterprise/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import BaseModel, Field


class EnterpriseFeatureConfigs(BaseModel):
class EnterpriseFeatureConfig(BaseModel):
"""
Enterprise feature configs.
**Before using, please contact [email protected] by email to inquire about licensing matters.**
Expand Down
10 changes: 5 additions & 5 deletions api/configs/extra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pydantic import BaseModel

from configs.extra.notion_configs import NotionConfigs
from configs.extra.sentry_configs import SentryConfigs
from configs.extra.notion_config import NotionConfig
from configs.extra.sentry_config import SentryConfig


class ExtraServiceConfigs(
class ExtraServiceConfig(
# place the configs in alphabet order
NotionConfigs,
SentryConfigs,
NotionConfig,
SentryConfig,
):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import BaseModel, Field


class NotionConfigs(BaseModel):
class NotionConfig(BaseModel):
"""
Notion integration configs
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import BaseModel, Field, NonNegativeFloat


class SentryConfigs(BaseModel):
class SentryConfig(BaseModel):
"""
Sentry configs
"""
Expand Down
90 changes: 45 additions & 45 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import AliasChoices, BaseModel, Field, NonNegativeInt, PositiveInt


class SecurityConfigs(BaseModel):
class SecurityConfig(BaseModel):
"""
Secret Key configs
"""
Expand All @@ -16,7 +16,7 @@ class SecurityConfigs(BaseModel):
)


class AppExecutionConfigs(BaseModel):
class AppExecutionConfig(BaseModel):
"""
App Execution configs
"""
Expand All @@ -26,7 +26,7 @@ class AppExecutionConfigs(BaseModel):
)


class CodeExecutionSandboxConfigs(BaseModel):
class CodeExecutionSandboxConfig(BaseModel):
"""
Code Execution Sandbox configs
"""
Expand All @@ -41,7 +41,7 @@ class CodeExecutionSandboxConfigs(BaseModel):
)


class EndpointConfigs(BaseModel):
class EndpointConfig(BaseModel):
"""
Module URL configs
"""
Expand Down Expand Up @@ -70,7 +70,7 @@ class EndpointConfigs(BaseModel):
)


class FileAccessConfigs(BaseModel):
class FileAccessConfig(BaseModel):
"""
File Access configs
"""
Expand All @@ -89,7 +89,7 @@ class FileAccessConfigs(BaseModel):
)


class FileUploadConfigs(BaseModel):
class FileUploadConfig(BaseModel):
"""
File Uploading configs
"""
Expand All @@ -114,7 +114,7 @@ class FileUploadConfigs(BaseModel):
)


class HttpConfigs(BaseModel):
class HttpConfig(BaseModel):
"""
HTTP configs
"""
Expand All @@ -124,7 +124,7 @@ class HttpConfigs(BaseModel):
)


class InnerAPIConfigs(BaseModel):
class InnerAPIConfig(BaseModel):
"""
Inner API configs
"""
Expand All @@ -139,7 +139,7 @@ class InnerAPIConfigs(BaseModel):
)


class LoggingConfigs(BaseModel):
class LoggingConfig(BaseModel):
"""
Logging configs
"""
Expand Down Expand Up @@ -171,7 +171,7 @@ class LoggingConfigs(BaseModel):
)


class ModelLoadBalanceConfigs(BaseModel):
class ModelLoadBalanceConfig(BaseModel):
"""
Model load balance configs
"""
Expand All @@ -181,7 +181,7 @@ class ModelLoadBalanceConfigs(BaseModel):
)


class BillingConfigs(BaseModel):
class BillingConfig(BaseModel):
"""
Platform Billing Configurations
"""
Expand All @@ -191,7 +191,7 @@ class BillingConfigs(BaseModel):
)


class UpdateConfigs(BaseModel):
class UpdateConfig(BaseModel):
"""
Update configs
"""
Expand All @@ -201,7 +201,7 @@ class UpdateConfigs(BaseModel):
)


class WorkflowConfigs(BaseModel):
class WorkflowConfig(BaseModel):
"""
Workflow feature configs
"""
Expand All @@ -222,7 +222,7 @@ class WorkflowConfigs(BaseModel):
)


class OAuthConfigs(BaseModel):
class OAuthConfig(BaseModel):
"""
oauth configs
"""
Expand Down Expand Up @@ -252,7 +252,7 @@ class OAuthConfigs(BaseModel):
)


class ModerationConfigs(BaseModel):
class ModerationConfig(BaseModel):
"""
Moderation in app configs.
"""
Expand All @@ -264,7 +264,7 @@ class ModerationConfigs(BaseModel):
)


class ToolConfigs(BaseModel):
class ToolConfig(BaseModel):
"""
Tool configs
"""
Expand All @@ -275,7 +275,7 @@ class ToolConfigs(BaseModel):
)


class MailConfigs(BaseModel):
class MailConfig(BaseModel):
"""
Mail Configurations
"""
Expand Down Expand Up @@ -331,7 +331,7 @@ class MailConfigs(BaseModel):
)


class RagEtlConfigs(BaseModel):
class RagEtlConfig(BaseModel):
"""
RAG ETL Configurations.
"""
Expand All @@ -357,7 +357,7 @@ class RagEtlConfigs(BaseModel):
)


class DataSetConfigs(BaseModel):
class DataSetConfig(BaseModel):
"""
Dataset configs
"""
Expand All @@ -368,7 +368,7 @@ class DataSetConfigs(BaseModel):
)


class WorkspaceConfigs(BaseModel):
class WorkspaceConfig(BaseModel):
"""
Workspace configs
"""
Expand All @@ -379,7 +379,7 @@ class WorkspaceConfigs(BaseModel):
)


class IndexingConfigs(BaseModel):
class IndexingConfig(BaseModel):
"""
Indexing configs.
"""
Expand All @@ -390,36 +390,36 @@ class IndexingConfigs(BaseModel):
)


class ImageFormatConfigs(BaseModel):
class ImageFormatConfig(BaseModel):
MULTIMODAL_SEND_IMAGE_FORMAT: str = Field(
description='multi model send image format, support base64, url, default is base64',
default='base64',
)


class FeatureConfigs(
class FeatureConfig(
# place the configs in alphabet order
AppExecutionConfigs,
BillingConfigs,
CodeExecutionSandboxConfigs,
DataSetConfigs,
EndpointConfigs,
FileAccessConfigs,
FileUploadConfigs,
HttpConfigs,
ImageFormatConfigs,
InnerAPIConfigs,
IndexingConfigs,
LoggingConfigs,
MailConfigs,
ModelLoadBalanceConfigs,
ModerationConfigs,
OAuthConfigs,
RagEtlConfigs,
SecurityConfigs,
ToolConfigs,
UpdateConfigs,
WorkflowConfigs,
WorkspaceConfigs,
AppExecutionConfig,
BillingConfig,
CodeExecutionSandboxConfig,
DataSetConfig,
EndpointConfig,
FileAccessConfig,
FileUploadConfig,
HttpConfig,
ImageFormatConfig,
InnerAPIConfig,
IndexingConfig,
LoggingConfig,
MailConfig,
ModelLoadBalanceConfig,
ModerationConfig,
OAuthConfig,
RagEtlConfig,
SecurityConfig,
ToolConfig,
UpdateConfig,
WorkflowConfig,
WorkspaceConfig,
):
pass
6 changes: 3 additions & 3 deletions api/configs/middleware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel, Field

from configs.middleware.redis_configs import RedisConfigs
from configs.middleware.redis_config import RedisConfig
from configs.middleware.vdb.chroma_configs import ChromaConfigs
from configs.middleware.vdb.milvus_configs import MilvusConfigs
from configs.middleware.vdb.opensearch_configs import OpenSearchConfigs
Expand Down Expand Up @@ -44,10 +44,10 @@ class KeywordStoreConfigs(BaseModel):
)


class MiddlewareConfigs(
class MiddlewareConfig(
# place the configs in alphabet order
KeywordStoreConfigs,
RedisConfigs,
RedisConfig,
StorageConfigs,

# configs of vdb and vdb providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import BaseModel, Field, NonNegativeInt, PositiveInt


class RedisConfigs(BaseModel):
class RedisConfig(BaseModel):
"""
Redis configs
"""
Expand Down
Loading

0 comments on commit 8890978

Please sign in to comment.