-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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 map view #81666
[ML] Data frame analytics: Adds map view #81666
Conversation
Pinging @elastic/ml-ui (:ml) |
25ed802
to
5c69dc7
Compare
Opening the map off an outlier job created from a transform on the gallery data set, I always see this error: Response from @alvarezmelissa87 -- @peteharverson I was not able to reproduce this so far. I can add it as a known issue to the meta issue and keep trying. |
const keys = Object.keys(analysis || {}); | ||
|
||
if (keys.length === 1) { | ||
return keys[0] as DataFrameAnalysisConfigType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth checking the actual key value instead of typecasting?
...ication/data_frame_analytics/pages/analytics_management/components/action_map/map_button.tsx
Show resolved
Hide resolved
...lication/data_frame_analytics/pages/analytics_management/components/analytics_list/common.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
export const MapButton: FC<MapButtonProps> = ({ item }) => { | ||
const toolTipContent = i18n.translate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be defined inside of the disabled
condition
...ns/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape_options.tsx
Outdated
Show resolved
Hide resolved
...ns/ml/public/application/data_frame_analytics/pages/job_map/components/cytoscape_options.tsx
Outdated
Show resolved
Hide resolved
boxSelectionEnabled: false, | ||
maxZoom: 3, | ||
minZoom: 0.2, | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quite some @ts-ignore
here 🤔 . is it possible to avoid it? or at least specify the reason
// if (isDataFrameAnalyticsFailed(d.stats.state)) { | ||
// await ml.dataFrameAnalytics.stopDataFrameAnalytics(d.config.id, true); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delete functionality will be added in in a follow up as it requires some refactoring and I'm trying to keep this PR from getting too big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense trying to keep the PR concise! But I believe we should not commit commented code. You can always stash it locally. This article provides an explanation of why, and there are plenty of others
import React, { FC } from 'react'; | ||
import { EuiButton } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { ml } from '../../../../services/ml_api_service'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
const {
services: {
mlServices: { mlApiServices },
},
} = useMlKibana();
instead of a static import
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="xs" color="subdued"> | ||
{'inference model'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we provide a translation for this string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, this should probably be 'trained model'. As @darnautov mentioned, do these legend labels need translations?
import { useRef } from 'react'; | ||
import { useWindowSize } from 'react-use'; | ||
|
||
export function useRefDimensions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useRefDimensions
seems like a misleading name for this hook. And I'm not sure if you need it at all.
Have you tried to use EuiResizeObserver
instead?
import { Cytoscape, Controls, JobMapLegend } from './components'; | ||
import { ml } from '../../../services/ml_api_service'; | ||
// TODO: don't use dep cache - switch to hook | ||
import { getToastNotifications } from '../../../util/dependency_cache'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, please use toastNotifications
from the hook :)
...ns/ml/public/application/data_frame_analytics/pages/job_map/components/use_ref_dimensions.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/data_frame_analytics/pages/job_map/job_map.tsx
Show resolved
Hide resolved
while (complete === false) { | ||
count++; | ||
if (count >= 100) { | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the fixed amount of iterations, a for
loop is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is we don't know how many iteration we need since we're working backwards from the job/model id. We need to keep going until we've hit the source index/transform. The count is just to protect against infinite loops in case something changes or a new case is introduced that we haven't accounted for yet. The 100 limit is just an arbitrary value right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for
loop also supports the break
statement.
if (currentElem !== undefined && nextElem !== undefined) { | ||
result.elements.push({ | ||
data: { | ||
id: `${currentElem.data.id}~${nextElem.data.id}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use ~
as a separator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a way to denote that the edge connects one node id to another node id. It doesn't have any particular significance.
export type MapElements = AnalyticsMapNodeElement | AnalyticsMapEdgeElement; | ||
export interface AnalyticsMapReturnType { | ||
elements: MapElements[]; | ||
details: object; // transform, job, or index details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please specify it as a union type instead?
mlLicense.fullLicenseAPIGuard(async ({ client, request, response }) => { | ||
try { | ||
const { analyticsId } = request.params; | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to avoid this @ts-ignore
|
Noticed this bug when I can't open the flyout again after I closed it Response from @alvarezmelissa87 - This has been added to the meta issue. |
@darnautov - thanks for taking a look! 👍 The refresh indicator stuck in loading has been fixed. I've removed it as we don't need it for the job map. bc2b0f82f908f3958c99ca90d3e5da46f1356b9e What browser are you using when you see the double scroll bars? Yes, dark theme support is a good point - I'll add that as an item in the meta issue. |
@alvarezmelissa87 Also worth checking why bundle size has been increased by 1.4MB. webpack-bundle-analyzer is a great tool for that |
Great work, users can really benefit from getting an overview how all their resources rely to each other! I noticed this layout problem when's there's lots of jobs based off the same source index: Could this maybe improved by making the layout horizontal so that the labels don't overlap on the same line? It also look like there's an issue with the graphs height, it overflows the panels bottom. |
I'm seeing these warnings in dev console: @walterra - thanks for taking a look! 😄 This is an item in the meta issue (near the bottom under Known Issues) and will be addressed in a follow up once the default icon is available. |
1bafe2e
to
725ef83
Compare
export const JOB_MAP_NODE_TYPES = { | ||
ANALYTICS: 'analytics', | ||
TRANSFORM: 'transform', | ||
INDEX_PATTERN: 'index-pattern', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch - it's the index - I've updated it to reflect that 👍 bc2b0f82f908f3958c99ca90d3e5da46f1356b9e
bc2b0f8
to
05273b8
Compare
853be2f
to
39728e2
Compare
ANALYTICS: 'analytics', | ||
TRANSFORM: 'transform', | ||
INDEX: 'index', | ||
INFERENCE_MODEL: 'inferenceModel', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Trained model' is the term we are generally using now, so should probably rename these to be consistent.
display: 'inline-block'; | ||
} | ||
|
||
.mlJobMapLegend__inferenceModel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need renaming to trainedModel
if you switch 'inference model' node type to 'trained model' - see above.
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="xs" color="subdued"> | ||
{'inference model'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, this should probably be 'trained model'. As @darnautov mentioned, do these legend labels need translations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested latest edits and LGTM.
Happy for the layout issue when the map is a single row of nodes to be done in a follow-up. For now, it is easy enough for the user to drag the selection into the middle of the view.
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* add analytics map endpoint and server model * add map action to job and models list * wip:fetch models for jobs. Use url generator * get models when extending node. deduplicate elements * add job type icons. disable map action if job not finished. * move shared const to common dir * persist map tab. handle indexPattern from visualizer * use url generator in models list * temporarily disable delete action in flyout * update legend style. make map horizontal * update dfa model to use spaces changes * format creation time * update from indexPattern to index.remove refresh button * handle index patterns with wildcard
* master: [Security Solution][Detections] Adds framework for replacing API schemas (elastic#82462) [Enterprise Search] Share Loading component (elastic#83246) Consolidates Jest configuration files and scripts (elastic#82671) APM header changes (elastic#82870) [Security Solutions] Adds a default for indicator match custom query of *:* (elastic#81727) [Security Solution] Note 10k object paging limit on Endpoint list (elastic#82889) [packerCache] fix gulp usage, don't archive node_modules (elastic#83327) Upgrade Node.js to version 12 (elastic#61587) [Actions] Removing placeholders and updating validation messages on connector forms (elastic#82734) [Fleet] Rename ingest_manager_api_integration tests fleet_api_integration (elastic#83011) [DOCS] Updates Discover docs (elastic#82773) [ML] Data frame analytics: Adds map view (elastic#81666) enables actions scoped within the stack to register at Basic license (elastic#82931)
Summary
Meta issue with screenshots: #75295
Please add any feedback to the meta issue. Thank you!
This PR is the first part of the map view addition. Items addressed in this PR are the checked items in the meta issue above. Known issues are also included in the meta issue.
Includes fixes for issues found in original draft PR #76952
Delete action in flyout is temporarily commented out and will be addressed in a followup.
Checklist
Delete any items that are not applicable to this PR.