Skip to content

Commit d34af15

Browse files
committed
[SPARKNLP-1011] Adding unique suffix to avoid duplication in spark files
1 parent c9380c6 commit d34af15

25 files changed

+24
-48
lines changed

src/main/scala/com/johnsnowlabs/ml/onnx/OnnxWrapper.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ object OnnxWrapper {
9999
}
100100
}
101101

102-
// TODO: the parts related to onnx_data should be refactored once we support addFile()
103102
def read(
104103
sparkSession: SparkSession,
105104
modelPath: String,
@@ -108,7 +107,6 @@ object OnnxWrapper {
108107
modelName: String = "model",
109108
dataFileSuffix: Option[String] = Some("_data"),
110109
onnxFileSuffix: Option[String] = None): OnnxWrapper = {
111-
// TODO: onnxFileSuffix default none??
112110
// 1. Create tmp folder
113111
val tmpFolder = Files
114112
.createTempDirectory(UUID.randomUUID().toString.takeRight(12) + "_onnx")
@@ -136,7 +134,6 @@ object OnnxWrapper {
136134
if (onnxFileSuffix.isDefined && dataFileSuffix.isDefined) {
137135
val onnxDataFilePath = s"${onnxFileSuffix.get}_$modelName${dataFileSuffix.get}"
138136
onnxDataFile = Paths.get(parentDir, onnxDataFilePath).toFile
139-
// TODO: Here is the error it does not exist
140137
onnxDataFile.exists()
141138
} else false
142139
}

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/AlbertForQuestionAnswering.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,7 @@ trait ReadAlbertForQuestionAnsweringDLModel
328328
instance.setModelIfNotSet(spark, Some(tf), None, spp)
329329
case ONNX.name =>
330330
val onnxWrapper =
331-
readOnnxModel(
332-
path,
333-
spark,
334-
"_albert_classification_onnx",
335-
zipped = true,
336-
useBundle = false)
331+
readOnnxModel(path, spark, "albert_qa_classification_onnx")
337332
instance.setModelIfNotSet(spark, None, Some(onnxWrapper), spp)
338333
case _ =>
339334
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/AlbertForSequenceClassification.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,7 @@ trait ReadAlbertForSequenceDLModel
382382
instance.setModelIfNotSet(spark, Some(tf), None, spp)
383383
case ONNX.name =>
384384
val onnxWrapper =
385-
readOnnxModel(
386-
path,
387-
spark,
388-
"_albert_classification_onnx",
389-
zipped = true,
390-
useBundle = false)
385+
readOnnxModel(path, spark, "albert_sequence_classification_onnx")
391386
instance.setModelIfNotSet(spark, None, Some(onnxWrapper), spp)
392387
case _ =>
393388
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/AlbertForTokenClassification.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ trait ReadAlbertForTokenDLModel
353353
instance.setModelIfNotSet(spark, Some(tfWrapper), None, spp)
354354
case ONNX.name =>
355355
val onnxWrapper =
356-
readOnnxModel(
357-
path,
358-
spark,
359-
"_albert_classification_onnx",
360-
zipped = true,
361-
useBundle = false)
356+
readOnnxModel(path, spark, "albert_token_classification_onnx")
362357
instance.setModelIfNotSet(spark, None, Some(onnxWrapper), spp)
363358
case _ =>
364359
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/BertForQuestionAnswering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ trait ReadBertForQuestionAnsweringDLModel extends ReadTensorflowModel with ReadO
330330
instance.setModelIfNotSet(spark, Some(tensorFlow), None)
331331
case ONNX.name =>
332332
val onnxWrapper =
333-
readOnnxModel(path, spark, "_bert_classification_onnx")
333+
readOnnxModel(path, spark, "bert_qa_classification_onnx")
334334
instance.setModelIfNotSet(spark, None, Some(onnxWrapper))
335335
case _ =>
336336
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/BertForSequenceClassification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ trait ReadBertForSequenceDLModel extends ReadTensorflowModel with ReadOnnxModel
384384
instance.setModelIfNotSet(spark, Some(tensorFlow), None)
385385
case ONNX.name =>
386386
val onnxWrapper =
387-
readOnnxModel(path, spark, "_bert_classification_onnx")
387+
readOnnxModel(path, spark, "bert_sequence_classification_onnx")
388388
instance.setModelIfNotSet(spark, None, Some(onnxWrapper))
389389
case _ =>
390390
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/BertForTokenClassification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ trait ReadBertForTokenDLModel extends ReadTensorflowModel with ReadOnnxModel {
350350
instance.setModelIfNotSet(spark, Some(tensorFlow), None)
351351
case ONNX.name =>
352352
val onnxWrapper =
353-
readOnnxModel(path, spark, "_bert_classification_onnx")
353+
readOnnxModel(path, spark, "bert_token_classification_onnx")
354354
instance.setModelIfNotSet(spark, None, Some(onnxWrapper))
355355
case _ =>
356356
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/BertForZeroShotClassification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ trait ReadBertForZeroShotDLModel extends ReadTensorflowModel with ReadOnnxModel
400400
instance.setModelIfNotSet(spark, Some(tensorFlow), None)
401401
case ONNX.name =>
402402
val onnxWrapper =
403-
readOnnxModel(path, spark, "_bert_classification_onnx")
403+
readOnnxModel(path, spark, "bert_zs_classification_onnx")
404404
instance.setModelIfNotSet(spark, None, Some(onnxWrapper))
405405
case _ =>
406406
throw new Exception(notSupportedEngineError)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/CamemBertForQuestionAnswering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ trait ReadCamemBertForQADLModel
336336
readOnnxModel(
337337
path,
338338
spark,
339-
"_camembert_classification_onnx",
339+
"camembert_qa_classification_onnx",
340340
zipped = true,
341341
useBundle = false,
342342
None)

src/main/scala/com/johnsnowlabs/nlp/annotators/classifier/dl/CamemBertForSequenceClassification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ trait ReadCamemBertForSequenceDLModel
388388
readOnnxModel(
389389
path,
390390
spark,
391-
"_camembert_classification_onnx",
391+
"camembert_sequence_classification_onnx",
392392
zipped = true,
393393
useBundle = false,
394394
None)

0 commit comments

Comments
 (0)