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

trunner: provide traceback for internal exceptions when waiting for plo #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

damianloew
Copy link
Contributor

@damianloew damianloew commented Oct 16, 2023

Description

Before:
Screenshot from 2023-10-16 10-42-39

After:
Screenshot from 2023-10-25 11-56-48

The mentioned issue has been described on Confluence in Github Known Issues - point 2.5.

Motivation and Context

Provide more information about internal serial exceptions.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@damianloew damianloew marked this pull request as ready for review October 16, 2023 09:01
@github-actions
Copy link

github-actions bot commented Oct 16, 2023

Unit Test Results

5 949 tests  ±0   5 296 ✔️ ±0   30m 49s ⏱️ - 1m 43s
   325 suites ±0      653 💤 ±0 
       1 files   ±0          0 ±0 

Results for commit de0e94b. ± Comparison against base commit a37c915.

♻️ This comment has been updated with latest results.

@nalajcie
Copy link
Member

IMHO this should be solved in other way (maybe change how phoenixd exception is printed depending on verbosity in raw logs / test summary. Wrapping all phoenixd errors as PhoenixException is a nice way of abstracting things and makes it easier to use.

Please note that the original exception traceback is not lost, just not explicitly printed.

@damianloew damianloew changed the title trunner: don't wrap internal exceptions when waiting for plo device trunner: provide traceback for internal exceptions when waiting for plo Oct 25, 2023
@damianloew
Copy link
Contributor Author

damianloew commented Oct 25, 2023

IMHO this should be solved in other way (maybe change how phoenixd exception is printed depending on verbosity in raw logs / test summary. Wrapping all phoenixd errors as PhoenixException is a nice way of abstracting things and makes it easier to use.

Please note that the original exception traceback is not lost, just not explicitly printed.

Did you mean sth like the changes in the last force push?
To leave the phoenix exceptions simple I'd print traceback as output:
Screenshot from 2023-10-25 11-56-48

@damianloew damianloew force-pushed the damianloew/trunner_exceptions branch 2 times, most recently from 8401865 to 1c7e694 Compare October 26, 2023 08:58
@@ -24,7 +25,7 @@ def wait_for_vid_pid(vid: int, pid: int, timeout=0):
found_ports = [port for port in list_ports.comports() if port.pid == pid and port.vid == vid]

if len(found_ports) > 1:
raise Exception(
raise AssertionError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is not an Assertion error (or convert it to assert), maybe ValueError would be more in place here?

except (TimeoutError, AssertionError) as exc:
raise PhoenixdError(msg=str(exc)) from exc
except Exception as exc:
raise PhoenixdError(msg=str(exc), output=traceback.format_exc()) from exc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, it looks strange that the traceback is under OUTPUT, imho would be better to format the PhoenixdError exception directly inside the the exception implementation, sample code below (not tested):

class ProcessError(HarnessError):
    name: str = "PROCESS"
    # [...]

    def __str__(self) -> str:
        # TODO format github actions output
        err = [bold(f"{self.name} ERROR: ") + self.msg]

        if self.output is not None:
            err.extend([bold("OUTPUT:"), self.output])

        err.extend(self._format_additional_info())

        # ADDED CODE:
        # add traceback if it's rather an implementation error instead of a logic one
        if not isinstance(self.__cause__, TimeoutError):
            err.append(bold("TRACEBACK:"))
            err.extend(traceback.format_exception(self))

        err.append("")
        return "\n".join(err)

Copy link
Contributor Author

@damianloew damianloew Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked through all ProcessErrors used in test runner and in most of the cases traceback seems to be unnecessary (the line in test runner is then shown), I'd like to print it only for internal exceptions, where we don't know the exact line. That's why I've proposed (last fp) adding it only when Exception is raised and labeled as TRACEBACK:

Screenshot from 2023-11-02 13-42-59

What do you think?

@damianloew damianloew force-pushed the damianloew/trunner_exceptions branch 2 times, most recently from 3c5be3b to aed2461 Compare November 2, 2023 12:56
raise PhoenixdError(str(exc)) from exc
except Exception as exc:
# add traceback if it's an internal exception
raise PhoenixdError(str(exc), traceback=traceback.format_exc()) from exc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacing exception traceback is kindof misleading (no PhoenixdErorr exception is raised at the line provided in traceback). My proposed solution provided real traceback (2 tracebacks because of from usage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants