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

vdk-control-cli: improve execute error handling #135

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tabulate import tabulate
from taurus.vdk.control.configuration.defaults_config import load_default_team_name
from taurus.vdk.control.rest_lib.factory import ApiClientFactory
from taurus.vdk.control.rest_lib.rest_client_errors import ApiClientErrorDecorator
from taurus.vdk.control.utils import cli_utils
from taurus.vdk.control.utils.cli_utils import get_or_prompt
from taurus.vdk.control.utils.cli_utils import OutputFormat
Expand Down Expand Up @@ -51,6 +52,7 @@ def transform_execution(e: DataJobExecution):
elif output == OutputFormat.JSON.value:
return cli_utils.json_format(list(executions))

@ApiClientErrorDecorator()
def start(self, name: str, team: str, output: OutputFormat):
execution_request = DataJobExecutionRequest(
started_by=f"vdk-control-cli", args={}
Expand Down Expand Up @@ -80,12 +82,14 @@ def start(self, name: str, team: str, output: OutputFormat):
}
click.echo(json.dumps(result))

@ApiClientErrorDecorator()
def show(self, name: str, team: str, execution_id: str, output: OutputFormat):
execution: DataJobExecution = self.execution_api.data_job_execution_read(
team_name=team, job_name=name, execution_id=execution_id
)
click.echo(self.__model_executions([execution], output))

@ApiClientErrorDecorator()
def list(self, name: str, team: str, output: OutputFormat):
executions: list[DataJobExecution] = self.execution_api.data_job_execution_list(
team_name=team, job_name=name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ def test_execute_start_output_json(httpserver: PluginHTTPServer, tmpdir: LocalPa

assert job_name == json_output.get("job_name")
assert team_name == json_output.get("team")

def test_execute_with_exception(httpserver: PluginHTTPServer, tmpdir:LocalPath):
runner = CliRunner()
result = runner.invoke(execute, ["--start", "-n", "job_name", "-t", "team_name", "-u", "localhost"])

assert (
result.exit_code == 2
), f"result exit code is not 2, result output: {result.output}, exc: {result.exc_info}"
assert "what" in result.output and "why" in result.output