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/16 02:08:53 UTC

[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #11975: [Feature][PyDolphinScheduler] Support Pytorch task in pyds

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


##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/pytorch.py:
##########
@@ -0,0 +1,94 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task Pytorch."""
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.task import Task
+
+
+class DEFAULT:
+    """Default values for Pytorch."""
+
+    is_create_environment = False
+    project_path = "."
+    python_command = "${PYTHON_HOME}"
+
+
+class Pytorch(Task):
+    """Task Pytorch object, declare behavior for Pytorch task to dolphinscheduler.
+
+    See also: `DolphinScheduler Pytorch Task Plugin
+    <https://dolphinscheduler.apache.org/en-us/docs/dev/user_doc/guide/task/pytorch.html>`_
+
+    :param name: task name
+    :param script: Entry to the Python script file that you want to run.
+    :param script_params: Input parameters at run time.
+    :param project_path: The path to the project. Default "." .
+    :param is_create_environment: is create environment. Default False.
+    :param python_command: The path to the python command. Default "${PYTHON_HOME}".
+    :param python_env_tool: The python environment tool. Default "conda".
+    :param requirements: The path to the requirements.txt file. Default "requirements.txt".
+    :param conda_python_version: The python version of conda environment. Default "3.7".

Review Comment:
   Thanks for adding this doc string



##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/pytorch.py:
##########
@@ -0,0 +1,94 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task Pytorch."""
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.task import Task
+
+
+class DEFAULT:
+    """Default values for Pytorch."""
+
+    is_create_environment = False
+    project_path = "."
+    python_command = "${PYTHON_HOME}"
+
+
+class Pytorch(Task):
+    """Task Pytorch object, declare behavior for Pytorch task to dolphinscheduler.
+
+    See also: `DolphinScheduler Pytorch Task Plugin
+    <https://dolphinscheduler.apache.org/en-us/docs/dev/user_doc/guide/task/pytorch.html>`_
+
+    :param name: task name
+    :param script: Entry to the Python script file that you want to run.
+    :param script_params: Input parameters at run time.
+    :param project_path: The path to the project. Default "." .
+    :param is_create_environment: is create environment. Default False.
+    :param python_command: The path to the python command. Default "${PYTHON_HOME}".
+    :param python_env_tool: The python environment tool. Default "conda".
+    :param requirements: The path to the requirements.txt file. Default "requirements.txt".
+    :param conda_python_version: The python version of conda environment. Default "3.7".
+    """
+
+    _task_custom_attr = {
+        "script",
+        "script_params",
+        "other_params",
+        "python_path",
+        "is_create_environment",
+        "python_command",
+        "python_env_tool",
+        "requirements",
+        "conda_python_version",
+    }
+
+    def __init__(
+        self,
+        name: str,
+        script: str,
+        script_params: str = "",
+        project_path: str = DEFAULT.project_path,
+        is_create_environment: bool = DEFAULT.is_create_environment,
+        python_command: str = DEFAULT.python_command,
+        python_env_tool: str = "conda",
+        requirements: str = "requirements.txt",
+        conda_python_version="3.7",

Review Comment:
   If we have a default value of the parameter, we should better a `Optional` keyword
   
   ```suggestion
           is_create_environment: Optional[bool] = DEFAULT.is_create_environment,
           python_command: Optional[str] = DEFAULT.python_command,
           python_env_tool: Optional[str] = "conda",
           requirements: Optional[str] = "requirements.txt",
           conda_python_version: Optional[str] ="3.7",
   ```



-- 
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