Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Set a default version number for each pipeline version, make version name optional #221

Merged
Show file tree
Hide file tree
Changes from 4 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
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
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