Skip to content

Commit 005b0ac

Browse files
committed
update gaiaflow
1 parent 51099b5 commit 005b0ac

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

src/gaiaflow/cli/commands/minikube.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,10 @@ def restart(
9999
)
100100

101101

102-
@app.command(help="Containerize your package into a docker image.")
102+
@app.command(help="Containerize your package into a docker image inside the "
103+
"minikube cluster.")
103104
def dockerize(
104105
project_path: Path = typer.Option(..., "--path", "-p", help="Path to your project"),
105-
local: bool = typer.Option(
106-
False,
107-
"--local",
108-
"-l",
109-
help="This will create the image in your local docker instance instead "
110-
"of creating it inside prod-local environment",
111-
),
112106
):
113107
imports = load_imports()
114108
gaiaflow_path, user_project_path = imports.create_gaiaflow_context_path(
@@ -122,7 +116,7 @@ def dockerize(
122116
gaiaflow_path=gaiaflow_path,
123117
user_project_path=user_project_path,
124118
action=imports.ExtendedAction.DOCKERIZE,
125-
local=local,
119+
local=False,
126120
)
127121

128122

src/gaiaflow/cli/commands/mlops.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212

1313

1414
def load_imports():
15-
from gaiaflow.constants import BaseAction
15+
from gaiaflow.constants import BaseAction, ExtendedAction
1616
from gaiaflow.managers.mlops_manager import MlopsManager
17+
from gaiaflow.managers.minikube_manager import MinikubeManager
1718
from gaiaflow.managers.utils import (create_gaiaflow_context_path,
1819
gaiaflow_path_exists_in_state,
1920
save_project_state)
2021

2122
return SimpleNamespace(
2223
BaseAction=BaseAction,
24+
ExtendedAction=ExtendedAction,
2325
MlopsManager=MlopsManager,
26+
MinikubeManager=MinikubeManager,
2427
create_gaiaflow_context_path=create_gaiaflow_context_path,
2528
gaiaflow_path_exists_in_state=gaiaflow_path_exists_in_state,
2629
save_project_state=save_project_state,
@@ -233,6 +236,34 @@ def cleanup(
233236
)
234237

235238

239+
240+
@app.command(help="Containerize your package into a docker image locally.")
241+
def dockerize(
242+
project_path: Path = typer.Option(..., "--path", "-p", help="Path to your project"),
243+
):
244+
imports = load_imports()
245+
gaiaflow_path, user_project_path = imports.create_gaiaflow_context_path(
246+
project_path
247+
)
248+
gaiaflow_path_exists = imports.gaiaflow_path_exists_in_state(gaiaflow_path, True)
249+
if not gaiaflow_path_exists:
250+
imports.save_project_state(user_project_path, gaiaflow_path)
251+
else:
252+
typer.echo(
253+
f"Gaiaflow project already exists at {gaiaflow_path}. Skipping "
254+
f"saving to the state"
255+
)
256+
257+
typer.echo("Running dockerize")
258+
imports.MinikubeManager.run(
259+
gaiaflow_path=gaiaflow_path,
260+
user_project_path=user_project_path,
261+
action=imports.ExtendedAction.DOCKERIZE,
262+
local=True,
263+
)
264+
265+
266+
236267
# TODO: To let the user update the current infra with new local packages or
237268
# mounts as they want it.
238269
# def update():

src/gaiaflow/core/create_task.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@
309309

310310
class GaiaflowMode(Enum):
311311
DEV = "dev"
312-
PROD_LOCAL_DOCKER = "prod_local_docker"
313-
PROD_LOCAL_MINIKUBE = "prod_local_minikube"
312+
DEV_DOCKER = "dev_docker"
313+
PROD_LOCAL = "prod_local"
314314
PROD = "prod"
315315

316316

317317
OPERATOR_MAP = {
318318
GaiaflowMode.DEV: DevTaskOperator,
319-
GaiaflowMode.PROD_LOCAL_DOCKER: DockerTaskOperator,
320-
GaiaflowMode.PROD_LOCAL_MINIKUBE: ProdLocalTaskOperator,
319+
GaiaflowMode.DEV_DOCKER: DockerTaskOperator,
320+
GaiaflowMode.PROD_LOCAL: ProdLocalTaskOperator,
321321
GaiaflowMode.PROD: ProdTaskOperator,
322322
}
323323

@@ -333,8 +333,12 @@ def create_task(
333333
env_vars: dict | None = None,
334334
retries: int = 3,
335335
dag=None,
336-
params=None,
337336
):
337+
"""It is a high-level abstraction on top of Apache Airflow operators.
338+
339+
It allows you to define tasks for your DAGs in a uniform, environment-aware
340+
way, without worrying about which Airflow operator to use for each execution mode.
341+
"""
338342
try:
339343
gaiaflow_mode: GaiaflowMode = GaiaflowMode(mode)
340344
except ValueError:
@@ -348,7 +352,6 @@ def create_task(
348352
env_vars = {}
349353

350354
dag_params = getattr(dag, "params", {}) if dag else {}
351-
combined_params = {**dag_params, **(params or {})}
352355

353356
operator_cls = OPERATOR_MAP.get(gaiaflow_mode)
354357
if not operator_cls:
@@ -363,7 +366,7 @@ def create_task(
363366
secrets=secrets,
364367
env_vars=env_vars,
365368
retries=retries,
366-
params=combined_params,
369+
params=dag_params,
367370
mode=mode,
368371
)
369372

0 commit comments

Comments
 (0)