HuangXingBo commented on a change in pull request #10126: [FLINK-14590][python] 
Unify the working directory of Java process and Python process when submitting 
python jobs via "flink run -py"
URL: https://github.com/apache/flink/pull/10126#discussion_r347703910
 
 

 ##########
 File path: 
flink-python/src/test/java/org/apache/flink/client/python/PythonEnvUtilsTest.java
 ##########
 @@ -41,98 +42,103 @@
  * Tests for the {@link PythonEnvUtils}.
  */
 public class PythonEnvUtilsTest {
-       private Path tmpDirPath;
-       private FileSystem tmpDirFs;
+       private String tmpDirPath;
 
        @Before
        public void prepareTestEnvironment() {
-               String tmpDir = System.getProperty("java.io.tmpdir") +
-                       File.separator + "pyflink" + File.separator + 
UUID.randomUUID();
-
-               tmpDirPath = new Path(tmpDir);
-               try {
-                       tmpDirFs = tmpDirPath.getFileSystem();
-                       if (tmpDirFs.exists(tmpDirPath)) {
-                               tmpDirFs.delete(tmpDirPath, true);
-                       }
-                       tmpDirFs.mkdirs(tmpDirPath);
-               } catch (IOException e) {
-                       throw new RuntimeException("initial PythonUtil test 
environment failed");
-               }
+               tmpDirPath = System.getProperty("java.io.tmpdir") +
+                       File.separator + "pyflink_" + UUID.randomUUID();
+               new File(tmpDirPath).mkdirs();
        }
 
        @Test
        public void testPreparePythonEnvironment() throws IOException {
                // xxx/a.zip, xxx/subdir/b.py, xxx/subdir/c.zip
-               File a = new File(tmpDirPath.toString() + File.separator + 
"a.zip");
+               File a = new File(tmpDirPath + File.separator + "a.zip");
                a.createNewFile();
-               File subdir = new File(tmpDirPath.toString() + File.separator + 
"subdir");
+               File moduleDir = new File(tmpDirPath + File.separator + 
"module_dir");
+               moduleDir.mkdir();
+               File subdir = new File(tmpDirPath + File.separator + "subdir");
                subdir.mkdir();
-               File b = new File(tmpDirPath.toString() + File.separator + 
"subdir" + File.separator + "b.py");
+               File b = new File(tmpDirPath + File.separator + "subdir" + 
File.separator + "b.py");
                b.createNewFile();
-               File c = new File(tmpDirPath.toString() + File.separator + 
"subdir" + File.separator + "c.zip");
+               File c = new File(tmpDirPath + File.separator + "subdir" + 
File.separator + "c.zip");
                c.createNewFile();
 
                List<Path> pyFilesList = new ArrayList<>();
-               pyFilesList.add(tmpDirPath);
+               pyFilesList.add(new Path(a.getAbsolutePath()));
+               pyFilesList.add(new Path(moduleDir.getAbsolutePath()));
 
 Review comment:
   What's the reason of creating moduleDir instead of using subdir

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to