Skip to content

Conversation

@PauloVLB
Copy link
Member

@PauloVLB PauloVLB commented Nov 12, 2025

Context

This PR introduces a way to choose between internal, external and dev immutable images when choosing the project in the init command of the CLI and update the tests accordingly.

For doing that, the old DOCKER_IMAGE constant is now a dictionary that maps the name of the project to the gcr path of the correspondent image. It was also added the option --project (or -p) to specify the project that the user wants to use and pull the correspondent image in the initialization. The user can select multiple projects, if he wants, ex.:

$ casp init -p internal -p dev

Further work

The gcr path to the images are still hardcoded, this can be improved in future work.



def pull_image() -> bool:
def pull_image(image: str = 'internal') -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here internal is more a project then an image. You could rename the function to pull_image_for_project, and keep the behavior or actually receive the image here instead of the project name, and extracting the step of doing DOCKER_IMAGES[image] out of this function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I've renamed the project parameter and the pull_image_for_project function as you suggested. The concepts should be used correctly now.

Copy link
Contributor

@javanlacerda javanlacerda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ViniciustCosta
Copy link
Collaborator

ViniciustCosta commented Nov 13, 2025

You can address this in a separate PR, but it would be nice to rename the test files to follow the codebase pattern: <filename>_test.py

@javanlacerda
Copy link
Contributor

You can address this in a separate PR, but it would be nice to rename the test files to follow the codebase pattern: <filename>_test.py

+1

type=click.Choice(
docker_utils.PROJECT_TO_IMAGE.keys(), case_sensitive=False),
multiple=True)
def cli(projects: Tuple[str, ...]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this kind of typing, prefer using either abstract container types (like Sequence) or built-in type like tuple itself over the type alias. (go/pystyle#typing-imports)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"""Pulls the docker image."""
click.echo(f'Pulling Docker image: {docker_utils.DOCKER_IMAGE}...')
if not docker_utils.pull_image():
def _pull_image_for_project(project: str = 'internal'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this method should not have a default value for project. It should always expect it as an arg.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing in future PR.

@click.command(name='init', help='Initializes the CLI')
def cli():
@click.option(
'--projects',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Maybe the name project is not very clear for external users. I think config could be a bit more clear, wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing in future PR.

@PauloVLB PauloVLB merged commit 617da1c into master Nov 13, 2025
10 checks passed
@PauloVLB PauloVLB deleted the cli-add-image-selection branch November 13, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants