mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
feat(LocalRunnerClient): support executing origin actions
Context: Origin actions are generated by DynamicActionGenerator and may optionally be persistently serialized. This feature adds the basic execution flow for origin actions within LocalRunnerClient. Notes: The current mapping between action files and their extensions is hardcoded. This should later be replaced with a configurable registry or loaded dynamically during application startup.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import sys
|
||||
|
||||
|
||||
def parse_args(argv):
|
||||
"""
|
||||
将 --key=value 解析成 dict
|
||||
"""
|
||||
params = {}
|
||||
for arg in argv:
|
||||
if arg.startswith("--") and "=" in arg:
|
||||
key, value = arg[2:].split("=", 1)
|
||||
params[key] = value
|
||||
return params
|
||||
|
||||
|
||||
def main():
|
||||
params = parse_args(sys.argv[1:])
|
||||
|
||||
name = params.get("name", "World")
|
||||
print(f"Hello {name}!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,40 @@
|
||||
package work.slhaf.partner.core.action.runner;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import work.slhaf.partner.core.action.entity.MetaAction;
|
||||
import work.slhaf.partner.core.action.entity.MetaActionType;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class LocalRunnerClientTest {
|
||||
|
||||
static LocalRunnerClient runnerClient;
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
runnerClient = new LocalRunnerClient(Map.of(), Executors.newVirtualThreadPerTaskExecutor(), "/home/slhaf/Projects/IdeaProjects/Projects/Partner/Partner-Main/src/test/java/resources/action/data");
|
||||
}
|
||||
|
||||
@Test
|
||||
void runOrigin() {
|
||||
MetaAction metaAction = buildTmpMetaAction();
|
||||
|
||||
RunnerClient.RunnerResponse runnerResponse = runnerClient.doRun(metaAction);
|
||||
System.out.println(runnerResponse.getData());
|
||||
}
|
||||
|
||||
private static @NotNull MetaAction buildTmpMetaAction() {
|
||||
MetaAction metaAction = new MetaAction();
|
||||
metaAction.setIo(false);
|
||||
metaAction.setKey("hello_world");
|
||||
metaAction.setParams(Map.of("name", "origin_run"));
|
||||
metaAction.setOrder(-1);
|
||||
metaAction.setType(MetaActionType.ORIGIN);
|
||||
metaAction.setPath(Path.of("/home/slhaf/Projects/IdeaProjects/Projects/Partner/Partner-Main/src/test/java/resources/action/tmp/hello_world.py"));
|
||||
return metaAction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user