-
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.
Merge pull request #2522 from Gkrumbach07/story/RHOAIENG-2983-experim…
…ents-data-filters Story/rhoaieng 2983 experiments data filters
- Loading branch information
Showing
22 changed files
with
765 additions
and
43 deletions.
There are no files selected for viewing
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
41 changes: 34 additions & 7 deletions
41
frontend/src/concepts/pipelines/apiHooks/useExperiments.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 |
---|---|---|
@@ -1,24 +1,51 @@ | ||
import * as React from 'react'; | ||
import { ExperimentKFv2 } from '~/concepts/pipelines/kfTypes'; | ||
import { ExperimentKFv2, PipelinesFilterOp, StorageStateKF } from '~/concepts/pipelines/kfTypes'; | ||
import { usePipelinesAPI } from '~/concepts/pipelines/context'; | ||
import usePipelineQuery from '~/concepts/pipelines/apiHooks/usePipelineQuery'; | ||
import { PipelineListPaged, PipelineOptions } from '~/concepts/pipelines/types'; | ||
import { FetchState } from '~/utilities/useFetchState'; | ||
|
||
const useExperiments = ( | ||
const useExperimentsByStorageState = ( | ||
options?: PipelineOptions, | ||
storageState?: StorageStateKF, | ||
): FetchState<PipelineListPaged<ExperimentKFv2>> => { | ||
const { api } = usePipelinesAPI(); | ||
return usePipelineQuery<ExperimentKFv2>( | ||
React.useCallback( | ||
(opts, params) => | ||
api | ||
.listExperiments(opts, params) | ||
.then((result) => ({ ...result, items: result.experiments })), | ||
[api], | ||
(opts, params) => { | ||
const predicates = params?.filter?.predicates || []; | ||
if (storageState) { | ||
predicates.push({ | ||
key: 'storage_state', | ||
operation: PipelinesFilterOp.EQUALS, | ||
// eslint-disable-next-line camelcase | ||
string_value: storageState, | ||
}); | ||
} | ||
return api | ||
.listExperiments(opts, { | ||
...params, | ||
filter: { predicates }, | ||
}) | ||
.then((result) => ({ ...result, items: result.experiments })); | ||
}, | ||
[api, storageState], | ||
), | ||
options, | ||
); | ||
}; | ||
|
||
const useExperiments = (options?: PipelineOptions): FetchState<PipelineListPaged<ExperimentKFv2>> => | ||
useExperimentsByStorageState(options); | ||
|
||
export const useActiveExperiments = ( | ||
options?: PipelineOptions, | ||
): FetchState<PipelineListPaged<ExperimentKFv2>> => | ||
useExperimentsByStorageState(options, StorageStateKF.AVAILABLE); | ||
|
||
export const useArchivedExperiments = ( | ||
options?: PipelineOptions, | ||
): FetchState<PipelineListPaged<ExperimentKFv2>> => | ||
useExperimentsByStorageState(options, StorageStateKF.ARCHIVED); | ||
|
||
export default useExperiments; |
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.