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/20 12:30:17 UTC

[GitHub] [dolphinscheduler] github-code-scanning[bot] commented on a diff in pull request #12071: [Improvement][Task Plugin] Optimize MLFlow task plugin for ease of use

github-code-scanning[bot] commented on code in PR #12071:
URL: https://github.com/apache/dolphinscheduler/pull/12071#discussion_r975299013


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/main/java/org/apache/dolphinscheduler/plugin/task/mlflow/MlflowTask.java:
##########
@@ -141,31 +170,53 @@
         args.add(String.format(MlflowConstants.EXPORT_MLFLOW_TRACKING_URI_ENV, mlflowParameters.getMlflowTrackingUri()));
 
         String runCommand;
+        String versionString;
+
+        if (mlflowParameters.isCustomProject()) {
+            runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
+            runCommand = String.format(runCommand, mlflowParameters.getParams(), mlflowParameters.getExperimentName(), mlflowParameters.getMlflowProjectVersion());
+            versionString = getVersionString(mlflowParameters.getMlflowProjectVersion(), mlflowParameters.getMlflowProjectRepository());
+        } else {
+            switch (mlflowParameters.getMlflowJobType()) {
+                case MlflowConstants.JOB_TYPE_BASIC_ALGORITHM:
+                    runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
+                    break;
+                case MlflowConstants.JOB_TYPE_AUTOML:
+                    runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
+                    break;
+                default:
+                    throw new TaskException("Unsupported mlflow job type: " + mlflowParameters.getMlflowJobType());
+            }
+
+            versionString = getVersionString(getPresetRepositoryVersion(), getPresetRepository());
+        }
+
+        // add version string to command if repository is local path
+        if (StringUtils.isNotEmpty(versionString)) {
+            runCommand = runCommand + " " + versionString;
+        }
 
         if (mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_BASIC_ALGORITHM)) {
             args.add(String.format(MlflowConstants.SET_DATA_PATH, mlflowParameters.getDataPath()));
-            args.add(String.format(MlflowConstants.SET_REPOSITORY, MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT));
-            args.add(String.format(MlflowConstants.GIT_CLONE_REPO, MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
 
-            runCommand = MlflowConstants.MLFLOW_RUN_BASIC_ALGORITHM;
+            String repoBasicAlgorithm = getPresetRepository() + MlflowConstants.PRESET_BASIC_ALGORITHM_PROJECT;
+            args.add(String.format(MlflowConstants.SET_REPOSITORY, repoBasicAlgorithm));
+
             runCommand = String.format(runCommand, mlflowParameters.getAlgorithm(), mlflowParameters.getParams(), mlflowParameters.getSearchParams(), mlflowParameters.getModelName(),
                 mlflowParameters.getExperimentName());
 
         } else if (mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_AUTOML)) {
             args.add(String.format(MlflowConstants.SET_DATA_PATH, mlflowParameters.getDataPath()));
-            args.add(String.format(MlflowConstants.SET_REPOSITORY, MlflowConstants.PRESET_AUTOML_PROJECT));
-            args.add(String.format(MlflowConstants.GIT_CLONE_REPO, MlflowConstants.PRESET_REPOSITORY, MlflowConstants.PRESET_PATH));
+            String repoAutoML = getPresetRepository() + MlflowConstants.PRESET_AUTOML_PROJECT;
+            args.add(String.format(MlflowConstants.SET_REPOSITORY, repoAutoML));
 
-            runCommand = MlflowConstants.MLFLOW_RUN_AUTOML_PROJECT;
             runCommand = String.format(runCommand, mlflowParameters.getAutomlTool(), mlflowParameters.getParams(), mlflowParameters.getModelName(), mlflowParameters.getExperimentName());
 
         } else if (mlflowParameters.getMlflowJobType().equals(MlflowConstants.JOB_TYPE_CUSTOM_PROJECT)) {
             args.add(String.format(MlflowConstants.SET_REPOSITORY, mlflowParameters.getMlflowProjectRepository()));
-
-            runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
-            runCommand = String.format(runCommand, mlflowParameters.getParams(), mlflowParameters.getExperimentName(), mlflowParameters.getMlflowProjectVersion());
+            runCommand = String.format(runCommand, mlflowParameters.getParams(), mlflowParameters.getExperimentName());

Review Comment:
   ## Missing format argument
   
   This format call refers to 4 argument(s) but only supplies 2 argument(s).
   This format call refers to 5 argument(s) but only supplies 2 argument(s).
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1488)



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/main/java/org/apache/dolphinscheduler/plugin/task/mlflow/MlflowTask.java:
##########
@@ -141,31 +170,53 @@
         args.add(String.format(MlflowConstants.EXPORT_MLFLOW_TRACKING_URI_ENV, mlflowParameters.getMlflowTrackingUri()));
 
         String runCommand;
+        String versionString;
+
+        if (mlflowParameters.isCustomProject()) {
+            runCommand = MlflowConstants.MLFLOW_RUN_CUSTOM_PROJECT;
+            runCommand = String.format(runCommand, mlflowParameters.getParams(), mlflowParameters.getExperimentName(), mlflowParameters.getMlflowProjectVersion());

Review Comment:
   ## Unused format argument
   
   This format call refers to 2 argument(s) but supplies 3 argument(s).
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1489)



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