kezhenxu94 commented on code in PR #10036:
URL: https://github.com/apache/dolphinscheduler/pull/10036#discussion_r873323267


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/test/java/org/apache/dolphinler/plugin/task/mlflow/MlflowTaskTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinler.plugin.task.mlflow;
+
+import java.io.IOException;
+import java.util.*;

Review Comment:
   Avoid star import



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/test/java/org/apache/dolphinler/plugin/task/mlflow/MlflowTaskTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinler.plugin.task.mlflow;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import 
org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowConstants;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowParameters;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowTask;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
+
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import 
org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({
+        JSONUtils.class,
+        PropertyUtils.class,
+})
+@PowerMockIgnore({"javax.*"})
+@SuppressStaticInitializationFor("org.apache.dolphinscheduler.spi.utils.PropertyUtils")
+public class MlflowTaskTest {
+    private static final Logger logger = 
LoggerFactory.getLogger(MlflowTask.class);
+
+    @Before
+    public void before() throws Exception {
+        PowerMockito.mockStatic(PropertyUtils.class);
+    }
+
+    public TaskExecutionContext createContext(MlflowParameters 
mlflowParameters){
+        String parameters = JSONUtils.toJsonString(mlflowParameters);
+        TaskExecutionContext taskExecutionContext = 
Mockito.mock(TaskExecutionContext.class);
+        
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(parameters);
+        
Mockito.when(taskExecutionContext.getTaskLogName()).thenReturn("MLflowTest");
+        
Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp/dolphinscheduler_test");
+        
Mockito.when(taskExecutionContext.getTaskAppId()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(taskExecutionContext.getTenantCode()).thenReturn("root");
+        Mockito.when(taskExecutionContext.getStartTime()).thenReturn(new 
Date());
+        Mockito.when(taskExecutionContext.getTaskTimeout()).thenReturn(10000);
+        
Mockito.when(taskExecutionContext.getLogPath()).thenReturn("/tmp/dolphinscheduler_test/log");
+        
Mockito.when(taskExecutionContext.getEnvironmentConfig()).thenReturn("export 
PATH=$HOME/anaconda3/bin:$PATH");
+
+        String userName = System.getenv().get("USER");
+        
Mockito.when(taskExecutionContext.getTenantCode()).thenReturn(userName);
+
+        
TaskExecutionContextCacheManager.cacheTaskExecutionContext(taskExecutionContext);
+        return taskExecutionContext;
+    }
+
+    @Test
+    public void testInitBasicAlgorithmTask()
+            throws Exception {
+        try {
+            MlflowParameters mlflowParameters = 
createBasicAlgorithmParameters();
+            TaskExecutionContext taskExecutionContext = 
createContext(mlflowParameters);
+            MlflowTask mlflowTask = new MlflowTask(taskExecutionContext);
+            mlflowTask.init();
+            
mlflowTask.getParameters().setVarPool(taskExecutionContext.getVarPool());
+//            mlflowTask.handle();

Review Comment:
   Remove if not needed



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/test/java/org/apache/dolphinler/plugin/task/mlflow/MlflowTaskTest.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinler.plugin.task.mlflow;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import 
org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowConstants;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowParameters;
+import org.apache.dolphinscheduler.plugin.task.mlflow.MlflowTask;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
+
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import 
org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({
+        JSONUtils.class,
+        PropertyUtils.class,
+})
+@PowerMockIgnore({"javax.*"})
+@SuppressStaticInitializationFor("org.apache.dolphinscheduler.spi.utils.PropertyUtils")
+public class MlflowTaskTest {
+    private static final Logger logger = 
LoggerFactory.getLogger(MlflowTask.class);
+
+    @Before
+    public void before() throws Exception {
+        PowerMockito.mockStatic(PropertyUtils.class);
+    }
+
+    public TaskExecutionContext createContext(MlflowParameters 
mlflowParameters){
+        String parameters = JSONUtils.toJsonString(mlflowParameters);
+        TaskExecutionContext taskExecutionContext = 
Mockito.mock(TaskExecutionContext.class);
+        
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(parameters);
+        
Mockito.when(taskExecutionContext.getTaskLogName()).thenReturn("MLflowTest");
+        
Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp/dolphinscheduler_test");
+        
Mockito.when(taskExecutionContext.getTaskAppId()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(taskExecutionContext.getTenantCode()).thenReturn("root");
+        Mockito.when(taskExecutionContext.getStartTime()).thenReturn(new 
Date());
+        Mockito.when(taskExecutionContext.getTaskTimeout()).thenReturn(10000);
+        
Mockito.when(taskExecutionContext.getLogPath()).thenReturn("/tmp/dolphinscheduler_test/log");
+        
Mockito.when(taskExecutionContext.getEnvironmentConfig()).thenReturn("export 
PATH=$HOME/anaconda3/bin:$PATH");
+
+        String userName = System.getenv().get("USER");
+        
Mockito.when(taskExecutionContext.getTenantCode()).thenReturn(userName);
+
+        
TaskExecutionContextCacheManager.cacheTaskExecutionContext(taskExecutionContext);
+        return taskExecutionContext;
+    }
+
+    @Test
+    public void testInitBasicAlgorithmTask()
+            throws Exception {
+        try {
+            MlflowParameters mlflowParameters = 
createBasicAlgorithmParameters();
+            TaskExecutionContext taskExecutionContext = 
createContext(mlflowParameters);
+            MlflowTask mlflowTask = new MlflowTask(taskExecutionContext);
+            mlflowTask.init();
+            
mlflowTask.getParameters().setVarPool(taskExecutionContext.getVarPool());
+//            mlflowTask.handle();
+        } catch (Exception e) {
+            Assert.fail(e.getMessage());
+        }
+    }
+
+    @Test
+    public void testInitAutoMLTask()
+            throws Exception {
+        try {
+            MlflowParameters mlflowParameters = createAutoMLParameters();
+            TaskExecutionContext taskExecutionContext = 
createContext(mlflowParameters);
+            MlflowTask mlflowTask = new MlflowTask(taskExecutionContext);
+            mlflowTask.init();
+            
mlflowTask.getParameters().setVarPool(taskExecutionContext.getVarPool());
+//            mlflowTask.handle();

Review Comment:
   Remove if not needed



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-mlflow/src/main/java/org/apache/dolphinscheduler/plugin/task/mlflow/MlflowConstants.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.mlflow;
+
+public class MlflowConstants {
+    private MlflowConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    public static final String JOB_TYPE_AUTOML = "AutoML";
+
+    public static final String JOB_TYPE_BASIC_ALGORITHM = "BasicAlgorithm";
+
+    public static final String PRESET_AUTOML_PROJECT = 
"https://github.com/jieguangzhou/MLflow-AutoML";;
+
+    public static final String PRESET_BASIC_ALGORITHM_PROJECT = 
"https://github.com/jieguangzhou/mlflow_sklearn_gallery";;

Review Comment:
   > The MLflow can run the GitHub URL as an MLflow project. In this 
implementation, if we wanted to provide the preset algorithm capability for the 
MLFlow component for my project, we needed a repository to hold the code.
   > 
   > I don't know how these repos should be created, do you have any 
suggestions?
   
   We'd better not to use personal repository here, is 
`PRESET_BASIC_ALGORITHM_PROJECT` is required in this task? If not we can just 
remove it, if it's required, we'd need to create a repo, or, is there other 
form of this settings, for example, using a directory (not repository)?



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