jeff-901 commented on a change in pull request #733:
URL: https://github.com/apache/submarine/pull/733#discussion_r699249324



##########
File path: submarine-sdk/pysubmarine/submarine/models/client.py
##########
@@ -101,6 +107,39 @@ def save_model(self,
             else:
                 raise MlflowException("No valid type of model has been 
matched")
 
+    def save_model_submarine(self,
+                             model_type,
+                             model,
+                             artifact_path,
+                             registered_model_name=None):
+        pattern = r"[0-9A-Za-z][0-9A-Za-z-_]*[0-9A-Za-z]|[0-9A-Za-z]"
+        if not re.fullmatch(pattern, artifact_path):
+            raise Exception(
+                "Artifact_path must only contains numbers, characters, hyphen 
and underscore.  \
+            Artifact_path must starts and ends with numbers or characters.")
+        local_dir = os.path.join(self.root, artifact_path)
+        if os.path.exists(local_dir):
+            version = len(os.listdir(local_dir)) + 1
+        else:
+            version = 1
+        artifact_path = os.path.join(artifact_path, str(version))
+        local_dir = os.path.join(local_dir, str(version))
+        os.makedirs(local_dir)
+        if model_type == "pytorch":
+            import submarine.models.pytorch

Review comment:
       No. I use the function on 131 line.

##########
File path: submarine-sdk/pysubmarine/submarine/models/client.py
##########
@@ -101,6 +107,39 @@ def save_model(self,
             else:
                 raise MlflowException("No valid type of model has been 
matched")
 
+    def save_model_submarine(self,
+                             model_type,
+                             model,
+                             artifact_path,
+                             registered_model_name=None):
+        pattern = r"[0-9A-Za-z][0-9A-Za-z-_]*[0-9A-Za-z]|[0-9A-Za-z]"
+        if not re.fullmatch(pattern, artifact_path):
+            raise Exception(
+                "Artifact_path must only contains numbers, characters, hyphen 
and underscore.  \
+            Artifact_path must starts and ends with numbers or characters.")
+        local_dir = os.path.join(self.root, artifact_path)
+        if os.path.exists(local_dir):
+            version = len(os.listdir(local_dir)) + 1
+        else:
+            version = 1
+        artifact_path = os.path.join(artifact_path, str(version))
+        local_dir = os.path.join(local_dir, str(version))
+        os.makedirs(local_dir)
+        if model_type == "pytorch":
+            import submarine.models.pytorch
+
+            submarine.models.pytorch.save_model(model, local_dir)
+        elif model_type == "tensorflow":
+            import submarine.models.tensorflow

Review comment:
       No. I use the function on 135 line.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to