MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _run_process

Method _run_process

runtime/node/executor/python_executor.py:116–167  ·  view source on GitHub ↗
(
        self,
        config: PythonRunnerConfig,
        script_path: Path,
        workspace: Path,
        node: Node,
    )

Source from the content-addressed store, hash-verified

114 return path
115
116 def _run_process(
117 self,
118 config: PythonRunnerConfig,
119 script_path: Path,
120 workspace: Path,
121 node: Node,
122 ) -> _ExecutionResult:
123 cmd = [config.interpreter]
124 if config.args:
125 cmd.extend(config.args)
126 cmd.append(str(script_path))
127 env = os.environ.copy()
128 env.update(config.env or {})
129 env.update(
130 {
131 "MAC_CODE_WORKSPACE": str(workspace),
132 "MAC_CODE_SCRIPT": str(script_path),
133 "MAC_NODE_ID": node.id,
134 }
135 )
136 try:
137 completed = subprocess.run(
138 cmd,
139 cwd=str(workspace),
140 capture_output=True,
141 check=False,
142 timeout=config.timeout_seconds,
143 )
144 except subprocess.TimeoutExpired as exc:
145 return _ExecutionResult(
146 success=False,
147 stdout="",
148 stderr=exc.stdout.decode(config.encoding, errors="replace") if exc.stdout else "",
149 exit_code=None,
150 error=f"Script did not finish within {config.timeout_seconds}s",
151 )
152 except FileNotFoundError:
153 return _ExecutionResult(
154 success=False,
155 stdout="",
156 stderr="",
157 exit_code=None,
158 error=f"Interpreter {config.interpreter} not found",
159 )
160 stdout = completed.stdout.decode(config.encoding, errors="replace")
161 stderr = completed.stderr.decode(config.encoding, errors="replace")
162 return _ExecutionResult(
163 success=completed.returncode == 0,
164 stdout=stdout,
165 stderr=stderr,
166 exit_code=completed.returncode,
167 )
168
169 def _build_failure_message(
170 self,

Callers 1

executeMethod · 0.95

Calls 4

_ExecutionResultClass · 0.85
copyMethod · 0.45
updateMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected