Skip to content

[ML] Add recognized modules links for Index data visualizer#131342

Merged
qn895 merged 8 commits intoelastic:mainfrom
qn895:ml-dv-register-recognized-modules
May 4, 2022
Merged

[ML] Add recognized modules links for Index data visualizer#131342
qn895 merged 8 commits intoelastic:mainfrom
qn895:ml-dv-register-recognized-modules

Conversation

@qn895
Copy link
Copy Markdown
Member

@qn895 qn895 commented May 2, 2022

Summary

Part of #86387. This PR re-adds recognized module links for the Index data visualizer. It also removes additionalLinks as a props for both Index data visualizer and File data visualizer. It's replaced async asyncLinkCards which is an array of promises that allows for us to pass in multiple links, and to be able to format the content dynamically.
Screen Shot 2022-05-02 at 13 51 40

This PR also moves the link to Discover up top.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@qn895 qn895 self-assigned this May 2, 2022
@qn895 qn895 marked this pull request as ready for review May 2, 2022 21:40
@qn895 qn895 requested a review from a team as a code owner May 2, 2022 21:40
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/ml-ui (:ml)

const [FileDataVisualizer, setFileDataVisualizer] = useState<FileDataVisualizerSpec | null>(null);

const links: ResultLink[] = useMemo(
const asyncLinkCards = useMemo(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These show up when accessing the file view from within the ML plugin, but not when I upload a file from the Kibana Home page - Upload a file.

Copy link
Copy Markdown
Member

@jgowdyelastic jgowdyelastic May 4, 2022

Choose a reason for hiding this comment

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

If I'm remembering correctly, we purposely didn't add any ML links to the file data vis when being used inside kibana's Add Data page.
It would be a lot more work to register the links on start up. We'd have to add a registry for the links to be stored in. Whereas currently the links are passed on component render.

Also most users will not be jumping from there to ML.
There are far more popular plugins in kibana that should come before ML in that list. but when using it inside ML, it makes sense to have links to other parts of ML

@qn895 qn895 requested a review from jgowdyelastic May 3, 2022 15:41
return false;
}
},
} as ResultLink),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rather than asserting ResultLink here, the asyncLinkCards declaration could be asyncLinkCards: AsyncLinkCards

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 846bd87

dataTestSubj: 'dataVisualizerCreateAdvancedJobCard',
},
'data-test-subj': 'dataVisualizerCreateAdvancedJobCard',
} as ResultLink,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than asserting as ResultLink, this function could have a return signature of Promise<ResultLink[]>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 846bd87

}

export type AsyncLinkCards = Array<
(params: AsyncLinkCardParams) => Promise<ResultLink | ResultLink[] | undefined>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would probably simplify the code if we only ever returned an array of ResultLink rather than having to deal with single links.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 846bd87

);
}

if (results) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as mentioned above, if we only ever dealt with ResultLink arrays, this logic could be removed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

alternatively, if we do still need single result links, the single link could be put in an array and processed the same, e.g.

const tempResults = Array.isArray(results) ? results : [results];
return await Promise.all(results.map ....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 846bd87

globalState?: any;
}

export type AsyncLinkCards = Array<
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure about the name AsyncLinkCards
It implies that there are also non-async links cards.
The functions that return the ResultsLinks are all async, so adding the word async to the name seems unnecessary.
Maybe something like GetResultLinks would be more accurate? Although i'm not crazy about that name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 966ff9f

createDataView: boolean;
showFilebeatFlyout(): void;
additionalLinks: ResultLink[];
asyncLinkCards?: AsyncLinkCards;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO the original additionalLinks name is better here.
Possibly changed to getAdditionalLinks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated here 966ff9f

Copy link
Copy Markdown
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
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 latest changes and LGTM

@qn895 qn895 added the Feature:File and Index Data Viz ML file and index data visualizer label May 4, 2022
@qn895
Copy link
Copy Markdown
Member Author

qn895 commented May 4, 2022

@elasticmachine merge upstream

@qn895 qn895 enabled auto-merge (squash) May 4, 2022 17:10
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataVisualizer 347 348 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
dataVisualizer 19 24 +5

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
dataVisualizer 2 3 +1

Async chunks

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

id before after diff
dataVisualizer 539.6KB 540.0KB +377.0B
ml 3.3MB 3.3MB +458.0B
total +835.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 39.3KB 39.5KB +114.0B
Unknown metric groups

API count

id before after diff
dataVisualizer 23 28 +5

History

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

cc @qn895

@qn895 qn895 merged commit a632484 into elastic:main May 4, 2022
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label May 4, 2022
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
…131342)

* [ML] Add dynamic registration of links for both index and file

* [ML] Consolidate type imports

* [ML] Revert uptime changes

* [ML] Fix cards visible when canDisplay is false

* [ML] Shorten create job text

* [ML] Remove as assertions

* [ML] Rename to GetAdditionalLinks

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@qn895 qn895 deleted the ml-dv-register-recognized-modules branch June 8, 2022 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:File and Index Data Viz ML file and index data visualizer :ml release_note:enhancement v8.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants