-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #950 from singnet/data-preset-tab
Dataset processing
- Loading branch information
Showing
47 changed files
with
1,646 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { DatasetClient, DatasetEndpoints } from "../../config/DatasetClient"; | ||
|
||
export const SET_MAIN_DATASET = "SET_MAIN_DATASET"; | ||
export const SET_MERGE_DATASET = "SET_MERGE_DATASET"; | ||
export const SET_EXAMPLE_DATASETS = "SET_EXAMPLE_DATASETS"; | ||
export const CLEAR_EXAMPLE_DATASETS = "CLEAR_EXAMPLE_DATASETS"; | ||
export const ADD_RECENT_DATASET = "ADD_RECENT_DATASET"; | ||
export const UPDATE_RECENT_DATASET = "UPDATE_RECENT_DATASET"; | ||
export const CLEAR_RECENT_DATASETS = "CLEAR_RECENT_DATASETS"; | ||
|
||
export const setMainDataset = (dataset) => (dispatch) => { | ||
dispatch({ | ||
type: SET_MAIN_DATASET, | ||
payload: dataset, | ||
}); | ||
}; | ||
|
||
export const setMergeDataset = (dataset) => (dispatch) => { | ||
dispatch({ | ||
type: SET_MERGE_DATASET, | ||
payload: dataset, | ||
}); | ||
}; | ||
|
||
export const setExampleDatasets = (datasetList) => (dispatch) => { | ||
dispatch({ | ||
type: SET_EXAMPLE_DATASETS, | ||
payload: datasetList, | ||
}); | ||
}; | ||
|
||
export const clearExampleDatasets = () => (dispatch) => { | ||
dispatch({ | ||
type: CLEAR_EXAMPLE_DATASETS, | ||
}); | ||
}; | ||
|
||
export const addRecentDataset = (dataset) => (dispatch) => { | ||
dispatch({ | ||
type: ADD_RECENT_DATASET, | ||
payload: dataset, | ||
}); | ||
}; | ||
|
||
export const updateRecentDataset = (datasetKey, additionalInfo) => (dispatch) => { | ||
dispatch({ | ||
type: UPDATE_RECENT_DATASET, | ||
payload: { datasetKey, additionalInfo }, | ||
}); | ||
}; | ||
|
||
export const clearRecentDatasets = () => (dispatch) => { | ||
dispatch({ | ||
type: CLEAR_RECENT_DATASETS, | ||
}); | ||
}; | ||
|
||
export const getDatasetStatistic = (datasetKey) => async (dispatch) => { | ||
const params = new URLSearchParams([["dataset_key", datasetKey]]); | ||
return DatasetClient.get(DatasetEndpoints.VALIDATE_AND_ANALIZE, { params }); | ||
}; | ||
|
||
export const improveDataset = (datasetKey, improveOptionsList) => async (dispatch) => { | ||
const params = { | ||
dataset_key: datasetKey, | ||
improve_options: improveOptionsList.reduce((acc, field) => { | ||
acc[field] = true; | ||
return acc; | ||
}, {}), | ||
}; | ||
return DatasetClient.post(DatasetEndpoints.IMPROVE, params); | ||
}; | ||
|
||
export const mergeDatasets = (mainDataset, mergeDataset) => async (dispatch) => { | ||
const params = { | ||
dataset_key_base: mainDataset, | ||
dataset_key_additional: mergeDataset, | ||
}; | ||
return DatasetClient.post(DatasetEndpoints.VALIDATE_MERGE, params) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
.catch((error) => { | ||
console.error("mergeDatasets Error:", error); | ||
}); | ||
}; | ||
|
||
export const validateMergeDatasets = (mainDataset, mergeDataset) => async (dispatch) => { | ||
const params = { | ||
dataset_key_base: mainDataset, | ||
dataset_key_additional: mergeDataset, | ||
}; | ||
return DatasetClient.post(DatasetEndpoints.MERGE, params) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
.catch((error) => { | ||
console.error("validateMergeDatasets Error:", error); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { datasetActions } from "../actionCreators"; | ||
|
||
const initialState = { | ||
mainDataset: null, | ||
mergeDataset: null, | ||
exampleDatasets: [ | ||
{ | ||
datasetKey: "[email protected]_1733211488305", | ||
name: "DataSet 1: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1733211612606", | ||
name: "DataSet 2: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1733211645798", | ||
name: "DataSet 3: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1733211676614", | ||
name: "DataSet 4: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
], | ||
recentDatasets: [ | ||
{ | ||
datasetKey: "[email protected]_1732864358004", | ||
// link: "https://ozx0e68owf.execute-api.us-east-1.amazonaws.com/download?key=data_instruct_llm_1000.zip_training@singularitynet.io_1732864358004", | ||
name: "DataSet Recent 1: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1732864358004", | ||
// link: "https://ozx0e68owf.execute-api.us-east-1.amazonaws.com/download?key=data_instruct_llm_1000.zip_training@singularitynet.io_1732864358004", | ||
name: "DataSet Recent 2: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1732864358004", | ||
// link: "https://ozx0e68owf.execute-api.us-east-1.amazonaws.com/download?key=data_instruct_llm_1000.zip_training@singularitynet.io_1732864358004", | ||
name: "DataSet Recent 3: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
{ | ||
datasetKey: "[email protected]_1732864358004", | ||
// link: "https://ozx0e68owf.execute-api.us-east-1.amazonaws.com/download?key=data_instruct_llm_1000.zip_training@singularitynet.io_1732864358004", | ||
name: "DataSet Recent 4: Training data for text translation", | ||
size: 51234, | ||
tag: "Text", | ||
}, | ||
], | ||
}; | ||
|
||
const datasetReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case datasetActions.SET_MAIN_DATASET: | ||
return { ...state, mainDataset: action.payload }; | ||
case datasetActions.SET_MERGE_DATASET: | ||
return { ...state, mergeDataset: action.payload }; | ||
case datasetActions.SET_EXAMPLE_DATASETS: | ||
return { ...state, exampleDatasets: action.payload }; | ||
case datasetActions.CLEAR_EXAMPLE_DATASETS: | ||
return { ...state, exampleDatasets: [] }; | ||
case datasetActions.ADD_RECENT_DATASET: | ||
return { ...state, recentDatasets: [action.payload, ...state.recentDatasets] }; | ||
case datasetActions.UPDATE_RECENT_DATASET: | ||
return { | ||
...state, | ||
recentDatasets: state.recentDatasets.map((dataset) => | ||
dataset.datasetKey === action.payload.datasetKey | ||
? { ...dataset, additionalInfo: action.payload.additionalInfo } // Update the matched user | ||
: dataset | ||
), | ||
}; | ||
case datasetActions.CLEAR_RECENT_DATASETS: | ||
return { ...state, recentDatasets: [] }; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default datasetReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/components/ServiceDetails/DataPreset/DashboardModal/ButtonGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { withStyles } from "@mui/styles"; | ||
import { useStyles } from "./styles"; | ||
import StyledButton from "../../../common/StyledButton"; | ||
import TableIcon from "@mui/icons-material/TableChartOutlined"; | ||
import { useDispatch } from "react-redux"; | ||
import { | ||
addRecentDataset, | ||
improveDataset, | ||
setMainDataset, setMergeDataset, | ||
} from "../../../../Redux/actionCreators/DatasetActions"; | ||
import { startAppLoader, stopAppLoader } from "../../../../Redux/actionCreators/LoaderActions"; | ||
import { LoaderContent } from "../../../../utility/constants/LoaderContent"; | ||
|
||
const ButtonsGroup = ({ classes, selectedParameters, isTableView, toggleTableView, dataset, index }) => { | ||
const dispatch = useDispatch(); | ||
|
||
const tableButtonText = isTableView ? "close tablet" : "view tablet"; | ||
|
||
const isImproveButtonDisable = !selectedParameters?.size; | ||
|
||
const getImprovedDataset = async () => { | ||
try{ | ||
dispatch(startAppLoader(LoaderContent.IMPROVE_DATASET)); | ||
const { data } = await dispatch(improveDataset(dataset.datasetKey, Array.from(selectedParameters.keys()))); | ||
const improvedDataset = { | ||
additionalInfo: { | ||
analysis: data.analysis, | ||
datasaet_sample: data.dataset_sample | ||
}, | ||
datasetKey: data.dataset_key_new, | ||
name: dataset.name + "_improved_rate_" + data.analysis.overall_score, | ||
size: dataset.size, | ||
tag: dataset.tag, | ||
}; | ||
await dispatch(addRecentDataset(improvedDataset)); | ||
!index ? await dispatch(setMainDataset(improvedDataset)) : await dispatch(setMergeDataset(improvedDataset)); | ||
} catch (error) { | ||
console.error("getImprovedDataset error", error); | ||
} finally { | ||
dispatch(stopAppLoader()); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={classes.buttonsContainer}> | ||
<StyledButton | ||
type="transparentBlueBorder" | ||
btnText={tableButtonText} | ||
IconComponent={TableIcon} | ||
onClick={toggleTableView} | ||
/> | ||
<StyledButton | ||
disabled={isImproveButtonDisable} | ||
type="gradientAccent" | ||
btnText="IMPROVE" | ||
onClick={getImprovedDataset} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default withStyles(useStyles)(ButtonsGroup); |
Oops, something went wrong.