@@ -24,6 +24,7 @@ import scala.collection.JavaConverters._
2424import scala .reflect .ClassTag
2525
2626import org .apache .spark ._
27+ import org .apache .spark .api .conda .CondaEnvironment .CondaSetupInstructions
2728import org .apache .spark .api .java .{JavaPairRDD , JavaRDD , JavaSparkContext }
2829import org .apache .spark .api .python .PythonRDD
2930import org .apache .spark .broadcast .Broadcast
@@ -39,11 +40,17 @@ private abstract class BaseRRDD[T: ClassTag, U: ClassTag](
3940 packageNames : Array [Byte ],
4041 broadcastVars : Array [Broadcast [Object ]])
4142 extends RDD [U ](parent) with Logging {
43+
44+ /**
45+ * Get the conda instructions eagerly - when the RDD is created.
46+ */
47+ val condaInstructions : Option [CondaSetupInstructions ] = context.buildCondaInstructions()
48+
4249 override def getPartitions : Array [Partition ] = parent.partitions
4350
4451 override def compute (partition : Partition , context : TaskContext ): Iterator [U ] = {
4552 val runner = new RRunner [U ](
46- func, deserializer, serializer, packageNames, broadcastVars, numPartitions)
53+ func, deserializer, serializer, packageNames, broadcastVars, condaInstructions, numPartitions)
4754
4855 // The parent may be also an RRDD, so we should launch it first.
4956 val parentIterator = firstParent[T ].iterator(partition, context)
@@ -79,6 +86,7 @@ private class RRDD[T: ClassTag](
7986 deserializer : String ,
8087 serializer : String ,
8188 packageNames : Array [Byte ],
89+ condaSetupInstructions : Option [CondaSetupInstructions ],
8290 broadcastVars : Array [Object ])
8391 extends BaseRRDD [T , Array [Byte ]](
8492 parent, - 1 , func, deserializer, serializer, packageNames,
@@ -94,6 +102,7 @@ private class StringRRDD[T: ClassTag](
94102 func : Array [Byte ],
95103 deserializer : String ,
96104 packageNames : Array [Byte ],
105+ condaSetupInstructions : Option [CondaSetupInstructions ],
97106 broadcastVars : Array [Object ])
98107 extends BaseRRDD [T , String ](
99108 parent, - 1 , func, deserializer, SerializationFormats .STRING , packageNames,
0 commit comments