Skip to content

Commit 488b290

Browse files
authored
feat!: Set a default version number for each pipeline version, make version name optional (#221)
* Wire optional name and returned versionName by GraphQL * Typo * Fix test * Fix small syntax issue * fix
1 parent 93e597e commit 488b290

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

openhexa/cli/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ def generate_zip_file(pipeline_directory_path: typing.Union[str, Path]) -> io.By
531531

532532
def upload_pipeline(
533533
pipeline_directory_path: typing.Union[str, Path],
534-
name: str,
534+
name: str = None,
535535
description: str = None,
536536
link: str = None,
537537
):
@@ -561,7 +561,7 @@ def upload_pipeline(
561561
errors
562562
pipelineVersion {
563563
id
564-
name
564+
versionName
565565
}
566566
}
567567
}

openhexa/cli/cli.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ def pipelines_init(name: str):
237237
@click.option(
238238
"--name",
239239
"-n",
240+
default=None,
240241
type=str,
241242
help="Name of the version",
242243
prompt="Name of the version",
243-
required=True,
244+
prompt_required=False,
244245
)
245246
@click.option(
246247
"--description",
@@ -263,7 +264,7 @@ def pipelines_init(name: str):
263264
@click.option("--yes", is_flag=True, help="Skip confirmation")
264265
def pipelines_push(
265266
path: str,
266-
name: str,
267+
name: str = None,
267268
description: str = None,
268269
link: str = None,
269270
yes: bool = False,
@@ -309,17 +310,18 @@ def pipelines_push(
309310
)
310311
create_pipeline(pipeline.code, pipeline.name)
311312
elif not yes:
312-
click.confirm(
313-
f"Pushing pipeline {click.style(pipeline.code, bold=True)} to workspace {click.style(workspace, bold=True)} with name {click.style(name, bold=True)}?",
314-
True,
315-
abort=True,
313+
name_text = f" with name {click.style(name, bold=True)}" if name else ""
314+
confirmation_message = (
315+
f"Pushing pipeline {click.style(pipeline.code, bold=True)} "
316+
f"to workspace {click.style(workspace, bold=True)}{name_text} ?"
316317
)
318+
click.confirm(confirmation_message, default=True, abort=True)
317319

318320
try:
319-
upload_pipeline(path, name, description=description, link=link)
321+
uploaded_pipeline = upload_pipeline(path, name, description=description, link=link)
320322
click.echo(
321323
click.style(
322-
f"✅ New version '{name}' created! You can view the pipeline in OpenHEXA on {click.style(f'{settings.public_api_url}/workspaces/{workspace}/pipelines/{pipeline.code}', fg='bright_blue', underline=True)}",
324+
f"✅ New version '{uploaded_pipeline['versionName']}' created! You can view the pipeline in OpenHEXA on {click.style(f'{settings.public_api_url}/workspaces/{workspace}/pipelines/{pipeline.code}', fg='bright_blue', underline=True)}",
323325
fg="green",
324326
)
325327
)

openhexa/sdk/pipelines/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def download_pipeline(url: str, token: str, run_id: str, target_dir: str):
5050
pipelineRun(id: $id) {
5151
id
5252
version {
53-
number
53+
versionNumber
5454
}
5555
code
5656
}

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def test_push_pipeline(self, mock_upload_pipeline, mock_get_pipeline, mock_graph
126126
mock_pipeline = MagicMock(spec=Pipeline)
127127
mock_pipeline.code = pipeline_name
128128
mock_get_pipeline.return_value = mock_pipeline
129+
mock_upload_pipeline.return_value = {"versionName": version}
129130

130131
result = self.runner.invoke(pipelines_push, [tmp, "--name", version])
131132
self.assertEqual(result.exit_code, 0)

0 commit comments

Comments
 (0)