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

Make Sparkey testable #5128

Merged
merged 13 commits into from
Jan 11, 2024
Merged

Make Sparkey testable #5128

merged 13 commits into from
Jan 11, 2024

Conversation

kellen
Copy link
Contributor

@kellen kellen commented Dec 20, 2023

Adds SparkeyIO, a TestIO (rather than full-fledged ScioIO). Deprecates sideinput map.

Suggestions around naming the output Sparkey IO, currently SparkeyIO.output[K, V], are welcome as this feels awkward. An alternative is to use SparkeyIOOutput[K, V] directly, but this is also ugly.

Instead of #3172

Fixes #3173
Fixes #4819

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Attention: 37 lines in your changes are missing coverage. Please review.

Comparison is base (11ed971) 63.34% compared to head (b011c4f) 63.42%.
Report is 6 commits behind head on main.

❗ Current head b011c4f differs from pull request most recent head 300958a. Consider uploading reports for the commit 300958a to get more accurate results

Files Patch % Lines
...io/extra/sparkey/instances/MockSparkeyReader.scala 16.12% 26 Missing ⚠️
...scala/com/spotify/scio/extra/sparkey/package.scala 80.95% 8 Missing ⚠️
...ala/com/spotify/scio/extra/sparkey/SparkeyIO.scala 94.91% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5128      +/-   ##
==========================================
+ Coverage   63.34%   63.42%   +0.08%     
==========================================
  Files         291      293       +2     
  Lines       10837    10902      +65     
  Branches      753      716      -37     
==========================================
+ Hits         6865     6915      +50     
- Misses       3972     3987      +15     

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

@kellen kellen requested a review from RustedBones December 20, 2023 15:14
@@ -127,6 +128,7 @@ private[values] class MultiMapSideInput[K, V](val view: PCollectionView[JMap[K,
JMapWrapper.ofMultiMap(context.sideInput(view))
}

@deprecated(since = "0.14.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we include a deprecation message advising users what methods to use instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No this is just a pure "don't do this"

val input = Map("a" -> "b", "c" -> "d")
JobTest[SparkeyJob.type]
.args("--input=foo", "--output1=bar", "--output2=baz")
.input(SparkeyIO("foo"), Seq(MockStringSparkeyReader(input)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we instead have SparkeyIO expect a Map[K, V] (or Seq[(K, V)]) instead of a reader ? We would create the reader in the IO after isTest is checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this initially; the type parameter on ScioIO has to match the type of the mock data iterable passed to input, then in the internals of JobTest the SCollection returned must also be of the same type, so without changing the contract of ScioIO I don't think this is possible

@kellen kellen merged commit 6b93359 into main Jan 11, 2024
11 checks passed
@kellen kellen deleted the kellen/sparkeyio branch January 11, 2024 16:16
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.

map on SideInput is a terrible idea and should be deprecated. Support sparkey in JobTest
3 participants