MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / load_policy_module

Function load_policy_module

codeclash/arenas/cyborg/runtime/run_cyborg.py:27–43  ·  view source on GitHub ↗
(player_name: str, path: str)

Source from the content-addressed store, hash-verified

25
26
27def load_policy_module(player_name: str, path: str):
28 agent_dir = str(Path(path).resolve().parent)
29 inserted_agent_dir = agent_dir not in sys.path
30 if inserted_agent_dir:
31 sys.path.insert(0, agent_dir)
32 spec = importlib.util.spec_from_file_location(safe_module_name(player_name), path)
33 if spec is None or spec.loader is None:
34 raise RuntimeError(f"Could not load module spec from {path}")
35 module = importlib.util.module_from_spec(spec)
36 try:
37 spec.loader.exec_module(module)
38 finally:
39 if inserted_agent_dir:
40 sys.path.remove(agent_dir)
41 if not hasattr(module, "decide") or not callable(module.decide):
42 raise RuntimeError(f"{path} must define a callable decide(observation, action_space)")
43 return module
44
45
46def observation_to_plain(observation):

Callers 1

policy_workerFunction · 0.70

Calls 1

safe_module_nameFunction · 0.70

Tested by

no test coverage detected