@@ -497,7 +497,7 @@ def _write_imports(
497
497
import codecs
498
498
499
499
binary_string = "<binary string>"
500
- model = pickle.load (codecs.decode(binary_string.encode(), "base64"))
500
+ model = pickle.loads (codecs.decode(binary_string.encode(), "base64"))
501
501
"""
502
502
503
503
def _viya35_model_load (
@@ -562,6 +562,26 @@ def _viya35_model_load(
562
562
f'{ model_id } /{ model_file_name } ")))'
563
563
)
564
564
else :
565
+ if pickle_type .lower () == 'pickle' :
566
+ self .score_code += (
567
+ f'model_path = Path("/models/resources/viya/{ model_id } '
568
+ f'")\n with open(model_path / "{ model_file_name } ", '
569
+ f"\" rb\" ) as pickle_model:\n { '' :4} model = pd.read_pickle"
570
+ "(pickle_model)\n \n "
571
+ )
572
+ """
573
+ model_path = Path("/models/resources/viya/<UUID>")
574
+ with open(model_path / "model.pickle", "rb") as pickle_model:
575
+ model = pd.read_pickle(pickle_model)
576
+
577
+ """
578
+ return (
579
+ f"{ '' :8} model_path = Path(\" /models/resources/viya/{ model_id } "
580
+ f"\" )\n { '' :8} with open(model_path / \" { model_file_name } \" , "
581
+ f"\" rb\" ) as pickle_model:\n { '' :12} model = pd.read_pickle"
582
+ "(pickle_model)"
583
+ )
584
+
565
585
self .score_code += (
566
586
f'model_path = Path("/models/resources/viya/{ model_id } '
567
587
f'")\n with open(model_path / "{ model_file_name } ", '
@@ -658,6 +678,23 @@ def _viya4_model_load(
658
678
f"safe_mode=True)\n "
659
679
)
660
680
else :
681
+ if pickle_type .lower () == "pickle" :
682
+ self .score_code += (
683
+ f"with open(Path(settings.pickle_path) / "
684
+ f'"{ model_file_name } ", "rb") as pickle_model:\n '
685
+ f"{ '' :4} model = pd.read_pickle(pickle_model)\n \n "
686
+ )
687
+ """
688
+ with open(Path(settings.pickle_path) / "model.pickle", "rb") as pickle_model:
689
+ model = pd.read_pickle(pickle_model)
690
+
691
+ """
692
+ return (
693
+ f"{ '' :8} with open(Path(settings.pickle_path) / "
694
+ f'"{ model_file_name } ", "rb") as pickle_model:\n '
695
+ f"{ '' :12} model = pd.read_pickle(pickle_model)\n \n "
696
+ )
697
+
661
698
self .score_code += (
662
699
f"with open(Path(settings.pickle_path) / "
663
700
f'"{ model_file_name } ", "rb") as pickle_model:\n '
0 commit comments