Skip to content

Commit

Permalink
fix: Improve error details and logging config handling (#3012)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored Dec 18, 2024
1 parent b92e911 commit 23beed9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion flytekit/extend/backend/agent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from prometheus_client import Counter, Summary

from flytekit import logger
from flytekit.bin.entrypoint import get_traceback_str
from flytekit.exceptions.system import FlyteAgentNotFound
from flytekit.extend.backend.base_agent import AgentRegistry, SyncAgentBase, mirror_async_methods
from flytekit.models.literals import LiteralMap
Expand Down Expand Up @@ -63,7 +64,7 @@ def _handle_exception(e: Exception, context: grpc.ServicerContext, task_type: st
context.set_details(error_message)
request_failure_count.labels(task_type=task_type, operation=operation, error_code=HTTPStatus.NOT_FOUND).inc()
else:
error_message = f"failed to {operation} {task_type} task with error: {e}."
error_message = f"failed to {operation} {task_type} task with error:\n {get_traceback_str(e)}."
logger.error(error_message)
context.set_code(grpc.StatusCode.INTERNAL)
context.set_details(error_message)
Expand Down
2 changes: 1 addition & 1 deletion flytekit/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_level_from_cli_verbosity(verbosity: int) -> int:
:return: logging level
"""
if verbosity == 0:
return logging.CRITICAL
return _get_env_logging_level(default_level=logging.CRITICAL)
elif verbosity == 1:
return logging.WARNING
elif verbosity == 2:
Expand Down
8 changes: 3 additions & 5 deletions tests/flytekit/unit/cli/pyflyte/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,7 @@ def test_nested_workflow(working_dir, wf_path, monkeypatch: pytest.MonkeyPatch):
],
catch_exceptions=False,
)
assert (
result.stdout.strip()
== "Running Execution on local.\nRunning Execution on local."
)
assert ("Running Execution on local." in result.stdout.strip())
assert result.exit_code == 0


Expand Down Expand Up @@ -853,7 +850,8 @@ def test_list_default_arguments(task_path):
catch_exceptions=False,
)
assert result.exit_code == 0
assert result.stdout == "Running Execution on local.\n0 Hello Color.RED\n\n"
assert "Running Execution on local." in result.stdout
assert "Hello Color.RED" in result.stdout


def test_entity_non_found_in_file():
Expand Down

0 comments on commit 23beed9

Please sign in to comment.