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

Function create_file_in_container

codeclash/utils/environment.py:164–178  ·  view source on GitHub ↗

Create a file with given content on a Docker container. Uses a temporary file on the local filesystem for the transfer.

(
    container: DockerEnvironment,
    *,
    content: str,
    dest_path: str | Path,
)

Source from the content-addressed store, hash-verified

162 Be extremely careful with trailing slashes in src_path and dest_path, the behavior
163 of docker cp is also different depending on whether the destination exists.
164 """
165 cmd = [
166 "docker",
167 "cp",
168 f"{container.container_id}:{src_path}",
169 str(dest_path),
170 ]
171 print(f"Copy from container: cmd={cmd}")
172 Path(dest_path).parent.mkdir(parents=True, exist_ok=True)
173 result = subprocess.run(cmd, check=False, capture_output=True, text=True)
174 if result.returncode != 0:
175 raise RuntimeError(
176 f"Failed to copy {container.container_id}:{src_path} to {dest_path}: {result.stdout}{result.stderr}"
177 )
178 return result
179
180
181def create_file_in_container(

Callers 6

execute_roundMethod · 0.90
execute_roundMethod · 0.90
validate_codeMethod · 0.90
execute_roundMethod · 0.90
reset_and_apply_patchMethod · 0.90

Calls 2

_scratch_dirFunction · 0.85
copy_to_containerFunction · 0.85

Tested by

no test coverage detected