Skip to content
Snippets Groups Projects
Commit 496a474c authored by ali asaria's avatar ali asaria
Browse files

repeatedly try to load tensorboard for slower machines

parent e68f0bd8
No related branches found
Tags llamaindex@0.2.9
No related merge requests found
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Modal, ModalDialog, ModalClose, CircularProgress } from '@mui/joy'; import {
Modal,
ModalDialog,
ModalClose,
CircularProgress,
DialogTitle,
} from '@mui/joy';
import * as chatAPI from 'renderer/lib/transformerlab-api-sdk'; import * as chatAPI from 'renderer/lib/transformerlab-api-sdk';
import { RotateCcwIcon } from 'lucide-react';
const fetcher = (url) => fetch(url).then((res) => res.json()); const fetcher = (url) => fetch(url).then((res) => res.json());
...@@ -10,35 +17,51 @@ export default function TensorboardModal({ ...@@ -10,35 +17,51 @@ export default function TensorboardModal({
}) { }) {
const [iframeReady, setIframeReady] = useState(false); const [iframeReady, setIframeReady] = useState(false);
var currentServerURL = window.TransformerLab.API_URL;
// If there is a port number, remove it:
currentServerURL = currentServerURL.replace(/:[0-9]+\/$/, '');
useEffect(() => { useEffect(() => {
if (currentTensorboard !== -1) { const asyncFunction = async () => {
console.log('starting tensorboard'); if (currentTensorboard !== -1) {
var job_id = currentTensorboard; console.log('starting tensorboard');
fetcher( var job_id = currentTensorboard;
chatAPI.API_URL() + 'train/tensorboard/start?job_id=' + job_id setIframeReady(false);
).then((res) => {
console.log(res);
});
// Wait three secondes (to give tensorboard time to start) before showing the iframe await fetch(
setIframeReady(false); chatAPI.API_URL() + 'train/tensorboard/start?job_id=' + job_id
);
setTimeout(() => { for (let i = 0; i < 8; i++) {
setIframeReady(true); console.log('checking if tensorboard is ready - ' + i);
}, 3000); // Wait three seconds (to give tensorboard time to start) before showing the iframe
} await new Promise((r) => setTimeout(r, 3000));
if (currentTensorboard == -1) { try {
console.log('stopping tensorboard'); const tensorboardIsReady = await fetch(`${currentServerURL}:6006/`);
fetcher(chatAPI.API_URL() + 'train/tensorboard/stop').then((res) => { if (tensorboardIsReady.status === 200) {
console.log(res); setIframeReady(true);
}); break;
} } else {
}, [currentTensorboard]); console.log('tensorboard not ready yet');
}
} catch (e) {
console.error(e);
continue;
}
}
}
var currentServerURL = window.TransformerLab.API_URL; if (currentTensorboard == -1) {
// If there is a port number, remove it: console.log('stopping tensorboard');
currentServerURL = currentServerURL.replace(/:[0-9]+\/$/, ''); fetcher(chatAPI.API_URL() + 'train/tensorboard/stop').then((res) => {
console.log(res);
});
}
};
asyncFunction().catch((e) => console.error(e));
}, [currentTensorboard]);
return ( return (
<Modal <Modal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment