-
Notifications
You must be signed in to change notification settings - Fork 45
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
Attempting to shade scala-logging dependency #293
Comments
@echeipesh Note: I've not tried to run against Spark 2.4.x. So maybe there's something wrong there. I wonder if some of this has to do with Scala logging using macros? Maybe an argument to get rid of it, and just use Java APIs? If you're willing to try something, find any places where a |
@echeipesh Also, what version of Java is that running under? |
I would say that figuring out how to shade this dependency would be enough. |
@metasim This is all on Java 1.8 diff --git a/core/src/main/scala/org/locationtech/rasterframes/rasterframes.scala b/core/src/main/scala/org/locationtech/rasterframes/rasterframes.scala
index 1517e8f0..2b908c7f 100644
--- a/core/src/main/scala/org/locationtech/rasterframes/rasterframes.scala
+++ b/core/src/main/scala/org/locationtech/rasterframes/rasterframes.scala
@@ -21,7 +21,7 @@
package org.locationtech
import com.typesafe.config.ConfigFactory
-import com.typesafe.scalalogging.LazyLogging
+import com.typesafe.scalalogging.Logger
import geotrellis.raster.isData
import geotrellis.raster.{Tile, TileFeature}
import geotrellis.spark.{ContextRDD, Metadata, SpaceTimeKey, SpatialKey, TileLayerMetadata}
@@ -33,6 +33,7 @@ import org.locationtech.rasterframes.encoders.StandardEncoders
import org.locationtech.rasterframes.extensions.Implicits
import org.locationtech.rasterframes.model.TileDimensions
import org.locationtech.rasterframes.util.ZeroSevenCompatibilityKit
+import org.slf4j.LoggerFactory
import shapeless.tag.@@
import scala.reflect.runtime.universe._
@@ -43,8 +44,10 @@ package object rasterframes extends StandardColumns
with Implicits
with rasterframes.jts.Implicits
with StandardEncoders
- with DataFrameFunctions.Library
- with LazyLogging {
+ with DataFrameFunctions.Library {
+
+ @transient
+ protected lazy val logger: Logger = Logger(LoggerFactory.getLogger(getClass.getName))
@transient
private[rasterframes] I have not tested it on DataBricks yet, but this produces an assembly where the imports of RasterFrame packages happens fine. I'll keep you posted. |
Reproduced. I'll go ahead and fix this and any similar cases. |
A bit further, but serialization error (despite $ spark-shell --jars /Users/sfitch/Coding/OSS/locationtech-rasterframes/pyrasterframes/target/scala-2.11/pyrasterframes-assembly-0.8.1-SNAPSHOT.jar
...
Spark context available as 'sc' (master = local[*], app id = local-1566321608265).
Spark session available as 'spark'.
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 2.3.3
/_/
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_171)
Type in expressions to have them evaluated.
Type :help for more information.
scala> import org.locationtech.rasterframes._
import org.locationtech.rasterframes._
scala> import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.datasource.raster._
scala> val rf = spark.read.raster.load("https://s22s-test-geotiffs.s3.amazonaws.com/luray_snp/B02.tif")
java.lang.AssertionError: assertion failed: unsafe symbol Logger (child of package scalalogging) in runtime reflection universe
at scala.reflect.internal.Symbols$Symbol.<init>(Symbols.scala:184)
at scala.reflect.internal.Symbols$TypeSymbol.<init>(Symbols.scala:3009)
at scala.reflect.internal.Symbols$ClassSymbol.<init>(Symbols.scala:3201)
at scala.reflect.internal.Symbols$StubClassSymbol.<init>(Symbols.scala:3496)
at scala.reflect.internal.Symbols$Symbol.newStubSymbol(Symbols.scala:498)
at scala.reflect.internal.pickling.UnPickler$Scan.readExtSymbol$1(UnPickler
... |
Calling |
Caught the exception in the debugger after commenting out RF code triggering the Found this message on the stack in a frame further up, which makes me wonder if shading did't transform all references in all libraries:
|
Ran $ javap -cp /Users/sfitch/Coding/OSS/locationtech-rasterframes/pyrasterframes/target/scala-2.11/pyrasterframes-assembly-0.8.1-SNAPSHOT.jar geotrellis.raster.Tile | grep scalalogging
public interface geotrellis.raster.Tile extends geotrellis.raster.CellGrid, geotrellis.raster.IterableTile, geotrellis.raster.MappableTile<geotrellis.raster.Tile>, rf.shaded.com.typesafe.scalalogging.LazyLogging { and in the
and both show all references as having been shaded. :-/ |
I think the problem might have something to do with Spark making heavy use of Scala |
@echeipesh I'm worried that this problem isn't solvable without removing https://stackoverflow.com/a/40404371/296509 I'm not a fan because it means RasterFrames is essentially requiring an isolated version of GeoTrellis that has scalalogging shaded for it before its used by RasterFrames. |
… the trait hierachy. See issue for specifics on why this didn't work.
Branch with moving |
Reworking of logging usage to fix #293
* develop: Fixed image link in README.md PR feedback. Removed `GeoTiffCollectionRelation` due to usage limitation and overlap with `RasterSourceDataSource` functionality. Bump pytest to 4.x series In rf_ipython, honor users pandas max_colwidth on Geometry objects Additional python version wrangling. merge pyspark-notebook:spark-2.3.4-hadoop-2.7 Dockerfile into this one Dropping pandas version requirement. Updated requirements.txt for Spark. Fixes to `UserDefinedAggregateFunction` implementations so they run in the Databricks environment. Not sure what the cause is, but this change set seems to fix it. Added shading of Typesafe config. Upgraded to Spark 2.4.4 Bumped dev version. Set release version. Reworking of logging usage to fix locationtech#293 Eyecandy for index page. Bumping pytest version. Added liblzma-dev to build environment.
This issue was encountered while we were attempting to shade the
com.typesafe.scala-logging
classes in an effort to get RasterFrames running in DataBricks environment. DataBricks itself brings inscom.typesafe.scala-logging
version2.1.2
on the class path which is not binary compatible with version3.9.0
used by RasterFrames and will result inInstantiationException
Reproduce
The failure to shade can be reproduced locally and shows ups as a failed import.
The attempt is done against current
develop
by trying to hook into the mechanism inRFAssemblyPlugin
Then creating assembly using:
sbt 'project pyrasterframes' assembly
Inspecting the assembly jar we see the shading took effect:
Trying to use the assembly goes south:
Trying to see what is going on in
package org.locationtech.rasterframes.package
everything seems hunky-dory:Note that it implements the shaded version
rf.shaded.com.typesafe.scalalogging.LazyLogging
The text was updated successfully, but these errors were encountered: