Skip to content

Commit 8e73491

Browse files
author
Keivan Vosoughi
committed
Add Data Augmentation Icon
1 parent decfbba commit 8e73491

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed
Lines changed: 13 additions & 0 deletions
Loading

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import { File, WorkflowType } from './types';
88
import { useFetchModels } from '../../api/api';
99
import { MODEL_PROVIDER_LABELS } from './constants';
1010
import { ModelProviders, ModelProvidersDropdownOpts } from './types';
11-
import { useWizardCtx } from './utils';
11+
import { getWizardModel, getWizardModeType, useWizardCtx } from './utils';
1212
import FileSelectorButton from './FileSelectorButton';
1313
import UseCaseSelector from './UseCaseSelector';
14+
import { useLocation } from 'react-router-dom';
15+
import { WizardModeType } from '../../types';
16+
import { get } from 'lodash';
1417

1518

1619
const StepContainer = styled(Flex)`
@@ -39,7 +42,7 @@ export const USECASE_OPTIONS = [
3942
export const WORKFLOW_OPTIONS = [
4043
{ label: 'Supervised Fine-Tuning', value: 'supervised-fine-tuning' },
4144
{ label: 'Custom Data Generation', value: 'custom' },
42-
{ label: 'Freeform Data Generation', value: 'freeform' }
45+
// { label: 'Freeform Data Generation', value: 'freeform' }
4346
];
4447

4548
export const MODEL_TYPE_OPTIONS: ModelProvidersDropdownOpts = [
@@ -48,6 +51,21 @@ export const MODEL_TYPE_OPTIONS: ModelProvidersDropdownOpts = [
4851
];
4952

5053
const Configure = () => {
54+
const location = useLocation();
55+
const [wizardModeType, setWizardModeType] = useState(getWizardModeType(location));
56+
// const wizardModeType = getWizardModeType(location);
57+
console.log('location', location);
58+
console.log('wizardModeType', wizardModeType);
59+
60+
useEffect(() => {
61+
if (wizardModeType === WizardModeType.DATA_AUGMENTATION) {
62+
setWizardModeType(WizardModeType.DATA_AUGMENTATION);
63+
form.setFieldValue('workflow_type', 'freeform');
64+
} else {
65+
setWizardModeType(WizardModeType.DATA_GENERATION);
66+
}
67+
}, [location, wizardModeType]);
68+
5169
const form = Form.useFormInstance();
5270
const formData = Form.useWatch((values) => values, form);
5371
const { setIsStepValid } = useWizardCtx();
@@ -121,6 +139,8 @@ const Configure = () => {
121139
setSelectedFiles([]);
122140
}
123141
}
142+
console.log('formData', formData);
143+
console.log(wizardModeType === WizardModeType.DATA_AUGMENTATION);
124144

125145
return (
126146
<StepContainer justify='center'>
@@ -141,8 +161,10 @@ const Configure = () => {
141161
label='Model Provider'
142162
rules={[{ required: true }]}
143163
labelCol={labelCol}
164+
shouldUpdate
144165
>
145166
<Select
167+
146168
onChange={() => form.setFieldValue('model_id', undefined)}
147169
placeholder={'Select a model provider'}
148170
>
@@ -210,6 +232,7 @@ const Configure = () => {
210232
label='Workflow'
211233
tooltip='A specialized workflow for your dataset'
212234
labelCol={labelCol}
235+
hidden={wizardModeType === WizardModeType.DATA_AUGMENTATION}
213236
shouldUpdate
214237
rules={[
215238
{ required: true }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const DataGenerator: FunctionComponent<Props> = ({ mode }) => {
108108

109109
// Data passed from listing table to prepopulate form
110110
const location = useLocation();
111+
console.log('DataGenerator location: ', location);
111112
const { generate_file_name } = useParams();
112113
const initialData = location?.state?.data;
113114
const mutation = useMutation({

app/client/src/pages/DataGenerator/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { WizardCtxObj } from './types';
33
import moment from 'moment';
44
import toString from 'lodash/toString';
55
import { File } from './types';
6+
import { WizardModeType } from '../../types';
67

78
export const WizardCtx = createContext<WizardCtxObj | null>(null);
89
export const useWizardCtx = (): WizardCtxObj => {
@@ -105,3 +106,15 @@ export const getHttpStatusCodeVerb = (statusCode: number) => {
105106
return null;
106107
}
107108
};
109+
110+
export const getWizardModeType = (location: any) => {
111+
const pathname = location?.pathname || '';
112+
switch (pathname) {
113+
case '/data-augmentation':
114+
return WizardModeType.DATA_AUGMENTATION;
115+
case '/data-generator':
116+
return WizardModeType.DATA_GENERATION;
117+
default:
118+
return null;
119+
}
120+
}

app/client/src/pages/Home/HomePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ const HomePage: React.FC = () => {
117117
</div>
118118
</div>
119119
</HeaderSection>
120-
<HeaderSection>
121-
<div className="left-section">
120+
<HeaderSection style={{ marginLeft: '1rem' }}>
121+
<div className="left-section" style={{ padding: '5px' }}>
122122
<img src={DataAugmentationIcon} alt="Datasets" />
123123
</div>
124124
<div className="middle-section">

app/client/src/routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const router = createBrowserRouter([
4040
loader: async () => null
4141
},
4242
{
43-
path: Pages.GENERATOR,
43+
path: Pages.DATA_AUGMENTATION,
4444
element: <DataGenerator key={Pages.DATA_AUGMENTATION} mode={WizardModeType.DATA_AUGMENTATION}/>,
4545
errorElement: <ErrorPage />,
4646
loader: async () => null

0 commit comments

Comments
 (0)