Skip to content

Commit

Permalink
[ML] DF Analytics creation: switch to includes table (elastic#70009)
Browse files Browse the repository at this point in the history
* update modelMemoryLimit when hyperParams change

* update functional clone tests

* switch excludes table to includes table

* Job configuration details update

* fix jest tests and types

* fix translations and validate includes fields

* fix functional test

* handle empty includes selection

* switch filter to field_value_toggle_group

* update clone functional test
  • Loading branch information
alvarezmelissa87 authored Jul 6, 2020
1 parent 89dcdbb commit 31abd6d
Show file tree
Hide file tree
Showing 24 changed files with 461 additions and 286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ function getError(error) {
export function CustomSelectionTable({
checkboxDisabledCheck,
columns,
currentPage = 0,
filterDefaultFields,
filters,
items,
itemsPerPage = ITEMS_PER_PAGE,
onTableChange,
radioDisabledCheck,
selectedIds,
setCurrentPaginationData,
singleSelection,
sortableProperties,
tableItemId = 'id',
Expand Down Expand Up @@ -80,7 +82,7 @@ export function CustomSelectionTable({
}, [selectedIds]); // eslint-disable-line

useEffect(() => {
const tablePager = new Pager(currentItems.length, itemsPerPage);
const tablePager = new Pager(currentItems.length, itemsPerPage, currentPage);
setPagerSettings({
itemsPerPage: itemsPerPage,
firstItemIndex: tablePager.getFirstItemIndex(),
Expand Down Expand Up @@ -124,6 +126,13 @@ export function CustomSelectionTable({
}
}

if (setCurrentPaginationData) {
setCurrentPaginationData({
pageIndex: pager.getCurrentPageIndex(),
itemsPerPage: pagerSettings.itemsPerPage,
});
}

onTableChange(currentSelected);
}

Expand Down Expand Up @@ -389,13 +398,15 @@ export function CustomSelectionTable({
CustomSelectionTable.propTypes = {
checkboxDisabledCheck: PropTypes.func,
columns: PropTypes.array.isRequired,
currentPage: PropTypes.number,
filterDefaultFields: PropTypes.array,
filters: PropTypes.array,
items: PropTypes.array.isRequired,
itemsPerPage: PropTypes.number,
onTableChange: PropTypes.func.isRequired,
radioDisabledCheck: PropTypes.func,
selectedId: PropTypes.array,
setCurrentPaginationData: PropTypes.func,
singleSelection: PropTypes.bool,
sortableProperties: PropTypes.object,
tableItemId: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ export const AdvancedStep: FC<CreateAnalyticsStepProps> = ({
setCurrentStep,
stepActivated,
}) => {
const showForm = step === ANALYTICS_STEPS.ADVANCED;
const showDetails = step !== ANALYTICS_STEPS.ADVANCED && stepActivated === true;

const dataTestSubj = `mlAnalyticsCreateJobWizardAdvancedStep${showForm ? ' active' : ''}${
showDetails ? ' summary' : ''
}`;

return (
<EuiForm>
{step === ANALYTICS_STEPS.ADVANCED && (
<EuiForm data-test-subj={dataTestSubj}>
{showForm && (
<AdvancedStepForm actions={actions} state={state} setCurrentStep={setCurrentStep} />
)}
{step !== ANALYTICS_STEPS.ADVANCED && stepActivated === true && (
<AdvancedStepDetails setCurrentStep={setCurrentStep} state={state} />
)}
{showDetails && <AdvancedStepDetails setCurrentStep={setCurrentStep} state={state} />}
</EuiForm>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
const [advancedParamErrors, setAdvancedParamErrors] = useState<AdvancedParamErrors>({});
const [fetchingAdvancedParamErrors, setFetchingAdvancedParamErrors] = useState<boolean>(false);

const { setFormState } = actions;
const { setEstimatedModelMemoryLimit, setFormState } = actions;
const { form, isJobCreated } = state;
const {
computeFeatureInfluence,
Expand Down Expand Up @@ -87,10 +87,15 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
useEffect(() => {
setFetchingAdvancedParamErrors(true);
(async function () {
const { success, errorMessage } = await fetchExplainData(form);
const { success, errorMessage, expectedMemory } = await fetchExplainData(form);
const paramErrors: AdvancedParamErrors = {};

if (!success) {
if (success) {
if (modelMemoryLimit !== expectedMemory) {
setEstimatedModelMemoryLimit(expectedMemory);
setFormState({ modelMemoryLimit: expectedMemory });
}
} else {
// Check which field is invalid
Object.values(ANALYSIS_ADVANCED_FIELDS).forEach((param) => {
if (errorMessage.includes(`[${param}]`)) {
Expand Down
Loading

0 comments on commit 31abd6d

Please sign in to comment.