NVIDIA / NVTX

The NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications.
Apache License 2.0
309 stars 48 forks source link

[python] Automatic annotation with function name #85

Closed merlinND closed 11 months ago

merlinND commented 12 months ago

Hello,

As of nvtx 0.2.8 (installed from Pypi), the feature automatically annotating functions with their name when using @nvtx.annotate() no longer works.

I believe this is due to the following check: https://github.com/NVIDIA/NVTX/blob/fcc56f8d439ab33249ab1d702c7daa6e73a353d7/python/nvtx/nvtx.py#L107

Indeed, self.attributes.message seems to be created regardless of whether message was provided in the constructor: https://github.com/NVIDIA/NVTX/blob/fcc56f8d439ab33249ab1d702c7daa6e73a353d7/python/nvtx/nvtx.py#L78

Changing the check to:

if not self.attributes.message.string:

locally seems to give back the expected behavior (however I don't know if this is the correct fix).

shwina commented 12 months ago

Ah, good catch @merlinND -- any chance you are interested in submitting the fix as a pull request? If so, I'm happy to merge, test locally, and cut a release.