MCPcopy
hub / github.com/allenai/open-instruct / should_execute

Function should_execute

open_instruct/code_utils/code_utils.py:271–286  ·  view source on GitHub ↗

Determine if we should try to execute this program at all for safety reasons.

(program: str, tests: list[Any])

Source from the content-addressed store, hash-verified

269
270
271def should_execute(program: str, tests: list[Any]) -> bool:
272 """Determine if we should try to execute this program at all for safety
273 reasons."""
274 dangerous_commands = [
275 "threading",
276 "multiprocess",
277 "multiprocessing",
278 "import os",
279 "from os",
280 "shutil",
281 "import torch",
282 "from torch",
283 "import sklearn",
284 "from sklearn",
285 ]
286 return all(comm not in program for comm in dangerous_commands)
287
288
289# -------------------------------------------------------------

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected