MCPcopy Index your code
hub / github.com/CodeClash-ai/CodeClash / pull_game_container_aws_ecr

Function pull_game_container_aws_ecr

codeclash/utils/aws.py:30–62  ·  view source on GitHub ↗

Pull a game container from AWS ECR and tag it with the local name. Args: game_name: The game name (e.g., 'BattleSnake') image_name: The local image name (e.g., 'codeclash/battlesnake') logger: Logger instance for debug output Raises: AssertionError: If AWS_D

(*, game_name: str, image_name: str, logger: Logger)

Source from the content-addressed store, hash-verified

28
29
30def pull_game_container_aws_ecr(*, game_name: str, image_name: str, logger: Logger) -> None:
31 """Pull a game container from AWS ECR and tag it with the local name.
32
33 Args:
34 game_name: The game name (e.g., 'BattleSnake')
35 image_name: The local image name (e.g., 'codeclash/battlesnake')
36 logger: Logger instance for debug output
37
38 Raises:
39 AssertionError: If AWS_DOCKER_REGISTRY is not set
40 RuntimeError: If docker pull or tag fails
41 """
42 logger.info(f"Running in AWS Batch, pulling Docker image {image_name}")
43
44 aws_docker_registry = os.getenv("AWS_DOCKER_REGISTRY")
45 assert aws_docker_registry is not None, (
46 "AWS_DOCKER_REGISTRY environment variable must be set when running in AWS Batch"
47 )
48
49 registry_image = f"{aws_docker_registry}/codeclash/{game_name.lower()}"
50
51 logger.debug(f"Pulling {registry_image} and tagging as {image_name}")
52 result = subprocess.run(
53 f"docker pull {registry_image} && docker tag {registry_image} {image_name}",
54 shell=True,
55 capture_output=True,
56 text=True,
57 )
58 if result.returncode != 0:
59 logger.error(f"❌ Failed to pull and tag Docker image: {result.stderr}\n{result.stdout}")
60 raise RuntimeError(f"Failed to pull and tag Docker image: {result.stderr}")
61
62 logger.info(f"✅ Pulled and tagged Docker image {image_name}")
63
64
65def s3_log_sync(local_output_dir: Path, *, logger: Logger) -> None:

Callers 1

build_imageMethod · 0.90

Calls 1

runMethod · 0.45

Tested by

no test coverage detected