Skip to content
Snippets Groups Projects
Commit 1c1ac003 authored by Ali Asaria's avatar Ali Asaria
Browse files

display errors when checking if conda exists

parent 4ce3d0d1
Branches
Tags
No related merge requests found
...@@ -314,7 +314,7 @@ export async function checkIfCondaEnvironmentExists() { ...@@ -314,7 +314,7 @@ export async function checkIfCondaEnvironmentExists() {
if (error) { if (error) {
response.status = 'error'; response.status = 'error';
response.message = 'Conda environment check failed.'; response.message = 'Conda environment check failed.';
response.data = { stdout: '', stderr: stderr.toString() }; response.data = { stdout: stdout?.toString(), stderr: stderr.toString() };
console.log('Conda environment check failed.'); console.log('Conda environment check failed.');
return response; return response;
} }
...@@ -330,8 +330,11 @@ export async function checkIfCondaEnvironmentExists() { ...@@ -330,8 +330,11 @@ export async function checkIfCondaEnvironmentExists() {
stdout.includes(env_path) && stdout.includes(env_path) &&
fs.existsSync(path.join(root_dir, 'envs', 'transformerlab')) fs.existsSync(path.join(root_dir, 'envs', 'transformerlab'))
) { ) {
return true; response.status = 'success';
return response;
} else { } else {
response.status = 'error';
response.message = 'Conda environment "transformerlab" not found.';
return false; return false;
} }
} }
......
...@@ -521,6 +521,7 @@ function CheckIfCondaInstalled({ activeStep, setActiveStep }) { ...@@ -521,6 +521,7 @@ function CheckIfCondaInstalled({ activeStep, setActiveStep }) {
function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) { function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) {
const [installStatus, setInstallStatus] = useState(''); // notstarted, pending, success, error const [installStatus, setInstallStatus] = useState(''); // notstarted, pending, success, error
const [errorMessage, setErrorMessage] = useState(null);
useEffect(() => { useEffect(() => {
if (activeStep !== Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS')) if (activeStep !== Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS'))
...@@ -530,11 +531,16 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) { ...@@ -530,11 +531,16 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) {
const condaExists = await window.electron.ipcRenderer.invoke( const condaExists = await window.electron.ipcRenderer.invoke(
'server:checkIfCondaEnvironmentExists' 'server:checkIfCondaEnvironmentExists'
); );
if (condaExists) { console.log(JSON.stringify(condaExists));
if (condaExists?.status == 'success') {
setInstallStatus('success'); setInstallStatus('success');
setActiveStep(Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1); setActiveStep(Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1);
} else { } else {
setInstallStatus('notstarted'); setInstallStatus('notstarted');
setErrorMessage({
message: condaExists?.message,
data: condaExists?.data,
});
} }
})(); })();
}, [activeStep]); }, [activeStep]);
...@@ -567,12 +573,18 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) { ...@@ -567,12 +573,18 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) {
const condaExists = await window.electron.ipcRenderer.invoke( const condaExists = await window.electron.ipcRenderer.invoke(
'server:checkIfCondaEnvironmentExists' 'server:checkIfCondaEnvironmentExists'
); );
if (condaExists) { if (condaExists?.status == 'success') {
setInstallStatus('success'); setInstallStatus('success');
setActiveStep( setActiveStep(
Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1 Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1
); );
return; return;
} else {
setInstallStatus('error');
setErrorMessage({
message: condaExists?.message,
data: condaExists?.data,
});
} }
setIntervalXTimes( setIntervalXTimes(
async () => { async () => {
...@@ -580,12 +592,18 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) { ...@@ -580,12 +592,18 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) {
await window.electron.ipcRenderer.invoke( await window.electron.ipcRenderer.invoke(
'server:checkIfCondaEnvironmentExists' 'server:checkIfCondaEnvironmentExists'
); );
if (condaExists) { if (condaExists?.status == 'success') {
setInstallStatus('success'); setInstallStatus('success');
setActiveStep( setActiveStep(
Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1 Steps.indexOf('CHECK_IF_CONDA_ENVIRONMENT_EXISTS') + 1
); );
return true; return true;
} else {
setInstallStatus('error');
setErrorMessage({
message: condaExists?.message,
data: condaExists?.data,
});
} }
return false; return false;
}, },
...@@ -599,6 +617,12 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) { ...@@ -599,6 +617,12 @@ function CheckIfCondaEnvironmentExists({ activeStep, setActiveStep }) {
</Button> </Button>
</ButtonGroup> </ButtonGroup>
)} )}
<Typography level="body-sm" color="warning">
{errorMessage?.message}
</Typography>
<Typography level="body-sm" color="neutral">
{errorMessage?.data?.stdout} {errorMessage?.data?.stderr}
</Typography>
</Stack> </Stack>
</> </>
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment