Skip to content

Commit 3c0e6c5

Browse files
authored
Merge pull request #78 from cloudera/DSE-45281
This PR makes the following changes: Increase the refresh rate for the check upgrade call DSE-45281 - Fix for uploading the topics issue not saved in re-generate flow Fix for random error popups while in re-generate path/flow DSE-45283 - Trim the seeds after the upload DSE-45116 - Errors keep popping up in SDS UI
2 parents 3a53dd7 + 8c13379 commit 3c0e6c5

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

app/client/src/pages/DataGenerator/DataGenerator.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import isEmpty from 'lodash/isEmpty';
22
import isString from 'lodash/isString';
33
import { useEffect, useRef, useState } from 'react';
44
import { useLocation, useParams } from 'react-router-dom';
5+
56
import { Button, Flex, Form, Layout, Steps } from 'antd';
67
import type { FormInstance } from 'antd';
78
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
@@ -17,7 +18,8 @@ import Finish from './Finish';
1718

1819
import { DataGenWizardSteps, WizardStepConfig, WorkflowType } from './types';
1920
import { WizardCtx } from './utils';
20-
import { useGetDatasetDetails } from '../DatasetDetails/hooks';
21+
import { fetchDatasetDetails, useGetDatasetDetails } from '../DatasetDetails/hooks';
22+
import { useMutation } from '@tanstack/react-query';
2123

2224
const { Content } = Layout;
2325
// const { Title } = Typography;
@@ -97,28 +99,29 @@ const DataGenerator = () => {
9799
const [current, setCurrent] = useState(0);
98100
const [maxStep, setMaxStep] = useState(0);
99101
const [isStepValid, setIsStepValid] = useState<boolean>(false);
102+
100103
// Data passed from listing table to prepopulate form
101104
const location = useLocation();
102105
const { generate_file_name } = useParams();
103106
const initialData = location?.state?.data;
104-
const datasetDetailsReq = generate_file_name && useGetDatasetDetails(generate_file_name);
105-
console.log('datasetDetailsReq', datasetDetailsReq);
107+
const mutation = useMutation({
108+
mutationFn: fetchDatasetDetails
109+
});
106110

107111

108112
useEffect(() => {
109-
if (
110-
datasetDetailsReq &&
111-
typeof datasetDetailsReq === 'object' &&
112-
'dataset' in datasetDetailsReq &&
113-
!isEmpty(datasetDetailsReq.dataset)
114-
) {
115-
console.log('setting initial dataset....')
113+
if (generate_file_name && !mutation.data) {
114+
mutation.mutate(generate_file_name);
115+
}
116+
if (mutation.data && mutation?.data?.dataset) {
116117
form.setFieldsValue({
117118
...initialData,
118-
...(datasetDetailsReq.dataset as any)
119+
...(mutation?.data?.dataset as any)
119120
});
120121
}
121-
}, [datasetDetailsReq]);
122+
123+
}, [generate_file_name]);
124+
122125

123126
if (initialData?.technique) {
124127
initialData.workflow_type = initialData?.technique === 'sft' ?

app/client/src/pages/DataGenerator/Finish.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ const Finish = () => {
132132

133133
const isDemo = isDemoMode(num_questions, topics, form);
134134

135-
useEffect(() => {
135+
useEffect(() => {
136136
const formValues = form.getFieldsValue(true);
137+
137138
const doc_paths = formValues.doc_paths;
138139
if (Array.isArray(doc_paths) && !isEmpty(doc_paths)) {
139140
if (formValues.workflow_type === WorkflowType.SUPERVISED_FINE_TUNING) {
@@ -183,6 +184,7 @@ const Finish = () => {
183184
}
184185

185186
const args = {...formValues, is_demo: isDemo, model_params: formValues.model_parameters }
187+
console.log('Triggering data generation with args:', args);
186188
triggerPost(args)
187189
}, []);
188190

app/client/src/pages/DataGenerator/Prompt.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ const Prompt = () => {
112112
});
113113

114114
useEffect(() => {
115-
if (!isEmpty(mutation.data)) {
116-
setItems(mutation.data);
117-
form.setFieldValue('topics', mutation.data);
115+
if (!isEmpty(mutation.data && !mutation.isError)) {
116+
const seeds = mutation.data.map((item: string) => item.trim());
117+
setItems(seeds);
118+
form.setFieldValue('topics', seeds);
118119
}
119120
}, [mutation.data]);
120121

@@ -214,6 +215,7 @@ const Prompt = () => {
214215
setCustomTopic('');
215216
};
216217

218+
217219
const onAddFiles = (files: File[]) => {
218220
if (!isEmpty (files)) {
219221
const file = first(files);
@@ -223,6 +225,7 @@ const Prompt = () => {
223225
}
224226
};
225227
}
228+
console.log('mutation data:', mutation);
226229

227230
return (
228231
<Row gutter={[50,0]}>
@@ -315,6 +318,14 @@ const Prompt = () => {
315318
workflow_type === WorkflowType.CUSTOM_DATA_GENERATION ||
316319
workflow_type === WorkflowType.FREE_FORM_DATA_GENERATION) &&
317320
<Flex gap={20} vertical>
321+
{mutation.isError &&
322+
<Alert
323+
message='Error fetching seed instructions'
324+
description={get(mutation.error, 'message', 'An error occurred while fetching seed instructions.')}
325+
type='error'
326+
/>
327+
}
328+
{mutation.isPending && <Alert message='Loading seed instructions...' type='info' />}
318329
<Flex>
319330
<SeedsFormItem
320331
name={'topics'}

app/client/src/pages/DataGenerator/Summary.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const Summary= () => {
5353
examples = []
5454
} = form.getFieldsValue(true);
5555

56+
console.log('Summary form values:', form.getFieldsValue(true));
57+
5658
const cfgStepDataSource = [
5759
{ label: 'Dataset Name', children: display_name },
5860
{ label: 'Usecase', children: use_case },

app/client/src/pages/DatasetDetails/hooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const BASE_API_URL = import.meta.env.VITE_AMP_URL;
99

1010

1111

12-
const fetchDatasetDetails = async (generate_file_name: string) => {
12+
export const fetchDatasetDetails = async (generate_file_name: string) => {
1313
const dataset_details__resp = await fetch(`${BASE_API_URL}/dataset_details/${generate_file_name}`, {
1414
method: 'GET',
1515
});

app/client/src/pages/Home/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export const useUpgradeStatus = () => {
203203
{
204204
queryKey: ["fetchUpgradeStatus", fetchUpgradeStatus],
205205
queryFn: () => fetchUpgradeStatus(),
206-
refetchInterval: 60000
206+
refetchInterval: 10 * 60000
207207
}
208208
);
209209

0 commit comments

Comments
 (0)