mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(runner): remove unused method listSystemDependencies
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package work.slhaf.partner.core.action.runner;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -18,7 +16,6 @@ import work.slhaf.partner.core.action.runner.support.ActionSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -156,29 +153,6 @@ public class LocalRunnerClient extends RunnerClient implements AutoCloseable {
|
||||
actionSerializer.persistSerialize(metaActionInfo, fileMetaData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject listSysDependencies() {
|
||||
JSONObject sysDependencies = new JSONObject();
|
||||
sysDependencies.put("language", "Python");
|
||||
JSONArray dependencies = sysDependencies.putArray("dependencies");
|
||||
CommandExecutionService.Result pyResult = commandExecutionService.exec("pip", "list", "--format=freeze");
|
||||
if (pyResult.isOk()) {
|
||||
List<String> resultList = pyResult.getResultList();
|
||||
if (resultList != null) {
|
||||
for (String result : resultList) {
|
||||
JSONObject element = dependencies.addObject();
|
||||
String[] split = result.split("==");
|
||||
element.put("name", split[0]);
|
||||
element.put("version", split.length > 1 ? split[1] : "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JSONObject element = dependencies.addObject();
|
||||
element.put("error", pyResult.getTotal());
|
||||
}
|
||||
return sysDependencies;
|
||||
}
|
||||
|
||||
private void registerMcpClient(McpClientRegistry clientRegistry, McpTransportFactory transportFactory, String id, McpTransportConfig transportConfig) {
|
||||
val client = io.modelcontextprotocol.client.McpClient.sync(transportFactory.create(transportConfig, null))
|
||||
.requestTimeout(java.time.Duration.ofSeconds(transportConfig.timeout()))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package work.slhaf.partner.core.action.runner;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -111,11 +110,6 @@ public abstract class RunnerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出执行环境下的系统依赖情况
|
||||
*/
|
||||
public abstract JSONObject listSysDependencies();
|
||||
|
||||
@Data
|
||||
public static class RunnerResponse {
|
||||
private boolean ok;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package work.slhaf.partner.core.action.runner;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import work.slhaf.partner.core.action.entity.ActionFileMetaData;
|
||||
import work.slhaf.partner.core.action.entity.MetaAction;
|
||||
import work.slhaf.partner.core.action.entity.MetaActionInfo;
|
||||
@@ -39,11 +38,6 @@ public class SandboxRunnerClient extends RunnerClient {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject listSysDependencies() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildTmpPath(String actionKey, String codeType) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildTmpPath'");
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
package experimental;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import work.slhaf.partner.core.action.entity.MetaActionInfo;
|
||||
import work.slhaf.partner.core.action.runner.LocalRunnerClient;
|
||||
import work.slhaf.partner.core.action.runner.RunnerClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class SystemTest {
|
||||
@Test
|
||||
@@ -36,13 +29,4 @@ public class SystemTest {
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
void localRunnerClientTest() {
|
||||
ConcurrentHashMap<String, MetaActionInfo> existedMetaActions = new ConcurrentHashMap<>();
|
||||
ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
RunnerClient client = new LocalRunnerClient(existedMetaActions, executor, null);
|
||||
JSONObject res = client.listSysDependencies();
|
||||
System.out.println(res.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user