Skip to content

Commit adc657d

Browse files
committed
move more to context
1 parent ce1d848 commit adc657d

File tree

6 files changed

+17
-32
lines changed

6 files changed

+17
-32
lines changed

src/renderer/components/Experiment/Documents/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Sheet } from '@mui/joy';
22
import Documents from '../../Shared/Documents';
33

4-
export default function BigDocumentsPage({ experimentInfo }) {
4+
export default function BigDocumentsPage({}) {
55
return (
66
<Sheet
77
sx={{
@@ -12,7 +12,7 @@ export default function BigDocumentsPage({ experimentInfo }) {
1212
pb: 2,
1313
}}
1414
>
15-
<Documents experimentInfo={experimentInfo} fullPage additionalMessage />
15+
<Documents fullPage additionalMessage />
1616
</Sheet>
1717
);
1818
}

src/renderer/components/Experiment/Eval/Eval.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import Sheet from '@mui/joy/Sheet';
44

5+
import { useExperimentInfo } from 'renderer/lib/ExperimentInfoContext.js';
56
import EvalJobsTable from './EvalJobsTable.tsx';
67
import EvalTasksTable from './EvalTasksTable';
78

8-
export default function Eval({ experimentInfo, experimentInfoMutate }) {
9+
export default function Eval({}) {
10+
const { experimentInfo } = useExperimentInfo();
911
if (!experimentInfo) {
1012
return 'No experiment selected';
1113
}

src/renderer/components/Experiment/Generate/Generate.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Typography, Option, Stack } from '@mui/joy';
99

1010
import GenerateJobsTable from './GenerateJobsTable';
1111
import GenerateTasksTable from './GenerateTasksTable';
12+
import { useExperimentInfo } from 'renderer/lib/ExperimentInfoContext';
1213

1314
function getTemplateParametersForPlugin(pluginName, plugins) {
1415
if (!pluginName || !plugins) {
@@ -28,11 +29,8 @@ function getTemplateParametersForPlugin(pluginName, plugins) {
2829

2930
const fetcher = (url) => fetch(url).then((res) => res.json());
3031

31-
export default function Generate({
32-
experimentInfo,
33-
addGeneration,
34-
experimentInfoMutate,
35-
}) {
32+
export default function Generate({ addGeneration }) {
33+
const { experimentInfo, experimentInfoMutate } = useExperimentInfo();
3634
const [currentPlugin, setCurrentPlugin] = useState('');
3735
const [currentGenerationId, setCurrentGenerationId] = useState('');
3836

src/renderer/components/Experiment/Train/TrainLoRA.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import TensorboardModal from './TensorboardModal';
5151
import ViewOutputModal from './ViewOutputModal';
5252
import ImportRecipeModal from './ImportRecipeModal';
5353
import ViewEvalImagesModal from './ViewEvalImagesModal';
54+
import { useExperimentInfo } from 'renderer/lib/ExperimentInfoContext';
5455
dayjs.extend(relativeTime);
5556
var duration = require('dayjs/plugin/duration');
5657
dayjs.extend(duration);
@@ -96,7 +97,8 @@ function formatJobConfig(c): ReactElement {
9697

9798
const fetcher = (url) => fetch(url).then((res) => res.json());
9899

99-
export default function TrainLoRA({ experimentInfo }) {
100+
export default function TrainLoRA({}) {
101+
const { experimentInfo } = useExperimentInfo();
100102
const [open, setOpen] = useState(false);
101103
const [currentTensorboardForModal, setCurrentTensorboardForModal] =
102104
useState(-1);

src/renderer/components/MainAppPanel.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -363,34 +363,16 @@ export default function MainAppPanel({ setLogsDrawerOpen = null }) {
363363
/>
364364
<Route path="/experiment/embeddings" element={<Embeddings />} />
365365
<Route path="/experiment/tokenize" element={<Tokenize />} />
366-
<Route
367-
path="/experiment/training"
368-
element={<TrainLoRA experimentInfo={experimentInfo} />}
369-
/>
366+
<Route path="/experiment/training" element={<TrainLoRA />} />
370367
<Route
371368
path="/experiment/eval"
372-
element={
373-
<Eval
374-
experimentInfo={experimentInfo}
375-
addEvaluation={experimentAddEvaluation}
376-
experimentInfoMutate={experimentInfoMutate}
377-
/>
378-
}
369+
element={<Eval addEvaluation={experimentAddEvaluation} />}
379370
/>
380371
<Route
381372
path="/experiment/generate"
382-
element={
383-
<Generate
384-
experimentInfo={experimentInfo}
385-
addGeneration={experimentAddGeneration}
386-
experimentInfoMutate={experimentInfoMutate}
387-
/>
388-
}
389-
/>
390-
<Route
391-
path="/experiment/documents"
392-
element={<Documents experimentInfo={experimentInfo} />}
373+
element={<Generate addGeneration={experimentAddGeneration} />}
393374
/>
375+
<Route path="/experiment/documents" element={<Documents />} />
394376
<Route
395377
path="/experiment/rag"
396378
element={

src/renderer/components/Shared/Documents/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { FaRegFilePdf } from 'react-icons/fa6';
5353
import { LuFileJson } from 'react-icons/lu';
5454
import TinyButton from 'renderer/components/Shared/TinyButton';
5555
import * as chatAPI from '../../../lib/transformerlab-api-sdk';
56+
import { useExperimentInfo } from 'renderer/lib/ExperimentInfoContext';
5657

5758
function RowMenu({ experimentInfo, filename, foldername, mutate, row }) {
5859
return (
@@ -314,11 +315,11 @@ const fetcher = (url) => fetch(url).then((res) => res.json());
314315
type Order = 'asc' | 'desc';
315316

316317
export default function Documents({
317-
experimentInfo,
318318
fullPage = false,
319319
additionalMessage = false,
320320
fixedFolder = '',
321321
}) {
322+
const { experimentInfo } = useExperimentInfo();
322323
const [doc, setDoc] = React.useState<Doc>('desc');
323324
const [open, setOpen] = React.useState(false);
324325
const [dropzoneActive, setDropzoneActive] = React.useState(false);

0 commit comments

Comments
 (0)