@@ -20,7 +20,7 @@ import java.nio.file.Files
20
20
import java .nio .file .Path
21
21
import java .nio .file .Paths
22
22
import java .nio .file .attribute .PosixFilePermission
23
- import java .util .concurrent .locks .{ Lock , ReentrantLock }
23
+ import java .util .concurrent .locks .ReentrantLock
24
24
import java .util .regex .Pattern
25
25
26
26
import scala .collection .JavaConverters ._
@@ -213,8 +213,9 @@ object CondaEnvironmentManager extends Logging {
213
213
private [this ] val httpUrlToken =
214
214
Pattern .compile(" (\\ b\\ w+://[^:/@]*:)([^/@]+)(?=@([\\ w-.]+)(:\\ d+)?\\ b)" )
215
215
216
- private val initializedEnvironmentsLock = new ReentrantLock ()
217
- private val initializedEnvironments = mutable.HashMap [CondaSetupInstructions , CondaEnvironment ]()
216
+ private [this ] val initializedEnvironmentsLock = new ReentrantLock ()
217
+ private [this ] val initializedEnvironments =
218
+ mutable.HashMap [CondaSetupInstructions , CondaEnvironment ]()
218
219
219
220
private [conda] def redactCredentials (line : String ): String = {
220
221
httpUrlToken.matcher(line).replaceAll(" $1<password>" )
@@ -228,11 +229,8 @@ object CondaEnvironmentManager extends Logging {
228
229
new CondaEnvironmentManager (condaBinaryPath, verbosity, packageDirs)
229
230
}
230
231
231
- /**
232
- * Helper method to create a conda environment from [[CondaEnvironment.CondaSetupInstructions ]].
233
- * This is intended to be called on the executor with serialized instructions.
234
- */
235
- def createCondaEnvironment (instructions : CondaSetupInstructions ): CondaEnvironment = {
232
+ private [this ] def createCondaEnvironment (
233
+ instructions : CondaSetupInstructions ): CondaEnvironment = {
236
234
val condaPackages = instructions.packages
237
235
val env = SparkEnv .get
238
236
val condaEnvManager = CondaEnvironmentManager .fromConf(env.conf)
@@ -247,9 +245,10 @@ object CondaEnvironmentManager extends Logging {
247
245
}
248
246
249
247
/**
250
- * Helper method that will cache precreated conda environments.
248
+ * Gets the conda environment for [[CondaEnvironment.CondaSetupInstructions ]]. This will create
249
+ * a new one if none exists.
251
250
*/
252
- def createOrGetCondaEnvironment (instructions : CondaSetupInstructions ): CondaEnvironment = {
251
+ def getOrCreateCondaEnvironment (instructions : CondaSetupInstructions ): CondaEnvironment = {
253
252
initializedEnvironmentsLock.lock()
254
253
try {
255
254
initializedEnvironments.get(instructions) match {
0 commit comments