You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by cd...@apache.org on 2022/11/16 23:48:20 UTC

[submarine] branch master updated: SUBMARINE-1348. Fix implicit Optional check style issues for mypy

This is an automated email from the ASF dual-hosted git repository.

cdmikechen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new 179ce618 SUBMARINE-1348. Fix implicit Optional check style issues for mypy
179ce618 is described below

commit 179ce618fc47c618afd35d0b51c61608f7e1c802
Author: Zhao-Wei <ja...@gmail.com>
AuthorDate: Tue Nov 15 00:50:53 2022 -0600

    SUBMARINE-1348. Fix implicit Optional check style issues for mypy
    
    ### What is this PR for?
    Fix mypy python check error (cause by mypy recent change: --no-implicit-optional by default)
    https://mypy-lang.blogspot.com/2022/11/mypy-0990-released.html
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-1348
    
    ### How should this be tested?
    Python check style test will now pass
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: Zhao-Wei <ja...@gmail.com>
    
    Signed-off-by: cdmikechen <cd...@apache.org>
    
    Closes #1016 from JackLiu00521/SUBMARINE-1348 and squashes the following commits:
    
    cf187dc3 [Zhao-Wei] fix import order
    0712eaa0 [Zhao-Wei] fix import order
    e824340f [Zhao-Wei] try disable isort
    5b714fa0 [Zhao-Wei] try fix isort
    16920c8f [Zhao-Wei] fix python implicit optional types problem in checkstyle
---
 .../submarine/store/model_registry/abstract_store.py | 14 +++++++-------
 .../store/model_registry/sqlalchemy_store.py         | 14 +++++++-------
 .../pysubmarine/submarine/tracking/client.py         | 20 ++++++++++----------
 .../pysubmarine/submarine/tracking/fluent.py         |  7 ++++---
 4 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/submarine-sdk/pysubmarine/submarine/store/model_registry/abstract_store.py b/submarine-sdk/pysubmarine/submarine/store/model_registry/abstract_store.py
index 24c60868..da27216b 100644
--- a/submarine-sdk/pysubmarine/submarine/store/model_registry/abstract_store.py
+++ b/submarine-sdk/pysubmarine/submarine/store/model_registry/abstract_store.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 from abc import ABCMeta, abstractmethod
-from typing import List
+from typing import List, Optional
 
 from submarine.entities.model_registry import ModelVersion, RegisteredModel
 
@@ -36,7 +36,7 @@ class AbstractStore:
 
     @abstractmethod
     def create_registered_model(
-        self, name: str, description: str = None, tags: List[str] = None
+        self, name: str, description: Optional[str] = None, tags: Optional[List[str]] = None
     ) -> RegisteredModel:
         """
         Create a new registered model in backend store.
@@ -82,7 +82,7 @@ class AbstractStore:
 
     @abstractmethod
     def list_registered_model(
-        self, filter_str: str = None, filter_tags: List[str] = None
+        self, filter_str: Optional[str] = None, filter_tags: Optional[List[str]] = None
     ) -> List[RegisteredModel]:
         """
         List of all models.
@@ -130,9 +130,9 @@ class AbstractStore:
         user_id: str,
         experiment_id: str,
         model_type: str,
-        dataset: str = None,
-        description: str = None,
-        tags: List[str] = None,
+        dataset: Optional[str] = None,
+        description: Optional[str] = None,
+        tags: Optional[List[str]] = None,
     ) -> ModelVersion:
         """
         Create a new version of the registered model
@@ -190,7 +190,7 @@ class AbstractStore:
         pass
 
     @abstractmethod
-    def list_model_versions(self, name: str, filter_tags: list = None) -> List[ModelVersion]:
+    def list_model_versions(self, name: str, filter_tags: Optional[list] = None) -> List[ModelVersion]:
         """
         List of all models that satisfy the filter criteria.
         :param name: Registered model name.
diff --git a/submarine-sdk/pysubmarine/submarine/store/model_registry/sqlalchemy_store.py b/submarine-sdk/pysubmarine/submarine/store/model_registry/sqlalchemy_store.py
index d2da6c10..3b1766bd 100644
--- a/submarine-sdk/pysubmarine/submarine/store/model_registry/sqlalchemy_store.py
+++ b/submarine-sdk/pysubmarine/submarine/store/model_registry/sqlalchemy_store.py
@@ -16,7 +16,7 @@
 import logging
 from contextlib import contextmanager
 from datetime import datetime
-from typing import List, Union
+from typing import List, Optional, Union
 
 import sqlalchemy
 from sqlalchemy.engine.base import Engine
@@ -140,7 +140,7 @@ class SqlAlchemyStore(AbstractStore):
             session.add(objs)
 
     def create_registered_model(
-        self, name: str, description: str = None, tags: List[str] = None
+        self, name: str, description: Optional[str] = None, tags: Optional[List[str]] = None
     ) -> RegisteredModel:
         """
         Create a new registered model in backend store.
@@ -250,7 +250,7 @@ class SqlAlchemyStore(AbstractStore):
             session.delete(sql_registered_model)
 
     def list_registered_model(
-        self, filter_str: str = None, filter_tags: List[str] = None
+        self, filter_str: Optional[str] = None, filter_tags: Optional[List[str]] = None
     ) -> List[RegisteredModel]:
         """
         List of all models.
@@ -334,9 +334,9 @@ class SqlAlchemyStore(AbstractStore):
         user_id: str,
         experiment_id: str,
         model_type: str,
-        dataset: str = None,
-        description: str = None,
-        tags: List[str] = None,
+        dataset: Optional[str] = None,
+        description: Optional[str] = None,
+        tags: Optional[List[str]] = None,
     ) -> ModelVersion:
         """
         Create a new version of the registered model
@@ -478,7 +478,7 @@ class SqlAlchemyStore(AbstractStore):
             sql_model_version = self._get_sql_model_version(session, name, version, True)
             return sql_model_version.to_submarine_entity()
 
-    def list_model_versions(self, name: str, filter_tags: list = None) -> List[ModelVersion]:
+    def list_model_versions(self, name: str, filter_tags: Optional[list] = None) -> List[ModelVersion]:
         """
         List of all models that satisfy the filter criteria.
         :param name: Registered model name.
diff --git a/submarine-sdk/pysubmarine/submarine/tracking/client.py b/submarine-sdk/pysubmarine/submarine/tracking/client.py
index 0ad37b88..7c4a2677 100644
--- a/submarine-sdk/pysubmarine/submarine/tracking/client.py
+++ b/submarine-sdk/pysubmarine/submarine/tracking/client.py
@@ -17,7 +17,7 @@ import os
 import re
 import tempfile
 from datetime import datetime
-from typing import Any, Dict
+from typing import Any, Dict, Optional
 
 import submarine
 from submarine.artifacts.repository import Repository
@@ -38,10 +38,10 @@ class SubmarineClient:
 
     def __init__(
         self,
-        db_uri: str = None,
-        s3_registry_uri: str = None,
-        aws_access_key_id: str = None,
-        aws_secret_access_key: str = None,
+        db_uri: Optional[str] = None,
+        s3_registry_uri: Optional[str] = None,
+        aws_access_key_id: Optional[str] = None,
+        aws_secret_access_key: Optional[str] = None,
         host: str = generate_host(),
     ) -> None:
         """
@@ -100,9 +100,9 @@ class SubmarineClient:
         self,
         model,
         model_type: str,
-        registered_model_name: str = None,
-        input_dim: list = None,
-        output_dim: list = None,
+        registered_model_name: Optional[str] = None,
+        input_dim: Optional[list] = None,
+        output_dim: Optional[list] = None,
     ) -> None:
         """
         Save a model into the minio pod or even register a model.
@@ -159,8 +159,8 @@ class SubmarineClient:
         dest_path: str,
         model_type: str,
         model_id: str,
-        input_dim: list = None,
-        output_dim: list = None,
+        input_dim: Optional[list] = None,
+        output_dim: Optional[list] = None,
     ):
         """
         Save a model into the minio pod.
diff --git a/submarine-sdk/pysubmarine/submarine/tracking/fluent.py b/submarine-sdk/pysubmarine/submarine/tracking/fluent.py
index 69c21c0d..cb144456 100644
--- a/submarine-sdk/pysubmarine/submarine/tracking/fluent.py
+++ b/submarine-sdk/pysubmarine/submarine/tracking/fluent.py
@@ -19,6 +19,7 @@ Submarine run. This module is exposed to users at the top-level :py:mod:`submari
 
 import logging
 from datetime import datetime
+from typing import Optional
 
 from submarine.tracking.client import SubmarineClient
 from submarine.tracking.utils import get_job_id, get_worker_index
@@ -56,9 +57,9 @@ def log_metric(key, value, step=None):
 def save_model(
     model,
     model_type: str,
-    registered_model_name: str = None,
-    input_dim: list = None,
-    output_dim: list = None,
+    registered_model_name: Optional[str] = None,
+    input_dim: Optional[list] = None,
+    output_dim: Optional[list] = None,
 ):
     """
     Save a model into the minio pod.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org