You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/09/21 07:15:39 UTC

[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #11162: [Feature] Add CURD to the project/tenant/user section of the python-DS

zhongjiajie commented on code in PR #11162:
URL: https://github.com/apache/dolphinscheduler/pull/11162#discussion_r976128490


##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/models/user.py:
##########
@@ -73,5 +74,53 @@ def create_if_not_exists(self, **kwargs):
             self.queue,
             self.status,
         )
+        print(user.user_id)

Review Comment:
   do not use print in prod code, only if you want to print hint for it 
   ```suggestion
   ```



##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/models/project.py:
##########
@@ -31,11 +31,39 @@ def __init__(
         self,
         name: str = configuration.WORKFLOW_PROJECT,
         description: Optional[str] = None,
+        code: Optional[str] = None,
     ):
         super().__init__(name, description)
+        self.code = code
 
     def create_if_not_exists(self, user=configuration.USER_NAME) -> None:
         """Create Project if not exists."""
-        JavaGate().create_or_grant_project(user, self.name, self.description)
+        _ = JavaGate().create_or_grant_project(user, self.name, self.description)
         # TODO recover result checker
         # gateway_result_checker(result, None)
+
+    def get_project_by_name(self, user=configuration.USER_NAME, name=None) -> None:
+        """Get Project by name."""
+        project = JavaGate().query_project_by_name(user, name)
+        self.name = project.getName()
+        self.description = project.getDescription()
+        self.code = project.getCode()
+        return

Review Comment:
   and think maybe we should return something here, like return the project object, 
   ```suggestion
       def get_project_by_name(self, user=configuration.USER_NAME, name=None) -> Project:
            """Get Project by name."""
            project = JavaGate().query_project_by_name(user, name)
            self.name = project.getName()
            self.description = project.getDescription()
            self.code = project.getCode()
            return self
   ```
   I thing use the `get` keyword but do not return anything is odd, WDTY?



##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/models/project.py:
##########
@@ -31,11 +31,39 @@ def __init__(
         self,
         name: str = configuration.WORKFLOW_PROJECT,
         description: Optional[str] = None,
+        code: Optional[str] = None,
     ):
         super().__init__(name, description)
+        self.code = code
 
     def create_if_not_exists(self, user=configuration.USER_NAME) -> None:
         """Create Project if not exists."""
-        JavaGate().create_or_grant_project(user, self.name, self.description)
+        _ = JavaGate().create_or_grant_project(user, self.name, self.description)

Review Comment:
   if we do not run the return object, why does we directly remove `_`?



##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/models/project.py:
##########
@@ -31,11 +31,39 @@ def __init__(
         self,
         name: str = configuration.WORKFLOW_PROJECT,
         description: Optional[str] = None,
+        code: Optional[str] = None,
     ):
         super().__init__(name, description)
+        self.code = code
 
     def create_if_not_exists(self, user=configuration.USER_NAME) -> None:
         """Create Project if not exists."""
-        JavaGate().create_or_grant_project(user, self.name, self.description)
+        _ = JavaGate().create_or_grant_project(user, self.name, self.description)
         # TODO recover result checker
         # gateway_result_checker(result, None)
+
+    def get_project_by_name(self, user=configuration.USER_NAME, name=None) -> None:
+        """Get Project by name."""
+        project = JavaGate().query_project_by_name(user, name)
+        self.name = project.getName()
+        self.description = project.getDescription()
+        self.code = project.getCode()
+        return

Review Comment:
   should we remove statement `return` if we return nothing?



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org