mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:58:04 +08:00
refactor(sandbox): reorganize sandbox-related imports and rename SandboxFactory to VMFactory for clarity
This commit is contained in:
@ -23,7 +23,7 @@ from core.tools.utils.system_encryption import (
|
||||
decrypt_system_params,
|
||||
)
|
||||
from core.virtual_environment.__base.virtual_environment import VirtualEnvironment
|
||||
from core.virtual_environment.factory import SandboxFactory, SandboxType
|
||||
from core.virtual_environment.factory import VMFactory, VMType
|
||||
from extensions.ext_database import db
|
||||
from models.sandbox import SandboxProvider, SandboxProviderSystemConfig
|
||||
from services.sandbox.encryption import create_sandbox_config_encrypter, masked_config
|
||||
@ -172,7 +172,7 @@ class SandboxProviderService:
|
||||
if model_class:
|
||||
model_class.model_validate(config)
|
||||
|
||||
SandboxFactory.validate(SandboxType(provider_type), config)
|
||||
VMFactory.validate(VMType(provider_type), config)
|
||||
|
||||
@classmethod
|
||||
def save_config(
|
||||
@ -334,9 +334,9 @@ class SandboxProviderService:
|
||||
if not config or not provider_type:
|
||||
raise ValueError(f"No active sandbox provider for tenant {tenant_id} or system default")
|
||||
|
||||
return SandboxFactory.create(
|
||||
return VMFactory.create(
|
||||
tenant_id=tenant_id,
|
||||
sandbox_type=SandboxType(provider_type),
|
||||
vm_type=VMType(provider_type),
|
||||
options=dict(config),
|
||||
environments=environments or {},
|
||||
)
|
||||
|
||||
@ -14,6 +14,7 @@ from core.app.apps.advanced_chat.app_config_manager import AdvancedChatAppConfig
|
||||
from core.app.apps.workflow.app_config_manager import WorkflowAppConfigManager
|
||||
from core.file import File
|
||||
from core.repositories import DifyCoreRepositoryFactory
|
||||
from core.sandbox.manager import SandboxManager
|
||||
from core.variables import Variable
|
||||
from core.variables.variables import VariableUnion
|
||||
from core.workflow.entities import WorkflowNodeExecution
|
||||
@ -703,7 +704,6 @@ class WorkflowService:
|
||||
if draft_workflow.get_feature(WorkflowFeatures.SANDBOX).enabled:
|
||||
sandbox = SandboxProviderService.create_sandbox(tenant_id=draft_workflow.tenant_id)
|
||||
single_step_execution_id = f"single-step-{uuid.uuid4()}"
|
||||
from core.virtual_environment.sandbox_manager import SandboxManager
|
||||
|
||||
SandboxManager.register(single_step_execution_id, sandbox)
|
||||
variable_pool.system_variables.workflow_execution_id = single_step_execution_id
|
||||
@ -727,8 +727,6 @@ class WorkflowService:
|
||||
)
|
||||
finally:
|
||||
if single_step_execution_id:
|
||||
from core.virtual_environment.sandbox_manager import SandboxManager
|
||||
|
||||
sandbox = SandboxManager.unregister(single_step_execution_id)
|
||||
if sandbox:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user