skpro icon indicating copy to clipboard operation
skpro copied to clipboard

ENH: improve diagnostics when conversion between mtypes is not defined

Open mohityadav8 opened this issue 9 months ago • 5 comments

Reference Issues/PRs

Closes #792

What does this implement/fix? Explain your changes.

This PR improves the error diagnostics in skpro/datatypes/_convert.py. Previously, when a conversion between two mtypes was not defined, the error message was: "No conversion defined from type X to Y" This message did not provide enough context to debug conversion failures.

This PR improves the error message by including:

  • the source mtype (from_type)
  • the target mtype (to_type)
  • the object type
  • the list of available conversions

This helps developers debug datatype conversion issues more easily.

Does your contribution introduce a new dependency? If yes, which one?

No new dependencies are introduced.

What should a reviewer concentrate their feedback on?

  • Whether the improved error message provides useful debugging information
  • Whether the formatting of the error message follows project conventions
  • Whether exposing available conversions in the error message is acceptable

Did you add any tests for the change?

No new tests were added since this change only improves the diagnostic message and does not modify functionality.
All existing tests pass successfully.

Any other comments?

This change is intended to improve developer experience when debugging conversion failures in the datatype conversion framework.

PR checklist

For all contributions
  • [x] I've added myself to the list of contributors with any new badges I've earned :-)
  • [x] The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • [ ] I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • [ ] I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • [ ] If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured dependency isolation.

mohityadav8 avatar Mar 04 '26 20:03 mohityadav8

Hi maintainers, This PR improves the error diagnostics when a conversion between mtypes is not defined in convert().

It provides additional context including:

  • source mtype
  • target mtype
  • object type
  • available conversions

Please let me know if any changes are needed. Thank you!

mohityadav8 avatar Mar 04 '26 21:03 mohityadav8

Hi @felipeangelimvieira and @fkiraly It looks like the workflows are awaiting maintainer approval and the PR also requires a code owner review. Could you please approve the workflows and review the PR when convenient? Thanks!

mohityadav8 avatar Mar 07 '26 14:03 mohityadav8

Hi @felipeangelimvieira and @fkiraly, Just a gentle follow-up on this PR. It improves the error diagnostics when a conversion between mtypes is not defined. It looks like the ReadTheDocs check failed automatically, but the change only modifies the error message in convert() and does not affect documentation. Could you please review the PR when you have time? Thank you!

mohityadav8 avatar Mar 08 '26 18:03 mohityadav8

Hello @mohityadav8 ! Sorry for the delay. It seems that the code has a indentation issue. Can you also add a simple test to check if the error is correctly shown?

felipeangelimvieira avatar Mar 12 '26 10:03 felipeangelimvieira

Hi @felipeangelimvieira and @fkiraly It looks like the workflows are awaiting maintainer approval and the PR also requires a code owner review. Could you please approve the workflows and review the PR when convenient? Thanks!

mohityadav8 avatar Mar 23 '26 07:03 mohityadav8