Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Data Frame Analytics: adds test pipeline action for DFA trained models in models list #168400

Merged

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Oct 9, 2023

Summary

Related issue: Testing data frame analysis models UI

This PR:

  • Adds ability to test the DFA model directly by adding the 'Test model' action
  • Added a link to the simulate pipeline API via 'Learn more'
  • 'View request body' allows the user to view the request being sent to the simulate pipeline endpoint
  • Checks if the source index exists and adds a dismissible callout with warning text
  • Adds a 'reload' option that gets a random sample doc to test
  • The 'reset' button resets the sample doc to the last used sample doc
image image image

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 self-assigned this Oct 9, 2023
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner October 9, 2023 18:54
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@peteharverson
Copy link
Contributor

Gave this a test and looks good. Some possible enhancements:

  • Add a way to inspect the request being made to simulate the pipeline
  • Add some extra text to clarify that it's using a doc from the source index
  • Check if the source index still exists, and if not, add some warning text
  • Add a control for reloading a different example doc to use in the test (this would be similar to the 'Reload examples' button in the flyout for other non-DFA models
  • Add a control allowing the user to specify the index from which to load the example doc (might want to check that the index contains the fields used in the model)

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

This is ready for a look when you get a chance 🙏 cc @peteharverson, @walterra

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream


interface Props {
sourceIndex?: string;
state: MlInferenceState;
mode: 'standAlone' | 'step';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to move this to an enum-like const, something like:

export const TEST_PIPELINE_MODE = {
  STAND_ALONE: 'stand_alone',
  STEP: 'step',
} as const;
export type TestPipelineMode = typeof TEST_PIPELINE_MODE[keyof typeof TEST_PIPELINE_MODE];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all to use TEST_PIPELINE_MODE in 2c51898

});
},
});
}, [getDocs, sourceIndex]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these depend on each other, maybe these 3 useCallbacks can be combined into a single useMemo, like:

const { getDocs, getSampleDoc, getRandomSampleDoc } = useMemo(() => { ... }, [...]});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 2c51898

defaultMessage="Run a simulation of the pipeline to confirm it produces the anticipated results."
/>{' '}
{state.targetField && (
{mode === 'step' ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to then use the previously mentioned TEST_PIPELINE_MODE.STEP here.

</p>
</EuiText>
</EuiFlexItem>
{mode === 'standAlone' ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use the previously mentioned TEST_PIPELINE_MODE.STAND_ALONE here.

</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<TestPipeline state={state} sourceIndex={sourceIndex} mode="standAlone" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use the previously mentioned TEST_PIPELINE_MODE.STAND_ALONE here.

@@ -157,7 +157,7 @@ export const AddInferencePipelineFlyout: FC<AddInferencePipelineFlyoutProps> = (
/>
)}
{step === ADD_INFERENCE_PIPELINE_STEPS.TEST && (
<TestPipeline sourceIndex={sourceIndex} state={formState} />
<TestPipeline sourceIndex={sourceIndex} state={formState} mode="step" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use TEST_PIPELINE_MODE.STEP here (see comment that suggests replacing the raw strings with an enum-like const).

@@ -15,6 +15,14 @@ import type { ModelItem } from '../models_list';

const PYTORCH_TYPES = Object.values(SUPPORTED_PYTORCH_TASKS);

export function isDfaTrainedModel(modelItem: ModelItem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be more like a type guard, for example:

export function isDfaTrainedModel(arg: unknown): arg is ModelItem) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I don't think it needs to be a type guard since all the items are ModelItem types - it's more checking that certain optional properties exist.

Comment on lines 42 to 46
if (isDfaTrainedModel(modelItem)) {
return true;
}

return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be just:

return isDfaTrainedModel(modelItem);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 2c51898

@jgowdyelastic
Copy link
Member

jgowdyelastic commented Oct 13, 2023

The resize behaviour doesn't adjust the titles. And is a bit buggy, the resize control disappears after use.
IMO the resizer isn't needed at all, can it be disabled?

2023-10-13.12-01-31.2023-10-13.12_01_50.mp4

@alvarezmelissa87
Copy link
Contributor Author

The resize behaviour doesn't adjust the titles. And is a bit buggy, the resize control disappears after use. IMO the resizer isn't needed at all, can it be disabled?

2023-10-13.12-01-31.2023-10-13.12_01_50.mp4

Thanks for taking a look @jgowdyelastic - that's part of an EUI component so agree the best way is to remove the resize option. Removed in 2c51898

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

Responded to all comments and made updates where necessary. This is ready for a final look when you get a chance 🙏
cc @peteharverson, @walterra

});
},
}),
[getDocs, sourceIndex]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If getDocs is nowhere else used than in this useMemo, I was hoping we could move it in there to have just one hook being used for all these queries, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, although they have different dependencies. As is, getSampleDoc and getRandomizedSampleDoc functions are only created once and getDocs only changes as the arguments change.
I might be missing some context but it's unclear to me what the benefits of having it all in one hook are?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that multiple hooks that depend on each other might cause multiple re-renders, whereas all code in a single useMemo/useCallback will just cause one rerender.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #37 / machine learning - short tests model management trained models for ML power user displays a model without an ingest pipeline and model can be deleted

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1818 1820 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 3.5MB 3.5MB +3.5KB
Unknown metric groups

ESLint disabled line counts

id before after diff
ml 555 557 +2

Total ESLint disabled count

id before after diff
ml 558 560 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and LGTM.

Just left a suggestion for some extra EuiSpacer.

<br />
</>
{state.targetField && (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - I think this could do with a couple of EuiSpacers (m) - one between the Test the pipeline results title and the text, and another after the 'Learn more' link and the next two lines.

image

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM

@alvarezmelissa87 alvarezmelissa87 merged commit a304007 into elastic:main Oct 17, 2023
34 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 17, 2023
@alvarezmelissa87 alvarezmelissa87 deleted the ml-trained-models-test-pipeline branch October 17, 2023 15:28
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 18, 2023
…odels in models list (elastic#168400)

## Summary

Related issue: [Testing data frame analysis models
UI](elastic#164440)

This PR:

- Adds ability to test the DFA model directly by adding the 'Test model'
action
- Added a link to the simulate pipeline API via 'Learn more'
- 'View request body' allows the user to view the request being sent to
the simulate pipeline endpoint
- Checks if the source index exists and adds a dismissible callout with
warning text
- Adds a 'reload' option that gets a random sample doc to test
- The 'reset' button resets the sample doc to the last used sample doc

<img width="1614" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/f37430db-5ef4-4088-859c-9f75dd2a14ab">

<img width="1697" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/ad6b785f-6e81-437c-93a6-694d19f43e67">

<img width="1624" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/cbac54b2-b9ed-41f0-8a80-bf7ed40f723f">



### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
benakansara pushed a commit to benakansara/kibana that referenced this pull request Oct 22, 2023
…odels in models list (elastic#168400)

## Summary

Related issue: [Testing data frame analysis models
UI](elastic#164440)

This PR:

- Adds ability to test the DFA model directly by adding the 'Test model'
action
- Added a link to the simulate pipeline API via 'Learn more'
- 'View request body' allows the user to view the request being sent to
the simulate pipeline endpoint
- Checks if the source index exists and adds a dismissible callout with
warning text
- Adds a 'reload' option that gets a random sample doc to test
- The 'reset' button resets the sample doc to the last used sample doc

<img width="1614" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/f37430db-5ef4-4088-859c-9f75dd2a14ab">

<img width="1697" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/ad6b785f-6e81-437c-93a6-694d19f43e67">

<img width="1624" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/cbac54b2-b9ed-41f0-8a80-bf7ed40f723f">



### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
benakansara pushed a commit to benakansara/kibana that referenced this pull request Oct 22, 2023
…odels in models list (elastic#168400)

## Summary

Related issue: [Testing data frame analysis models
UI](elastic#164440)

This PR:

- Adds ability to test the DFA model directly by adding the 'Test model'
action
- Added a link to the simulate pipeline API via 'Learn more'
- 'View request body' allows the user to view the request being sent to
the simulate pipeline endpoint
- Checks if the source index exists and adds a dismissible callout with
warning text
- Adds a 'reload' option that gets a random sample doc to test
- The 'reset' button resets the sample doc to the last used sample doc

<img width="1614" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/f37430db-5ef4-4088-859c-9f75dd2a14ab">

<img width="1697" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/ad6b785f-6e81-437c-93a6-694d19f43e67">

<img width="1624" alt="image"
src="https://github.com/elastic/kibana/assets/6446462/cbac54b2-b9ed-41f0-8a80-bf7ed40f723f">



### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@szabosteve szabosteve changed the title [ML] Data Frame Analytics: add test pipeline action for DFA trained models in models list [ML] Data Frame Analytics: adds test pipeline action for DFA trained models in models list Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Data Frame Analytics ML data frame analytics features :ml release_note:enhancement v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants