Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,41 @@ public class EnvironmentManager {
* - `pyyaml`: YAML file parsing and writing.
*/
public static String getPython3EnvContent(String envName, String version) {
String pythonVersion = (version != null && !version.isEmpty()) ? version : "3.9";
String pythonVersion = (version != null && !version.isEmpty()) ? version : "3.8";
return "name: " + envName + "\n"
+ "channels:\n"
+ " - conda-forge\n"
+ " - defaults\n"
+ " - knime\n"
+ "dependencies:\n"
+ " - python=" + pythonVersion + "\n"
+ " - numpy\n"
+ " - pandas\n"
+ " - scikit-learn\n"
+ " - scipy\n"
+ " - matplotlib-base\n"
+ " - plotly\n"
+ " - seaborn\n"
+ " - statsmodels\n"
+ " - requests\n"
+ " - pillow\n"
+ " - openpyxl\n"
+ " - knime-python-base\n"
//+ " - beautifulsoup4\n"
//+ " - cloudpickle\n"
//+ " - ipython\n"
//+ " - matplotlib-base\n"
//+ " - markdown\n"
//+ " - nbformat\n"
//+ " - nltk\n"
//+ " - nomkl\n"
//+ " - numpy\n"
//+ " - openpyxl\n"
//+ " - pandas\n"
//+ " - pillow\n"
//+ " - plotly\n"
//+ " - py4j\n"
+ " - descartes\n"
+ " - pyogrio\n"
+ " - pyyaml\n";
}
//+ " - pyarrow\n"
+ " - python=" + pythonVersion + "\n"
//+ " - pyogrio\n"
//+ " - python-dateutil\n"
//+ " - pytz\n"
//+ " - pyyaml\n"
//+ " - requests\n"
//+ " - scikit-learn\n"
//+ " - scipy\n"
//+ " - seaborn\n"
//+ " - statsmodels\n";
;
}

/**
* Generates the Conda environment YAML content for Python 2.
Expand Down Expand Up @@ -179,7 +192,7 @@ public static void createEnvironment(String environmentName, String languageWrit
// Add additional dependencies
if (additionalDependencies != null && additionalDependencies.length > 0) {
for (String dependency : additionalDependencies) {
if (!StringUtils.isBlank(dependency)) {
if (!StringUtils.isBlank(dependency) && !dependency.equalsIgnoreCase("os")) {
if (languageWrittenIn.toLowerCase().startsWith("r ")) {
dependency = "r-" + dependency;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected PortObject[] execute(PortObject[] inObjects, ExecutionContext exec) th
private boolean waitForEnvironmentCreation(FSKCondaEnvironmentCreationObserver.CondaEnvironmentCreationStatus m_status, ExecutionContext exec) throws InterruptedException {
int timeout = 300000; // Set a 300-second timeout
int elapsed = 0;
int interval = 500; // 500ms sleep interval
int interval = 5000; // 500ms sleep interval

while (elapsed < timeout) {
// Get the current status message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@
import org.knime.python2.Activator;
import org.knime.python2.CondaPythonCommand;
import org.knime.python2.ManualPythonCommand;
import org.knime.python2.PythonCommand;
import org.knime.python2.PythonKernelTester;
import org.knime.python2.PythonKernelTester.PythonKernelTestResult;
import org.knime.python2.PythonVersion;
import org.knime.python2.config.CondaEnvironmentsConfig;
import org.knime.python2.config.PythonConfigStorage;
import org.knime.python2.kernel.PythonKernel;
import org.knime.python2.prefs.PreferenceStorage;
import org.knime.python2.prefs.PreferenceWrappingConfigStorage;
import org.knime.python2.prefs.PythonPreferences;
Expand Down Expand Up @@ -1017,13 +1019,42 @@ private boolean callCondaAndMonitorExecution(Label label, final String... argume
private Process startCondaProcess(final String... arguments) throws IOException {
List<String> command = new ArrayList<>();
// Add the conda executable. If conda is in your system PATH, you can just use "conda"
String app =getCondaInstallationPath()+ "/bin/conda";
command.add(app);


String os = System.getProperty("os.name").toLowerCase();

// Command configuration for cross-platform compatibility
if (os.contains("win")) {
command.add("cmd.exe");
command.add("/c");
command.add("conda");

} else {
command.add(getCondaInstallationPath()+ "/bin/conda");
}

// Add all the provided arguments
command.addAll(Arrays.asList(arguments));

ProcessBuilder processBuilder = new ProcessBuilder(command);
return processBuilder.start();

}
@Override
public void setVisible(boolean visible) {
if (visible) {
// Reset envsMaps to force refresh
envsMaps = null;

// Refresh the conda environments
if (PreferenceInitializer.isPythonConda()) {
fillCondaEnvsforPython(condaPath, messageRConda, compositePythonConda);
}
if (PreferenceInitializer.isRConda()) {
fillCondaEnvsforR(condaPath, messageRConda, compositeRConda);
}
}
super.setVisible(visible);
}

}