Skip to content

Commit 28a3e22

Browse files
committed
Moved pytorch changes to pytorch_models to allow for release prep
1 parent 1018767 commit 28a3e22

File tree

3 files changed

+0
-55
lines changed

3 files changed

+0
-55
lines changed

src/sasctl/pzmm/write_json_files.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ def write_file_metadata_json(
470470
model_prefix: str,
471471
json_path: Union[str, Path, None] = None,
472472
is_h2o_model: Optional[bool] = False,
473-
is_pytorch_model: Optional[bool] = False,
474473
is_tf_keras_model: Optional[bool] = False,
475474
) -> Union[dict, None]:
476475
"""
@@ -490,10 +489,6 @@ def write_file_metadata_json(
490489
Sets whether the model metadata is associated with an H2O.ai model. If set
491490
as True, the MOJO model file will be set as a score resource. The default
492491
value is False.
493-
is_pytorch_model : bool, optional
494-
Sets whether the model metadata is associated with an H2O.ai model. If set
495-
as True, the .pth file will be set as a score resource. The default
496-
value is False.
497492
498493
Returns
499494
-------
@@ -510,9 +505,6 @@ def write_file_metadata_json(
510505
dict_list.append({"role": "scoreResource", "name": model_prefix + ".mojo"})
511506
elif is_tf_keras_model:
512507
dict_list.append({"role": "scoreResource", "name": model_prefix + ".h5"})
513-
# conditions added for pytorch.
514-
elif is_pytorch_model:
515-
dict_list.append(({"role": "scoreResource", "name": model_prefix + ".pth"}))
516508
else:
517509
dict_list.append(
518510
{"role": "scoreResource", "name": model_prefix + ".pickle"}

src/sasctl/pzmm/write_score_code.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def write_score_code(
177177
pickle_type,
178178
mojo_model="mojo_model" in kwargs,
179179
binary_h2o_model="binary_h2o_model" in kwargs,
180-
pytorch_model="pytorch_model" in kwargs,
181180
tf_model="tf_keras_model" in kwargs or "tf_core_model" in kwargs,
182181
binary_string=binary_string,
183182
)
@@ -189,7 +188,6 @@ def write_score_code(
189188
model_file_name,
190189
pickle_type=pickle_type,
191190
mojo_model="mojo_model" in kwargs,
192-
pytorch_model="pytorch_model" in kwargs,
193191
binary_h2o_model="binary_h2o_model" in kwargs,
194192
)
195193
# As above, but for SAS Viya 4 models
@@ -199,7 +197,6 @@ def write_score_code(
199197
pickle_type=pickle_type,
200198
mojo_model="mojo_model" in kwargs,
201199
binary_h2o_model="binary_h2o_model" in kwargs,
202-
pytorch_model="pytorch_model" in kwargs,
203200
tf_keras_model="tf_keras_model" in kwargs,
204201
tf_core_model="tf_core_model" in kwargs,
205202
)
@@ -408,7 +405,6 @@ def _write_imports(
408405
mojo_model: Optional[bool] = False,
409406
binary_h2o_model: Optional[bool] = False,
410407
tf_model: Optional[bool] = False,
411-
pytorch_model: Optional[bool] = False,
412408
binary_string: Optional[str] = None,
413409
) -> None:
414410
"""
@@ -431,9 +427,6 @@ def _write_imports(
431427
tf_model : bool, optional
432428
Flag to indicate that the model is a tensorflow model. The default value
433429
is None.
434-
pytorch_model : bool, optional
435-
Flag to indicate that the model is a pytorch model. The default value
436-
is None.
437430
binary_string : str, optional
438431
A binary representation of the Python model object. The default value is
439432
None.
@@ -482,29 +475,14 @@ def _write_imports(
482475
import tensorflow as tf
483476
484477
"""
485-
elif pytorch_model:
486-
cls.score_code += "import math\nimport torch\nimport pandas as pd\nimport numpy as np\nfrom pathlib import Path\n\n"
487-
elif binary_string:
488-
cls.score_code += (
489-
f'import codecs\n\nbinary_string = "{binary_string}"'
490-
f"\nmodel = {pickle_type}.loads(codecs.decode(binary_string"
491-
'.encode(), "base64"))\n\n'
492-
)
493-
"""
494-
import codecs
495478

496-
binary_string = "<binary string>"
497-
model = pickle.load(codecs.decode(binary_string.encode(), "base64"))
498-
499-
"""
500479

501480
@classmethod
502481
def _viya35_model_load(
503482
cls,
504483
model_id: str,
505484
model_file_name: str,
506485
pickle_type: Optional[str] = None,
507-
pytorch_model: Optional[str] = None,
508486
mojo_model: Optional[bool] = False,
509487
binary_h2o_model: Optional[bool] = False,
510488
) -> str:
@@ -561,15 +539,6 @@ def _viya35_model_load(
561539
f"{'':8}model = h2o.load(str(Path(\"/models/resources/viya/"
562540
f'{model_id}/{model_file_name}")))'
563541
)
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-
)
573542
else:
574543
cls.score_code += (
575544
f'model_path = Path("/models/resources/viya/{model_id}'
@@ -597,7 +566,6 @@ def _viya4_model_load(
597566
pickle_type: Optional[str] = None,
598567
mojo_model: Optional[bool] = False,
599568
binary_h2o_model: Optional[bool] = False,
600-
pytorch_model: Optional[bool] = False,
601569
tf_keras_model: Optional[bool] = False,
602570
tf_core_model: Optional[bool] = False,
603571
) -> str:
@@ -618,9 +586,6 @@ def _viya4_model_load(
618586
binary_h2o_model : boolean, optional
619587
Flag to indicate that the model is a H2O.ai binary model. The default value
620588
is None.
621-
pytorch_model : boolean, optional
622-
Flag to indicate that the model is a pytorch model. The default value
623-
is None.
624589
tf_keras_model : boolean, optional
625590
Flag to indicate that the model is a tensorflow keras model. The default
626591
value is False.
@@ -656,15 +621,6 @@ def _viya4_model_load(
656621
f"{'':8}model = h2o.load(str(Path(settings.pickle_path) / "
657622
f"{model_file_name}))\n\n"
658623
)
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-
)
668624
elif tf_keras_model:
669625
cls.score_code += (
670626
f"model = tf.keras.models.load_model(Path(settings.pickle_path) / "

src/sasctl/pzmm/zip_model.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def _filter_files(file_dir: Union[str, Path], is_viya4: Optional[bool] = False)
3333
file_names.extend(sorted(Path(file_dir).glob("*.pickle")))
3434
# Include H2O.ai MOJO files
3535
file_names.extend(sorted(Path(file_dir).glob("*.mojo")))
36-
# Include Pytorch.ai files
37-
file_names.extend(sorted(Path(file_dir).glob("*.pth")))
38-
file_names.extend(sorted(Path(file_dir).glob("*.pt")))
3936
if file_names:
4037
return file_names
4138
else:

0 commit comments

Comments
 (0)