Skip to content

Commit

Permalink
feat!: Set a default version number for each pipeline version, make v…
Browse files Browse the repository at this point in the history
…ersion name optional (#221)

* Wire optional name and returned versionName by GraphQL

* Typo

* Fix test

* Fix small syntax issue

* fix
  • Loading branch information
YolanFery authored Dec 3, 2024
1 parent 93e597e commit 488b290
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions openhexa/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def generate_zip_file(pipeline_directory_path: typing.Union[str, Path]) -> io.By

def upload_pipeline(
pipeline_directory_path: typing.Union[str, Path],
name: str,
name: str = None,
description: str = None,
link: str = None,
):
Expand Down Expand Up @@ -561,7 +561,7 @@ def upload_pipeline(
errors
pipelineVersion {
id
name
versionName
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions openhexa/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,11 @@ def pipelines_init(name: str):
@click.option(
"--name",
"-n",
default=None,
type=str,
help="Name of the version",
prompt="Name of the version",
required=True,
prompt_required=False,
)
@click.option(
"--description",
Expand All @@ -263,7 +264,7 @@ def pipelines_init(name: str):
@click.option("--yes", is_flag=True, help="Skip confirmation")
def pipelines_push(
path: str,
name: str,
name: str = None,
description: str = None,
link: str = None,
yes: bool = False,
Expand Down Expand Up @@ -309,17 +310,18 @@ def pipelines_push(
)
create_pipeline(pipeline.code, pipeline.name)
elif not yes:
click.confirm(
f"Pushing pipeline {click.style(pipeline.code, bold=True)} to workspace {click.style(workspace, bold=True)} with name {click.style(name, bold=True)}?",
True,
abort=True,
name_text = f" with name {click.style(name, bold=True)}" if name else ""
confirmation_message = (
f"Pushing pipeline {click.style(pipeline.code, bold=True)} "
f"to workspace {click.style(workspace, bold=True)}{name_text} ?"
)
click.confirm(confirmation_message, default=True, abort=True)

try:
upload_pipeline(path, name, description=description, link=link)
uploaded_pipeline = upload_pipeline(path, name, description=description, link=link)
click.echo(
click.style(
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)}",
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)}",
fg="green",
)
)
Expand Down
2 changes: 1 addition & 1 deletion openhexa/sdk/pipelines/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def download_pipeline(url: str, token: str, run_id: str, target_dir: str):
pipelineRun(id: $id) {
id
version {
number
versionNumber
}
code
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def test_push_pipeline(self, mock_upload_pipeline, mock_get_pipeline, mock_graph
mock_pipeline = MagicMock(spec=Pipeline)
mock_pipeline.code = pipeline_name
mock_get_pipeline.return_value = mock_pipeline
mock_upload_pipeline.return_value = {"versionName": version}

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

0 comments on commit 488b290

Please sign in to comment.