|
6 | 6 | import typer |
7 | 7 |
|
8 | 8 | from gaiaflow.constants import DEFAULT_IMAGE_NAME, Service |
| 9 | +from gaiaflow.managers.helpers import DockerHandlerMode |
9 | 10 |
|
10 | 11 | app = typer.Typer() |
11 | 12 | fs = fsspec.filesystem("file") |
@@ -256,8 +257,7 @@ def dockerize( |
256 | 257 | DEFAULT_IMAGE_NAME, "--image-name", "-i", help=("Name of your image.") |
257 | 258 | ), |
258 | 259 | dockerfile_path: Path = typer.Option( |
259 | | - None, "--dockerfile-path", "-d", help=("Path to your custom " |
260 | | - "Dockerfile") |
| 260 | + None, "--dockerfile-path", "-d", help=("Path to your custom Dockerfile") |
261 | 261 | ), |
262 | 262 | ): |
263 | 263 | imports = load_imports() |
@@ -288,6 +288,47 @@ def dockerize( |
288 | 288 | ) |
289 | 289 |
|
290 | 290 |
|
| 291 | + |
| 292 | +@app.command(help="List all the docker images in your system") |
| 293 | +def list_images(): |
| 294 | + imports = load_imports() |
| 295 | + project_path = Path.cwd() |
| 296 | + gaiaflow_path, user_project_path = imports.create_gaiaflow_context_path( |
| 297 | + project_path |
| 298 | + ) |
| 299 | + gaiaflow_path_exists = imports.gaiaflow_path_exists_in_state(gaiaflow_path, True) |
| 300 | + if not gaiaflow_path_exists: |
| 301 | + typer.echo("Please create a project with Gaiaflow before running this command.") |
| 302 | + return |
| 303 | + imports.MinikubeManager.run( |
| 304 | + gaiaflow_path=gaiaflow_path, |
| 305 | + user_project_path=user_project_path, |
| 306 | + action=imports.ExtendedAction.LIST_IMAGES, |
| 307 | + docker_handler_mode=DockerHandlerMode.LOCAL, |
| 308 | + ) |
| 309 | + |
| 310 | +@app.command(help="Delete a docker image from your system") |
| 311 | +def remove_image(image_name: str = typer.Option( |
| 312 | + DEFAULT_IMAGE_NAME, "--image-name", "-i", help=("Name of image " |
| 313 | + "to be deleted.") |
| 314 | + ),): |
| 315 | + imports = load_imports() |
| 316 | + project_path = Path.cwd() |
| 317 | + gaiaflow_path, user_project_path = imports.create_gaiaflow_context_path( |
| 318 | + project_path |
| 319 | + ) |
| 320 | + gaiaflow_path_exists = imports.gaiaflow_path_exists_in_state(gaiaflow_path, True) |
| 321 | + if not gaiaflow_path_exists: |
| 322 | + typer.echo("Please create a project with Gaiaflow before running this command.") |
| 323 | + return |
| 324 | + imports.MinikubeManager.run( |
| 325 | + gaiaflow_path=gaiaflow_path, |
| 326 | + user_project_path=user_project_path, |
| 327 | + action=imports.ExtendedAction.REMOVE_IMAGE, |
| 328 | + image_name=image_name, |
| 329 | + docker_handler_mode=DockerHandlerMode.LOCAL, |
| 330 | + ) |
| 331 | + |
291 | 332 | @app.command( |
292 | 333 | help="Update the dependencies for the Airflow tasks. This command " |
293 | 334 | "synchronizes the running container environments with the project's" |
|
0 commit comments