@@ -177,7 +177,6 @@ def write_score_code(
177
177
pickle_type ,
178
178
mojo_model = "mojo_model" in kwargs ,
179
179
binary_h2o_model = "binary_h2o_model" in kwargs ,
180
- pytorch_model = "pytorch_model" in kwargs ,
181
180
tf_model = "tf_keras_model" in kwargs or "tf_core_model" in kwargs ,
182
181
binary_string = binary_string ,
183
182
)
@@ -189,7 +188,6 @@ def write_score_code(
189
188
model_file_name ,
190
189
pickle_type = pickle_type ,
191
190
mojo_model = "mojo_model" in kwargs ,
192
- pytorch_model = "pytorch_model" in kwargs ,
193
191
binary_h2o_model = "binary_h2o_model" in kwargs ,
194
192
)
195
193
# As above, but for SAS Viya 4 models
@@ -199,7 +197,6 @@ def write_score_code(
199
197
pickle_type = pickle_type ,
200
198
mojo_model = "mojo_model" in kwargs ,
201
199
binary_h2o_model = "binary_h2o_model" in kwargs ,
202
- pytorch_model = "pytorch_model" in kwargs ,
203
200
tf_keras_model = "tf_keras_model" in kwargs ,
204
201
tf_core_model = "tf_core_model" in kwargs ,
205
202
)
@@ -408,7 +405,6 @@ def _write_imports(
408
405
mojo_model : Optional [bool ] = False ,
409
406
binary_h2o_model : Optional [bool ] = False ,
410
407
tf_model : Optional [bool ] = False ,
411
- pytorch_model : Optional [bool ] = False ,
412
408
binary_string : Optional [str ] = None ,
413
409
) -> None :
414
410
"""
@@ -431,9 +427,6 @@ def _write_imports(
431
427
tf_model : bool, optional
432
428
Flag to indicate that the model is a tensorflow model. The default value
433
429
is None.
434
- pytorch_model : bool, optional
435
- Flag to indicate that the model is a pytorch model. The default value
436
- is None.
437
430
binary_string : str, optional
438
431
A binary representation of the Python model object. The default value is
439
432
None.
@@ -482,29 +475,14 @@ def _write_imports(
482
475
import tensorflow as tf
483
476
484
477
"""
485
- elif pytorch_model :
486
- cls .score_code += "import math\n import torch\n import pandas as pd\n import numpy as np\n from pathlib import Path\n \n "
487
- elif binary_string :
488
- cls .score_code += (
489
- f'import codecs\n \n binary_string = "{ binary_string } "'
490
- f"\n model = { pickle_type } .loads(codecs.decode(binary_string"
491
- '.encode(), "base64"))\n \n '
492
- )
493
- """
494
- import codecs
495
478
496
- binary_string = "<binary string>"
497
- model = pickle.load(codecs.decode(binary_string.encode(), "base64"))
498
-
499
- """
500
479
501
480
@classmethod
502
481
def _viya35_model_load (
503
482
cls ,
504
483
model_id : str ,
505
484
model_file_name : str ,
506
485
pickle_type : Optional [str ] = None ,
507
- pytorch_model : Optional [str ] = None ,
508
486
mojo_model : Optional [bool ] = False ,
509
487
binary_h2o_model : Optional [bool ] = False ,
510
488
) -> str :
@@ -561,15 +539,6 @@ def _viya35_model_load(
561
539
f"{ '' :8} model = h2o.load(str(Path(\" /models/resources/viya/"
562
540
f'{ model_id } /{ model_file_name } ")))'
563
541
)
564
- elif pytorch_model :
565
- cls .score_code += (
566
- f'model = torch.load("/models/resources/viya/{ model_id } /" + '
567
- f"{ model_file_name } )\n \n "
568
- )
569
- return (
570
- f"{ '' :8} model = torch.load(\" /models/resources/viya/{ model_id } /\" + "
571
- f"{ model_file_name } )\n \n "
572
- )
573
542
else :
574
543
cls .score_code += (
575
544
f'model_path = Path("/models/resources/viya/{ model_id } '
@@ -597,7 +566,6 @@ def _viya4_model_load(
597
566
pickle_type : Optional [str ] = None ,
598
567
mojo_model : Optional [bool ] = False ,
599
568
binary_h2o_model : Optional [bool ] = False ,
600
- pytorch_model : Optional [bool ] = False ,
601
569
tf_keras_model : Optional [bool ] = False ,
602
570
tf_core_model : Optional [bool ] = False ,
603
571
) -> str :
@@ -618,9 +586,6 @@ def _viya4_model_load(
618
586
binary_h2o_model : boolean, optional
619
587
Flag to indicate that the model is a H2O.ai binary model. The default value
620
588
is None.
621
- pytorch_model : boolean, optional
622
- Flag to indicate that the model is a pytorch model. The default value
623
- is None.
624
589
tf_keras_model : boolean, optional
625
590
Flag to indicate that the model is a tensorflow keras model. The default
626
591
value is False.
@@ -656,15 +621,6 @@ def _viya4_model_load(
656
621
f"{ '' :8} model = h2o.load(str(Path(settings.pickle_path) / "
657
622
f"{ model_file_name } ))\n \n "
658
623
)
659
- elif pytorch_model :
660
- cls .score_code += (
661
- f"model = torch.load(Path(settings.pickle_path) / "
662
- f"{ model_file_name } )\n \n "
663
- )
664
- return (
665
- f"{ '' :8} model = torch.load(Path(settings.pickle_path) / "
666
- f"{ model_file_name } )\n \n "
667
- )
668
624
elif tf_keras_model :
669
625
cls .score_code += (
670
626
f"model = tf.keras.models.load_model(Path(settings.pickle_path) / "
0 commit comments