发布

  • [Promptflow CLI] Write exception info to stderr when set env PROMPTFLOW_STRUCTURE_EXCEPTION_OUTPUT (#331)

    frostbyte_neo 发布于 2023-09-08 03:53:18 +00:00

    Description

    Write exception info and command to stderr when set environment variable
    PROMPTFLOW_STRUCTURE_EXCEPTION_OUTPUT=true

    image

    promptflow error in stderr:

    {
        "message":"Connection 'invalid_name' is not found.",
        "messageFormat":"",
        "messageParameters":{
    
        },
        "referenceCode":"Unknown",
        "code":"ConnectionNotFoundError",
        "innerError":null,
        "debugInfo":{
            "type":"ConnectionNotFoundError",
            "message":"Connection 'invalid_name' is not found.",
            "stackTrace":"Traceback (most recent call last):\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_utils.py\", line 354, in wrapper\n    return func(*args, **kwargs)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_pf\\_connection.py\", line 187, in show_connection\n    connection = _client.connections.get(name)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\operations\\_connection_operations.py\", line 47, in get\n    orm_connection = ORMConnection.get(name, raise_error)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\_orm\\retry.py\", line 43, in f_retry\n    return f(*args, **kwargs)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_sdk\\_orm\\connection.py\", line 52, in get\n    raise ConnectionNotFoundError(f\"Connection {name!r} is not found.\")\n",
            "innerException":null
        },
        "command":"pf connection show --name invalid_name --format_exception"
    }
    

    system error in stderr:

    {
        "code":"SystemError",
        "message":"mock exception",
        "messageFormat":"",
        "messageParameters":{
    
        },
        "innerError":{
            "code":"Exception",
            "innerError":null
        },
        "debugInfo":{
            "type":"Exception",
            "message":"mock exception",
            "stackTrace":"Traceback (most recent call last):\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_utils.py\", line 354, in wrapper\n    return func(*args, **kwargs)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\promptflow\\_cli\\_pf\\_connection.py\", line 187, in show_connection\n    connection = _client.connections.get(name)\n  File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1093, in __call__\n    return self._mock_call(*args, **kwargs)\n  File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1097, in _mock_call\n    return self._execute_mock_call(*args, **kwargs)\n  File \"C:\\Users\\zhrua\\Miniconda3\\envs\\prompt_github\\lib\\unittest\\mock.py\", line 1158, in _execute_mock_call\n    result = effect(*args, **kwargs)\n  File \"D:\\Project\\github_promptflow\\promptflow\\src\\promptflow\\tests\\sdk_cli_test\\e2etests\\test_cli.py\", line 1123, in mocked_connection_get\n    raise Exception(\"mock exception\")\n",
            "innerException":null
        },
        "command":"pf connection show --name invalid_connection_name --format_exception"
    }
    

    All Promptflow Contribution checklist:

    • The pull request does not introduce [breaking changes]
    • CHANGELOG is updated for new features, bug fixes or other
      significant changes.
    • I have read the contribution guidelines.

    General Guidelines and Best Practices

    • Title of the pull request is clear and informative.
    • There are a small number of commits, each of which have an
      informative message. This means that previously merged commits do not
      appear in the history of the PR. For more information on cleaning up the
      commits in your PR, see this
      page
      .

    Testing Guidelines

    • Pull request includes test coverage for the included changes.
    下载附件