public static synchronized TransformServiceLauncher forProject(
      @Nullable String projectName, int port, @Nullable String pythonRequirementsFile)
      throws IOException {
    if (projectName == null || projectName.isEmpty()) {
      projectName = DEFAULT_PROJECT_NAME;
    }
    if (!launchers.containsKey(projectName)) {
      launchers.put(
          projectName, new TransformServiceLauncher(projectName, port, pythonRequirementsFile));
    }
    return launchers.get(projectName);
  }
@Test
  public void testLauncherInstallsDependencies() throws IOException {
    String projectName = UUID.randomUUID().toString();
    Path expectedTempDir = Paths.get(System.getProperty("java.io.tmpdir"), projectName);
    File file = expectedTempDir.toFile();
    file.deleteOnExit();

    File requirementsFile =
        Paths.get(
                System.getProperty("java.io.tmpdir"),
                ("requirements" + UUID.randomUUID().toString() + ".txt"))
            .toFile();
    requirementsFile.deleteOnExit();

    try (Writer fout =
        new OutputStreamWriter(
            new FileOutputStream(requirementsFile.getAbsolutePath()), StandardCharsets.UTF_8)) {
      fout.write("pypipackage1\n");
      fout.write("pypipackage2\n");
    }

    TransformServiceLauncher.forProject(projectName, 12345, requirementsFile.getAbsolutePath());

    // Confirming that the Transform Service launcher created a temporary requirements file with the
    // specified set of packages.
    Path expectedUpdatedRequirementsFile =
        Paths.get(expectedTempDir.toString(), "dependencies_dir", "requirements.txt");
    Assert.assertTrue(expectedUpdatedRequirementsFile.toFile().exists());

    ArrayList<String> expectedUpdatedRequirementsFileLines = new ArrayList<>();
    try (BufferedReader bufReader =
        Files.newBufferedReader(expectedUpdatedRequirementsFile, UTF_8)) {
      String line = bufReader.readLine();
      while (line != null) {
        expectedUpdatedRequirementsFileLines.add(line);
        line = bufReader.readLine();
      }
    }

    Assert.assertEquals(2, expectedUpdatedRequirementsFileLines.size());
    Assert.assertTrue(expectedUpdatedRequirementsFileLines.contains("pypipackage1"));
    Assert.assertTrue(expectedUpdatedRequirementsFileLines.contains("pypipackage2"));
  }