Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions data-agent-management/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
Expand Down Expand Up @@ -269,6 +273,16 @@
<artifactId>spring-ai-alibaba-graph-core</artifactId>
<version>${spring-ai-alibaba.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-sandbox</artifactId>
<version>${spring-ai-alibaba.version}</version>
</dependency>
<dependency>
<groupId>org.tomlj</groupId>
<artifactId>tomlj</artifactId>
<version>${tomlj.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
Expand Down Expand Up @@ -371,16 +385,6 @@
<artifactId>easyexcel</artifactId>
<version>3.3.4</version>
</dependency>
<!-- Docker Java Client -->
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-zerodep</artifactId>
</dependency>

</dependencies>
<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import com.alibaba.cloud.ai.dataagent.properties.DataAgentProperties;
import com.alibaba.cloud.ai.dataagent.properties.FileStorageProperties;
import com.alibaba.cloud.ai.dataagent.properties.OssStorageProperties;
import com.alibaba.cloud.ai.dataagent.service.code.CodePoolExecutorService;
import com.alibaba.cloud.ai.dataagent.service.code.CodePoolExecutorServiceFactory;
import com.alibaba.cloud.ai.dataagent.service.code.docker.DockerExecutorFactory;
import com.alibaba.cloud.ai.dataagent.service.file.FileStorageService;
import com.alibaba.cloud.ai.dataagent.service.file.FileStorageServiceFactory;
import com.alibaba.cloud.ai.dataagent.service.llm.LlmService;
Expand Down Expand Up @@ -127,13 +124,6 @@ public FileStorageService fileStorageService(FileStorageProperties properties,
return new FileStorageServiceFactory(properties, ossStorageProperties).getObject();
}

@Bean
@ConditionalOnMissingBean(CodePoolExecutorService.class)
public CodePoolExecutorService codePoolExecutorService(CodeExecutorProperties properties, LlmService llmService,
DockerExecutorFactory dockerExecutorFactory) {
return new CodePoolExecutorServiceFactory(properties, llmService, dockerExecutorFactory).getObject();
}

@Bean
@ConditionalOnMissingBean(RestClientCustomizer.class)
public RestClientCustomizer restClientCustomizer(@Value("${rest.connect.timeout:600}") long connectTimeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
*/
package com.alibaba.cloud.ai.dataagent.properties;

import com.alibaba.cloud.ai.dataagent.enums.CodePoolExecutorEnum;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;

import static com.alibaba.cloud.ai.dataagent.constant.Constant.PROJECT_PROPERTIES_PREFIX;

/**
Expand All @@ -34,94 +35,59 @@ public class CodeExecutorProperties {
public static final String CONFIG_PREFIX = PROJECT_PROPERTIES_PREFIX + ".code-executor";

/**
* Specify implementation class of code container pool runtime service
* Maximum container memory, in MB
*/
CodePoolExecutorEnum codePoolExecutor = CodePoolExecutorEnum.DOCKER;
Long limitMemory = 500L;

/**
* Service host, use default address if null
* Number of container CPU cores
*/
String host = null;
Long cpuCore = 1L;

/**
* Image name, can customize image with common third-party dependencies to replace
* this configuration
* Python code execution time limit
*/
String imageName = "continuumio/anaconda3:latest";
Duration codeTimeout = Duration.ofSeconds(60);

/**
* Container name prefix
* Python执行的最大重试次数
*/
String containerNamePrefix = "nl2sql-python-exec-";
Integer pythonMaxTriesCount = 5;

/**
* Task blocking queue size
*/
Integer taskQueueSize = 5;
private Sandbox sandbox = new Sandbox();

/**
* Maximum number of core containers
*/
Integer coreContainerNum = 2;
@Getter
@Setter
public static class Sandbox {

/**
* Maximum number of temporary containers
*/
Integer tempContainerNum = 2;
String dockerHost = "unix:///var/run/docker.sock";

/**
* Core thread count of thread pool
*/
Integer coreThreadSize = 5;
String imageName = "agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-base:latest";

/**
* Maximum thread count of thread pool
*/
Integer maxThreadSize = 5;
String containerPrefix = "dataagent-sandbox-";

/**
* Survival time of temporary containers, in minutes
*/
Integer tempContainerAliveTime = 5;
Integer maxConcurrency = 4;

/**
* Task survival time of thread pool, in seconds
*/
Long keepThreadAliveTime = 60L;
Integer queueCapacity = 10;

/**
* Task blocking queue size of thread pool
*/
Integer threadQueueSize = 10;
Integer maxCodeBytes = 256 * 1024;

/**
* Maximum container memory, in MB
*/
Long limitMemory = 500L;
Integer maxInputBytes = 10 * 1024 * 1024;

/**
* Number of container CPU cores
*/
Long cpuCore = 1L;
Integer maxOutputBytes = 1024 * 1024;

/**
* Python code execution time limit
*/
String codeTimeout = "60s";
Integer maxErrorBytes = 256 * 1024;

/**
* Maximum container runtime
*/
Long containerTimeout = 3000L;
Integer maxMetadataBytes = 8 * 1024;

/**
* Container network mode
*/
String networkMode = "none";
Integer maxDependencies = 20;

/**
* Python执行的最大重试次数
*/
Integer pythonMaxTriesCount = 5;
String packageIndexUrl = "https://pypi.org/simple";

Duration dependencyInstallTimeout = Duration.ofMinutes(3);

Integer maxConnections = 4096;

}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
*/
package com.alibaba.cloud.ai.dataagent.service.code;

import java.util.List;

/**
* 运行Python任务的容器池接口
*
* @author vlsmb
* @since 2025/7/12
* Executes generated Python code in an isolated sandbox.
*/
public interface CodePoolExecutorService {
public interface PythonCodeExecutorService {

TaskResponse runTask(TaskRequest request);

record TaskRequest(String code, String input, String requirement) {
record TaskRequest(String code, String input, List<String> dependencies) {

public TaskRequest {
dependencies = dependencies == null ? List.of() : List.copyOf(dependencies);
}

}

record TaskResponse(boolean isSuccess, boolean executionSuccessButResultFailed, String stdOut, String stdErr,
String exceptionMsg) {

// 执行运行代码任务时发生异常
public static TaskResponse exception(String msg) {
return new TaskResponse(false, false, null, null, "An exception occurred while executing the task: " + msg);
}

// 执行运行代码任务成功,并且代码正常返回
public static TaskResponse success(String stdOut) {
return new TaskResponse(true, false, stdOut, null, null);
}

// 执行运行代码任务成功,但是代码异常返回
public static TaskResponse failure(String stdOut, String stdErr) {
return new TaskResponse(false, true, stdOut, stdErr, "StdErr: " + stdErr);
}
Expand All @@ -54,10 +54,4 @@ public String toString() {
}
}

enum State {

READY, RUNNING, REMOVING

}

}

This file was deleted.

Loading
Loading