Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion openhexa/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,20 @@ def generate_zip_file(pipeline_directory_path: str | Path) -> io.BytesIO:
return zip_file


def _parameter_to_graphql_input(parameter) -> dict:
"""Serialize a pipeline parameter into a GraphQL ``ParameterInput``.

``Parameter.to_dict()`` uses snake_case keys for the parameter spec, but the
GraphQL ``ParameterInput`` type expects camelCase field names. Most keys are
single words and match in both conventions; ``choices_from_file`` is the
exception and must be renamed to ``choicesFromFile``.
"""
spec = parameter.to_dict()
if "choices_from_file" in spec:
spec["choicesFromFile"] = spec.pop("choices_from_file")
return spec


def upload_pipeline(
target_pipeline_code: str,
pipeline_directory_path: str | Path,
Expand Down Expand Up @@ -647,7 +661,7 @@ def upload_pipeline(
"description": description,
"externalLink": link,
"zipfile": base64_content,
"parameters": [p.to_dict() for p in pipeline.parameters],
"parameters": [_parameter_to_graphql_input(p) for p in pipeline.parameters],
"timeout": pipeline.timeout,
}

Expand Down
Loading