Skip to content

Commit 5bdf589

Browse files
committed
Check conda existence in miniforge3 instead of miniconda3
1 parent fc3c3de commit 5bdf589

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

src/main/util.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function checkForMissingSystemRequirements() {
138138
export async function checkLocalServerVersion() {
139139
const mainFile = path.join(
140140
await getTransformerLabCodeDir(),
141-
'LATEST_VERSION'
141+
'LATEST_VERSION',
142142
);
143143

144144
console.log('Checking if server is installed locally at', mainFile);
@@ -227,7 +227,7 @@ export function killLocalServer() {
227227
console.log('Killing local server if not NULL');
228228
if (localServer) {
229229
console.log(
230-
`Killing local server with pid ${localServer.pid} and all it children`
230+
`Killing local server with pid ${localServer.pid} and all it children`,
231231
);
232232
var kill = require('tree-kill');
233233
kill(localServer.pid, 'SIGTERM', function (err) {
@@ -251,8 +251,7 @@ export async function checkIfCurlInstalled() {
251251
}
252252
console.log(`stdout: ${stdout}`);
253253
return true;
254-
}
255-
catch (error) {
254+
} catch (error) {
256255
console.error(`Failed to check if curl is installed: ${error}`);
257256
return false;
258257
}
@@ -277,7 +276,9 @@ export async function installLocalServer() {
277276
// First check if curl is installed on the client machine:
278277
const curlInstalled = await checkIfCurlInstalled();
279278
if (!curlInstalled) {
280-
dialog.showMessageBox({message: 'Curl is not installed. Please install curl and try again.'});
279+
dialog.showMessageBox({
280+
message: 'Curl is not installed. Please install curl and try again.',
281+
});
281282
return;
282283
}
283284

@@ -294,15 +295,17 @@ export async function installLocalServer() {
294295
options,
295296
(error, stdout, stderr) => {
296297
if (error) {
297-
dialog.showMessageBox({message: `Failed to download Transformer Lab ${error}`});
298+
dialog.showMessageBox({
299+
message: `Failed to download Transformer Lab ${error}`,
300+
});
298301
console.error(`exec error: ${error}`);
299302
return;
300303
}
301304
console.log(`stdout: ${stdout}`);
302305
console.error(`stderr: ${stderr}`);
303306
// write stdout to the file called out:
304307
fs.writeSync(out, stdout);
305-
}
308+
},
306309
);
307310
} catch (err) {
308311
console.log('Failed to install local server', err);
@@ -312,7 +315,7 @@ export async function installLocalServer() {
312315
export async function checkIfCondaBinExists() {
313316
// Look for the conda directory inside .transformerlab
314317
const root_dir = await getTransformerLabRootDir();
315-
const condaBin = path.join(root_dir, 'miniconda3', 'bin', 'conda');
318+
const condaBin = path.join(root_dir, 'miniforge3', 'bin', 'conda');
316319
if (fs.existsSync(condaBin)) {
317320
return true;
318321
} else {
@@ -333,7 +336,7 @@ export async function checkDependencies() {
333336
// if not, report back that we need to do an install/update!
334337
const installedDependenciesFile = path.join(
335338
await getTransformerLabCodeDir(),
336-
'INSTALLED_DEPENDENCIES'
339+
'INSTALLED_DEPENDENCIES',
337340
);
338341
if (!fs.existsSync(installedDependenciesFile)) {
339342
response.status = 'error';
@@ -343,7 +346,7 @@ export async function checkDependencies() {
343346

344347
const { error, stdout, stderr } = await executeInstallStep(
345348
'list_installed_packages',
346-
false
349+
false,
347350
);
348351

349352
// if there was an error abort processing
@@ -406,7 +409,7 @@ export async function checkIfCondaEnvironmentExists() {
406409

407410
const { error, stdout, stderr } = await executeInstallStep(
408411
'list_environments',
409-
false
412+
false,
410413
);
411414

412415
let response = {
@@ -456,7 +459,7 @@ function truncate(str: string, max: number) {
456459
*/
457460
export async function executeInstallStep(
458461
argument: string,
459-
logToFile = true
462+
logToFile = true,
460463
): Promise<{ error: string | null; stdout: string; stderr: string }> {
461464
const server_dir = await getTransformerLabCodeDir();
462465
const logFilePath = await getLogFilePath();
@@ -465,7 +468,7 @@ export async function executeInstallStep(
465468

466469
if (!fs.existsSync(server_dir)) {
467470
console.log(
468-
'Install step failed. TransformerLab directory has not been setup.'
471+
'Install step failed. TransformerLab directory has not been setup.',
469472
);
470473
const err = new Error('TransformerLab directory has not been setup.');
471474
return { error: err, stdout: '', stderr: '' };
@@ -546,6 +549,6 @@ export async function executeInstallStep(
546549
});
547550
}
548551
});
549-
}
552+
},
550553
);
551554
}

src/renderer/components/Connect/LocalConnection.tsx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function setIntervalXTimes(
2626
callback,
2727
notSuccessful,
2828
delay,
29-
repetitions
29+
repetitions,
3030
) {
3131
var x = 0;
3232
var intervalID = window.setInterval(async function () {
@@ -88,7 +88,7 @@ function InstallStep({ children = <></>, thisStep, title, activeStep }) {
8888

8989
function InstallStepper({ setServer }) {
9090
const [activeStep, setActiveStep] = useState(
91-
Steps.indexOf('CHECK_IF_INSTALLED')
91+
Steps.indexOf('CHECK_IF_INSTALLED'),
9292
); // 0, 1, 2
9393

9494
const [userRequestedInstall, setUserRequestedInstall] = useState(false);
@@ -155,7 +155,7 @@ function InstallStepper({ setServer }) {
155155
throw new Error(setupMessage);
156156
}
157157
return window.electron.ipcRenderer.invoke(
158-
'server:checkIfInstalledLocally'
158+
'server:checkIfInstalledLocally',
159159
);
160160
})
161161
.then((serverIsInstalled) => {
@@ -185,15 +185,15 @@ function InstallStepper({ setServer }) {
185185
logStep(activeStep);
186186
(async () => {
187187
const ver = await window.electron.ipcRenderer.invoke(
188-
'server:checkLocalVersion'
188+
'server:checkLocalVersion',
189189
);
190190
setVersion(ver);
191191

192192
let json = {};
193193

194194
try {
195195
const rel = await fetch(
196-
'https://api.github.com/repos/transformerlab/transformerlab-api/releases/latest'
196+
'https://api.github.com/repos/transformerlab/transformerlab-api/releases/latest',
197197
);
198198
json = await rel.json();
199199
} catch {
@@ -225,7 +225,7 @@ function InstallStepper({ setServer }) {
225225

226226
(async () => {
227227
const condaExists = await window.electron.ipcRenderer.invoke(
228-
'server:checkIfCondaExists'
228+
'server:checkIfCondaExists',
229229
);
230230
if (condaExists) {
231231
setInstallStatus('success');
@@ -250,7 +250,7 @@ function InstallStepper({ setServer }) {
250250
(async () => {
251251
setInstallStatus('pending');
252252
const condaExists = await window.electron.ipcRenderer.invoke(
253-
'server:checkIfCondaEnvironmentExists'
253+
'server:checkIfCondaEnvironmentExists',
254254
);
255255
console.log(JSON.stringify(condaExists));
256256
if (condaExists?.status == 'success') {
@@ -276,13 +276,13 @@ function InstallStepper({ setServer }) {
276276

277277
(async () => {
278278
const ipcResponse = await window.electron.ipcRenderer.invoke(
279-
'server:checkDependencies'
279+
'server:checkDependencies',
280280
);
281281

282282
if (ipcResponse?.status == 'success' && ipcResponse?.data?.length == 0) {
283283
setInstallStatus('success');
284284
setActiveStep(
285-
Steps.indexOf('CHECK_IF_PYTHON_DEPENDENCIES_INSTALLED') + 1
285+
Steps.indexOf('CHECK_IF_PYTHON_DEPENDENCIES_INSTALLED') + 1,
286286
);
287287
} else {
288288
setInstallStatus('notstarted');
@@ -314,7 +314,7 @@ function InstallStepper({ setServer }) {
314314

315315
(async () => {
316316
const p = await fetch(
317-
'http://localhost:8338/plugins/list_missing_plugins_for_current_platform'
317+
'http://localhost:8338/plugins/list_missing_plugins_for_current_platform',
318318
);
319319
const json = await p.json();
320320
setMissingPlugins(json);
@@ -352,7 +352,7 @@ function InstallStepper({ setServer }) {
352352

353353
console.log('Starting Server');
354354
const start_process = await window.electron.ipcRenderer.invoke(
355-
'server:startLocalServer'
355+
'server:startLocalServer',
356356
);
357357

358358
if (start_process?.status == 'error') {
@@ -375,7 +375,7 @@ function InstallStepper({ setServer }) {
375375
'API is Installed',
376376
async () => {
377377
const serverIsInstalled = await window.electron.ipcRenderer.invoke(
378-
'server:checkIfInstalledLocally'
378+
'server:checkIfInstalledLocally',
379379
);
380380
if (serverIsInstalled) {
381381
setInstallStatus('success');
@@ -394,7 +394,7 @@ function InstallStepper({ setServer }) {
394394
setInstallStatus('error');
395395
},
396396
2000,
397-
8
397+
8,
398398
);
399399
}
400400

@@ -405,13 +405,13 @@ function InstallStepper({ setServer }) {
405405
'Server Version is Updated',
406406
async () => {
407407
const ver = await window.electron.ipcRenderer.invoke(
408-
'server:checkLocalVersion'
408+
'server:checkLocalVersion',
409409
);
410410

411411
let json = {};
412412
try {
413413
const rel = await fetch(
414-
'https://api.github.com/repos/transformerlab/transformerlab-api/releases/latest'
414+
'https://api.github.com/repos/transformerlab/transformerlab-api/releases/latest',
415415
);
416416
json = await rel.json();
417417
} catch {
@@ -436,27 +436,27 @@ function InstallStepper({ setServer }) {
436436
setInstallStatus('error');
437437
},
438438
2000,
439-
8
439+
8,
440440
);
441441
}
442442

443443
async function checkIfCondaIsInstalled() {
444444
setInstallStatus('pending');
445445
const installConda = await window.electron.ipcRenderer.invoke(
446-
'server:install_conda'
446+
'server:install_conda',
447447
);
448448
if (installConda?.error) {
449449
setInstallStatus('error');
450450
setErrorMessage(installConda?.stderr);
451451
alert(
452-
'Conda could not be installed. Try running "~/.transformerlab/src/install.sh install_conda" in your terminal. This can sometimes be caused by a file permission error where the ~/.conda directory on your machine is not accessible to your user account.'
452+
'Conda could not be installed. Try running "~/.transformerlab/src/install.sh install_conda" in your terminal. This can sometimes be caused by a file permission error where the ~/.conda directory on your machine is not accessible to your user account.',
453453
);
454454
setThinking(false);
455455
setActiveStep(Steps.indexOf('CHECK_IF_INSTALLED'));
456456
setUserRequestedInstall(false);
457457
}
458458
const condaExists = await window.electron.ipcRenderer.invoke(
459-
'server:checkIfCondaExists'
459+
'server:checkIfCondaExists',
460460
);
461461
if (condaExists) {
462462
setInstallStatus('success');
@@ -467,7 +467,7 @@ function InstallStepper({ setServer }) {
467467
'Conda is Installed',
468468
async () => {
469469
const condaExists = await window.electron.ipcRenderer.invoke(
470-
'server:checkIfCondaExists'
470+
'server:checkIfCondaExists',
471471
);
472472
if (condaExists) {
473473
setInstallStatus('success');
@@ -480,17 +480,17 @@ function InstallStepper({ setServer }) {
480480
setInstallStatus('error');
481481
},
482482
2000,
483-
8
483+
8,
484484
);
485485
}
486486

487487
async function checkIfCondaEnvironmentExists() {
488488
setInstallStatus('pending');
489489
const installConda = await window.electron.ipcRenderer.invoke(
490-
'server:install_create-conda-environment'
490+
'server:install_create-conda-environment',
491491
);
492492
const condaExists = await window.electron.ipcRenderer.invoke(
493-
'server:checkIfCondaEnvironmentExists'
493+
'server:checkIfCondaEnvironmentExists',
494494
);
495495
if (condaExists?.status == 'success') {
496496
setInstallStatus('success');
@@ -513,17 +513,17 @@ function InstallStepper({ setServer }) {
513513
setInstallStatus('pending');
514514
setDependenciesErrorMessage(null);
515515
await window.electron.ipcRenderer.invoke(
516-
'server:install_install-dependencies'
516+
'server:install_install-dependencies',
517517
);
518518

519519
const ipcResponse = await window.electron.ipcRenderer.invoke(
520-
'server:checkDependencies'
520+
'server:checkDependencies',
521521
);
522522

523523
if (ipcResponse?.status == 'success' && ipcResponse?.data?.length == 0) {
524524
setInstallStatus('success');
525525
setActiveStep(
526-
Steps.indexOf('CHECK_IF_PYTHON_DEPENDENCIES_INSTALLED') + 1
526+
Steps.indexOf('CHECK_IF_PYTHON_DEPENDENCIES_INSTALLED') + 1,
527527
);
528528
return;
529529
}
@@ -541,7 +541,7 @@ function InstallStepper({ setServer }) {
541541
async function checkForPlugins() {
542542
setInstallingPlugins(true);
543543
await fetch(
544-
'http://localhost:8338/plugins/install_missing_plugins_for_current_platform'
544+
'http://localhost:8338/plugins/install_missing_plugins_for_current_platform',
545545
);
546546
setInstallingPlugins(false);
547547
setMissingPlugins([]);
@@ -728,7 +728,8 @@ function InstallStepper({ setServer }) {
728728
thisStep={Steps.indexOf('CHECK_IF_CONDA_INSTALLED')}
729729
title={
730730
<>
731-
Check if Conda is Installed at ~/.transformerlab/miniconda3/{' '}
731+
Check if Conda is Installed at
732+
~/.transformerlab/miniforge3/{' '}
732733
</>
733734
}
734735
activeStep={activeStep}

0 commit comments

Comments
 (0)