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

Add GenAi-PA error handling #483

Merged
merged 5 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -17,7 +17,7 @@
from typing import Dict, List, Optional, Tuple

import requests
from genaipa_exceptions import GenAiPAException
from genai_pa.exceptions import GenAiPAException
from requests import Response


Expand Down
8 changes: 6 additions & 2 deletions src/c++/perf_analyzer/genai-pa/genai_pa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from genai_pa import parser
from genai_pa.constants import LOGGER_NAME
from genai_pa.exceptions import GenAiPAException

logging.basicConfig(level=logging.INFO, format="%(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger(LOGGER_NAME)
Expand All @@ -39,8 +40,11 @@
# to assert correct errors and messages.
# Optional argv used for testing - will default to sys.argv if None.
def run(argv=None):
args = parser.parse_args(argv)
args.func(args)
try:
args = parser.parse_args(argv)
args.func(args)
except Exception as e:
raise GenAiPAException(e)


def main():
Expand Down
2 changes: 1 addition & 1 deletion src/c++/perf_analyzer/genai-pa/genai_pa/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def run(model, args=None):
arg = utils.convert_option_name(arg)
cmd += f"--{arg} {value} "
logger.info(f"Running Perf Analyzer : '{cmd}'")
subprocess.run(cmd, shell=True)
subprocess.run(cmd, shell=True, check=True)
6 changes: 6 additions & 0 deletions src/c++/perf_analyzer/genai-pa/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

import pytest
from genai_pa import parser
from genai_pa.exceptions import GenAiPAException
from genai_pa.main import run


class TestCLIArguments:
Expand Down Expand Up @@ -91,3 +93,7 @@

# Check that the exit was unsuccessful
assert exc_info.value.code != 0

def test_execption_on_nonzero_exit(self):
with pytest.raises(GenAiPAException) as e:
_ = run(["-m", "nonexistent_model"])
4 changes: 2 additions & 2 deletions src/c++/perf_analyzer/genai-pa/tests/test_llm_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import os

import pytest
from genaipa_exceptions import GenAiPAException
from llm_inputs.llm_inputs import LlmInputs
from genai_pa.exceptions import GenAiPAException
from genai_pa.llm_inputs.llm_inputs import LlmInputs


class TestLlmInputs:
Expand Down
Loading