Skip to content

Commit

Permalink
Print exception when non-zero error code
Browse files Browse the repository at this point in the history
  • Loading branch information
dyastremsky committed Mar 1, 2024
1 parent f3514e4 commit 5a3f598
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
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
11 changes: 7 additions & 4 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,16 +40,18 @@
# 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():
# Interactive use will catch exceptions and log formatted errors rather than tracebacks.
try:
run()
except Exception as e:
logger.error(f"{e}")
logger.error(f"Unhandled exception: {e}")
return 1

return 0
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)
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

0 comments on commit 5a3f598

Please sign in to comment.