-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read pipeline run node details from mlmd context
- Loading branch information
1 parent
d2117a5
commit 0c0974f
Showing
9 changed files
with
241 additions
and
33 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
frontend/src/concepts/pipelines/apiHooks/mlmd/useExecutionsFromContext.ts
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,31 @@ | ||
import React from 'react'; | ||
import { usePipelinesAPI } from '~/concepts/pipelines/context'; | ||
import { Context, Execution, GetExecutionsByContextRequest } from '~/third_party/mlmd'; | ||
import { FAST_POLL_INTERVAL } from '~/utilities/const'; | ||
import useFetchState, { | ||
FetchState, | ||
FetchStateCallbackPromise, | ||
NotReadyError, | ||
} from '~/utilities/useFetchState'; | ||
|
||
export const useExecutionsFromContext = ( | ||
context: Context | null, | ||
pipelineFinished?: boolean, | ||
): FetchState<Execution[] | null> => { | ||
const { metadataStoreServiceClient } = usePipelinesAPI(); | ||
|
||
const call = React.useCallback<FetchStateCallbackPromise<Execution[] | null>>(async () => { | ||
if (!context) { | ||
return Promise.reject(new NotReadyError('No context')); | ||
} | ||
|
||
const request = new GetExecutionsByContextRequest(); | ||
request.setContextId(context.getId()); | ||
const res = await metadataStoreServiceClient.getExecutionsByContext(request); | ||
return res.getExecutionsList(); | ||
}, [metadataStoreServiceClient, context]); | ||
|
||
return useFetchState(call, null, { | ||
refreshRate: !pipelineFinished ? FAST_POLL_INTERVAL : undefined, | ||
}); | ||
}; |
48 changes: 48 additions & 0 deletions
48
frontend/src/concepts/pipelines/apiHooks/mlmd/usePipelineRunMlmdContext.ts
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,48 @@ | ||
import React from 'react'; | ||
import { Context } from '~/third_party/mlmd'; | ||
import { usePipelinesAPI } from '~/concepts/pipelines/context'; | ||
import useFetchState, { | ||
FetchState, | ||
FetchStateCallbackPromise, | ||
NotReadyError, | ||
} from '~/utilities/useFetchState'; | ||
import { GetContextByTypeAndNameRequest } from '~/third_party/mlmd/generated/ml_metadata/proto/metadata_store_service_pb'; | ||
import { FAST_POLL_INTERVAL } from '~/utilities/const'; | ||
|
||
const KFP_V2_RUN_CONTEXT_TYPE = 'system.PipelineRun'; | ||
|
||
const useMlmdContext = ( | ||
name?: string, | ||
type?: string, | ||
pipelineFinished?: boolean, | ||
): FetchState<Context | null> => { | ||
const { metadataStoreServiceClient } = usePipelinesAPI(); | ||
|
||
const call = React.useCallback<FetchStateCallbackPromise<Context | null>>(async () => { | ||
if (!type) { | ||
return Promise.reject(new NotReadyError('No context type')); | ||
} | ||
if (!name) { | ||
return Promise.reject(new NotReadyError('No context name')); | ||
} | ||
|
||
const request = new GetContextByTypeAndNameRequest(); | ||
request.setTypeName(type); | ||
request.setContextName(name); | ||
const res = await metadataStoreServiceClient.getContextByTypeAndName(request); | ||
const context = res.getContext(); | ||
if (!context) { | ||
return Promise.reject(new Error('Cannot find specified context')); | ||
} | ||
return context; | ||
}, [metadataStoreServiceClient, type, name]); | ||
|
||
return useFetchState(call, null, { | ||
refreshRate: !pipelineFinished ? FAST_POLL_INTERVAL : undefined, | ||
}); | ||
}; | ||
|
||
export const usePipelineRunMlmdContext = ( | ||
runID?: string, | ||
pipelineFinished?: boolean, | ||
): FetchState<Context | null> => useMlmdContext(runID, KFP_V2_RUN_CONTEXT_TYPE, pipelineFinished); |
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
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
Oops, something went wrong.