Skip to content

fix: companionModelClassName no longer returns generic type variable - #2195

Merged
Mark Hamilton (mhamilton723) merged 6 commits into
microsoft:masterfrom
BrendanWalsh:pygen
Apr 9, 2024
Merged

fix: companionModelClassName no longer returns generic type variable#2195
Mark Hamilton (mhamilton723) merged 6 commits into
microsoft:masterfrom
BrendanWalsh:pygen

Conversation

@BrendanWalsh

Copy link
Copy Markdown
Collaborator

This commit addresses an issue in the companionModelClassName method where the resolution of the companion model's class name was not accurately reflecting the intended Python package path for Regression models.

"from M import M", where M is the name of MLLib's Regressor class' concrete model type parameter:
https://github.com/apache/spark/blob/45ba9224602eb18fe45e339cbb8cf2e8a4924f0b/mllib/src/main/scala/org/apache/spark/ml/regression/Regressor.scala#L28

Implemented reflection with scala.reflect.runtime.universe._ to accurately access and utilize type information at runtime, overcoming Scala's type erasure limitations.

Tested against the existing method for all wrappable classes and found the only divergence to be the instance where it fixed the broken wrapped regressor. Added a regression test for this scenario.

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Apr 9, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 92.85714% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 83.59%. Comparing base (ca747bb) to head (0e9c0e6).

Files Patch % Lines
.../azure/synapse/ml/core/utils/JarLoadingUtils.scala 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2195      +/-   ##
==========================================
- Coverage   85.91%   83.59%   -2.33%     
==========================================
  Files         329      329              
  Lines       17086    17089       +3     
  Branches     1515     1523       +8     
==========================================
- Hits        14680    14285     -395     
- Misses       2406     2804     +398     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BrendanWalsh

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

override val uid: String = "test"
}

private[codegen] class TestRegressor extends Regressor[Vector, TestRegressor, TestRegressorModel] with Wrappable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

will this end up in the python bindings?

@mhamilton723
Mark Hamilton (mhamilton723) merged commit 50c7f1e into microsoft:master Apr 9, 2024
Rana Singh (ranadeepsingh) pushed a commit to ranadeepsingh/SynapseML that referenced this pull request Aug 7, 2026
## Summary
Update the previously dormant Wrappable companion-model test to expect the actual top-level TestRegressorModel name and remove imports left behind when the fixture moved to its own source file.

## Prompting Intent
Prepare PR microsoft#2590 for merge by diagnosing and fixing its Azure core-unit failure after codegen tests were added to the normal PR shard. Keep the correction narrow and preserve the PR's goal of making all code generation behavior continuously validated.

## Linked Sources
- Pull request: microsoft#2590
- Failed Azure build: https://msdata.visualstudio.com/b9b2accc-2d1c-45b3-9d24-0eb5d78cc47f/_build/results?buildId=230147126
- Original companion-model fix: microsoft#2195

## Rationale
The fixture has been a package-level class since microsoft#2195, so Scala reflection correctly returns com.microsoft.azure.synapse.ml.codegen.TestRegressorModel. The obsolete nested-class expectation went unnoticed because the codegen package was not part of the core CI shard. Correcting the assertion is preferable to excluding the suite or changing production reflection logic that already returns the right public class name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 81d39bfc-927c-418a-90a8-e0f2cd8fc128
Rana Singh (ranadeepsingh) pushed a commit to ranadeepsingh/SynapseML that referenced this pull request Aug 7, 2026
## Summary
Limit the dormant Wrappable test correction to the stale expected class name, retaining the surrounding release-branch source shape so the already-equivalent Spark 4.1 change merges without conflict.

## Prompting Intent
Prepare PR microsoft#2590 for merge after Azure confirmed that its product and codegen changes replayed onto Spark 4.1 but the broader test cleanup conflicted with an equivalent release-branch assertion fix. Preserve the corrected master test while keeping the compatibility patch minimal.

## Linked Sources
- Pull request: microsoft#2590
- Failed release replay: https://msdata.visualstudio.com/b9b2accc-2d1c-45b3-9d24-0eb5d78cc47f/_build/results?buildId=230156549
- Original companion-model fix: microsoft#2195

## Rationale
Spark 4.1 already expects the top-level TestRegressorModel name. Reverting unrelated import and formatting cleanup leaves a one-line semantic correction whose three-way merge recognizes that identical release change, while continuing to make the newly enabled master test pass. This avoids adding release-specific exclusions or weakening codegen CI coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 81d39bfc-927c-418a-90a8-e0f2cd8fc128
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.

3 participants