Skip to content

Commit 0553aee

Browse files
author
Nazar F
authored
fix: HEXA-1389 make functional type and tags optional (#324)
* make functional type and tags optional * fix: add tags to create pipeline
1 parent 773f27c commit 0553aee

2 files changed

Lines changed: 37 additions & 24 deletions

File tree

openhexa/cli/api.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,22 @@ def get_pipeline_from_code(pipeline_code: str) -> dict[str, typing.Any]:
290290
return data["pipelineByCode"]
291291

292292

293-
def create_pipeline(pipeline_name: str, functional_type: str = None):
293+
def create_pipeline(pipeline_name: str, functional_type: str = None, tags: list[str] = None):
294294
"""Create a pipeline using the API."""
295295
if settings.current_workspace is None:
296296
raise NoActiveWorkspaceError
297+
298+
input_data = {
299+
"workspaceSlug": settings.current_workspace,
300+
"name": pipeline_name,
301+
}
302+
303+
if functional_type is not None:
304+
input_data["functionalType"] = functional_type
305+
306+
if tags:
307+
input_data["tags"] = tags
308+
297309
data = graphql(
298310
"""
299311
mutation createPipeline($input: CreatePipelineInput!) {
@@ -308,13 +320,7 @@ def create_pipeline(pipeline_name: str, functional_type: str = None):
308320
}
309321
}
310322
""",
311-
{
312-
"input": {
313-
"workspaceSlug": settings.current_workspace,
314-
"name": pipeline_name,
315-
"functionalType": functional_type,
316-
}
317-
},
323+
{"input": input_data},
318324
)
319325

320326
if not data["createPipeline"]["success"]:
@@ -625,6 +631,24 @@ def upload_pipeline(
625631
zip_file.seek(0)
626632

627633
base64_content = base64.b64encode(zip_file.read()).decode("ascii")
634+
635+
input_data = {
636+
"workspaceSlug": settings.current_workspace,
637+
"code": target_pipeline_code,
638+
"name": name,
639+
"description": description,
640+
"externalLink": link,
641+
"zipfile": base64_content,
642+
"parameters": [p.to_dict() for p in pipeline.parameters],
643+
"timeout": pipeline.timeout,
644+
}
645+
646+
if functional_type or pipeline.functional_type:
647+
input_data["functionalType"] = functional_type or pipeline.functional_type
648+
649+
if tags:
650+
input_data["tags"] = tags
651+
628652
data = graphql(
629653
"""
630654
mutation uploadPipeline($input: UploadPipelineInput!) {
@@ -651,20 +675,7 @@ def upload_pipeline(
651675
}
652676
}
653677
""",
654-
{
655-
"input": {
656-
"workspaceSlug": settings.current_workspace,
657-
"code": target_pipeline_code,
658-
"name": name,
659-
"description": description,
660-
"externalLink": link,
661-
"zipfile": base64_content,
662-
"parameters": [p.to_dict() for p in pipeline.parameters],
663-
"timeout": pipeline.timeout,
664-
"functionalType": functional_type or pipeline.functional_type,
665-
"tags": tags,
666-
}
667-
},
678+
{"input": input_data},
668679
)
669680

670681
if not data["uploadPipeline"]["success"]:

openhexa/cli/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,12 @@ def pipelines_push(
459459
)
460460
click.confirm(confirmation_message, default=True, abort=True)
461461

462-
selected_pipeline = selected_pipeline or create_pipeline(pipeline.name, functional_type=functional_type)
462+
normalized_tags = [normalize_tag(t) for t in tag] if tag else []
463+
selected_pipeline = selected_pipeline or create_pipeline(
464+
pipeline.name, functional_type=functional_type, tags=normalized_tags
465+
)
463466
uploaded_pipeline_version = None
464467
try:
465-
normalized_tags = [normalize_tag(t) for t in tag] if tag else []
466468
uploaded_pipeline_version = upload_pipeline(
467469
selected_pipeline["code"],
468470
path,

0 commit comments

Comments
 (0)