Skip to content

Commit 3e622a1

Browse files
ocshawnShawn O'Connor
andauthored
(VPODC-187): clean up apis, show input button (#63)
* VPODC-187: clean up apis, show input button * VPODC-187: fix team project first time loading bug * VPODC-187: map input file to values from api * VPODC-187: fix lint error * VPODC-187: fix lint error and stories * VPODC-187: fix story errors * VPODC-187: fix build error --------- Co-authored-by: Shawn O'Connor <shawnoconnor@uchicago.edu>
1 parent 854c24e commit 3e622a1

File tree

16 files changed

+170
-278
lines changed

16 files changed

+170
-278
lines changed

src/lib/AnalysisApps/GWASResults/TestData/InputViewData/MockedFailureJSON.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ const MockedFailureJSON = {
33
wf_name: 'TestJDRMar29-1130AM',
44
arguments: {
55
parameters: [
6+
{ name: 'dataset_id', value: 12345 },
7+
{ name: 'dataset_observation_window', value: '123' },
8+
{ name: 'outcome_id', value: 123 },
9+
{ name: 'outcome_observation_window', value: '1234' },
10+
{ name: 'n_fold', value: 5 },
11+
{
12+
"name": "model_list",
13+
"value": "[\n {\n \"name\": \"Ada Boost\",\n \"params\":\n {\n \"nEstimators\": [10, 50, 200],\n \"learningRate\": [1.0, 0.5, 0.1],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Decision Tree\",\n \"params\":\n {\n \"criterion\": [\"gini\"],\n \"maxDepth\": [4],\n \"minSamplesSplit\": [2],\n \"minSamplesLeaf\": [10],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Gradient Boosting Machine\",\n \"params\":\n {\n \"ntrees\": [10, 100],\n \"nthread\": 20,\n \"maxDepth\": [4, 6],\n \"learnRate\": [0.1, 0.3],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Iterative Hard Thresholding\",\n \"params\":\n {\n \"K\": 10,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Lasso Cox Regression\",\n \"params\":\n {\n \"variance\": 0.01,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Multilayer Perceptron\",\n \"params\":\n {\n \"hiddenLayerSizes\": [4],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Naive Bayes\",\n \"params\": {}\n },\n {\n \"name\": \"Support Vector Machine\",\n \"params\":\n {\n \"degree\": [1, 3],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Lasso Logistic Regression\",\n \"params\":\n {\n \"variance\": 0.01,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Light Gradient Boosting Machine\",\n \"params\":\n {\n \"numLeaves\": [20, 31],\n \"maxDepth\": [-1, 5],\n \"minDataInLeaf\": [10],\n \"learningRate\": [0.05, 0.1],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Random Forest\",\n \"params\":\n {\n \"ntrees\": [100, 500],\n \"criterion\": [\"gini\"],\n \"maxDepth\": [4, 10, 17],\n \"minSamplesSplit\": [2],\n \"minSamplesLeaf\": [1, 10],\n \"minWeightFractionLeaf\": [0],\n \"mtries\": [\"sqrt\", \"log2\"],\n \"maxLeafNodes\": [100],\n \"minImpurityDecrease\": [0],\n \"bootstrap\": [true],\n \"maxSamples\": [0.9],\n \"oobScore\": [false],\n \"classWeight\": [\"balanced\"],\n \"seed\": 42\n }\n }\n]\n"
14+
},
615
{ name: 'n_pcs', value: null },
716
{
817
name: 'variables',

src/lib/AnalysisApps/GWASResults/TestData/InputViewData/MockedSuccessJSON.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ const MockedSuccessJSON = {
33
wf_name: 'TestJDRMar29-1130AM',
44
arguments: {
55
parameters: [
6-
{ name: 'n_pcs', value: '3' },
6+
{ name: 'dataset_id', value: 12345 },
7+
{ name: 'dataset_observation_window', value: '123' },
8+
{ name: 'outcome_id', value: 123 },
9+
{ name: 'outcome_observation_window', value: '1234' },
10+
{ name: 'n_fold', value: 5 },
11+
{
12+
"name": "model_list",
13+
"value": "[\n {\n \"name\": \"Ada Boost\",\n \"params\":\n {\n \"nEstimators\": [10, 50, 200],\n \"learningRate\": [1.0, 0.5, 0.1],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Decision Tree\",\n \"params\":\n {\n \"criterion\": [\"gini\"],\n \"maxDepth\": [4],\n \"minSamplesSplit\": [2],\n \"minSamplesLeaf\": [10],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Gradient Boosting Machine\",\n \"params\":\n {\n \"ntrees\": [10, 100],\n \"nthread\": 20,\n \"maxDepth\": [4, 6],\n \"learnRate\": [0.1, 0.3],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Iterative Hard Thresholding\",\n \"params\":\n {\n \"K\": 10,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Lasso Cox Regression\",\n \"params\":\n {\n \"variance\": 0.01,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Multilayer Perceptron\",\n \"params\":\n {\n \"hiddenLayerSizes\": [4],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Naive Bayes\",\n \"params\": {}\n },\n {\n \"name\": \"Support Vector Machine\",\n \"params\":\n {\n \"degree\": [1, 3],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Lasso Logistic Regression\",\n \"params\":\n {\n \"variance\": 0.01,\n \"seed\": 42\n }\n },\n {\n \"name\": \"Light Gradient Boosting Machine\",\n \"params\":\n {\n \"numLeaves\": [20, 31],\n \"maxDepth\": [-1, 5],\n \"minDataInLeaf\": [10],\n \"learningRate\": [0.05, 0.1],\n \"seed\": 42\n }\n },\n {\n \"name\": \"Random Forest\",\n \"params\":\n {\n \"ntrees\": [100, 500],\n \"criterion\": [\"gini\"],\n \"maxDepth\": [4, 10, 17],\n \"minSamplesSplit\": [2],\n \"minSamplesLeaf\": [1, 10],\n \"minWeightFractionLeaf\": [0],\n \"mtries\": [\"sqrt\", \"log2\"],\n \"maxLeafNodes\": [100],\n \"minImpurityDecrease\": [0],\n \"bootstrap\": [true],\n \"maxSamples\": [0.9],\n \"oobScore\": [false],\n \"classWeight\": [\"balanced\"],\n \"seed\": 42\n }\n }\n]\n"
14+
},
715
{
816
name: 'variables',
917
value:

src/lib/AnalysisApps/GWASResults/Views/Home/Home.stories.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { useState, useEffect } from 'react';
2+
import { Provider } from 'react-redux';
3+
import { coreStore } from '@gen3/core';
24
import { Meta, StoryObj } from '@storybook/nextjs';
35
//import { QueryClient, QueryClientProvider } from 'react-query';
46
import SharedContext from '../../Utils/SharedContext';
@@ -10,7 +12,7 @@ import InitialHomeTableState from './HomeTableState/InitialHomeTableState';
1012
import { GwasWorkflowEndpoint } from '@/lib/AnalysisApps/SharedUtils/Endpoints';
1113
import { http, HttpResponse, delay } from 'msw';
1214
import { GWASResultsJobs } from './HomeTable/HomeTable';
13-
import { GEN3_API } from '@gen3/core';
15+
import { GEN3_WORKFLOW_API } from '../../../Results/Utils/workflowApi';
1416

1517
const meta: Meta<typeof Home> = {
1618
title: 'Results/Views/Home',
@@ -24,17 +26,18 @@ const meta: Meta<typeof Home> = {
2426
alert(`setCurrentView called with ${currentView}`);
2527
}, [currentView]);*/
2628
return (
27-
<SharedContext.Provider
29+
<Provider store={coreStore}>
30+
<SharedContext.Provider
2831
value={{
2932
selectedRowData,
3033
setSelectedRowData,
3134
setCurrentView,
3235
homeTableState,
3336
setHomeTableState,
34-
}}
35-
>
36-
<Story selectedTeamProject='test' />
37-
</SharedContext.Provider>
37+
}}>
38+
<Story selectedTeamProject='test' />
39+
</SharedContext.Provider>
40+
</Provider>
3841
);
3942
},
4043
],
@@ -123,21 +126,21 @@ export const MockedSuccess: Story = {
123126
msw: {
124127
handlers: [
125128
http.get(
126-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
129+
`${GEN3_WORKFLOW_API}/workflows`,
127130
async () => {
128131
await delay(2000);
129132
return HttpResponse.json(getMockWorkflowList());
130133
}
131134
),
132135
http.get(
133-
`${GwasWorkflowEndpoint}/user-monthly`,
136+
`${GEN3_WORKFLOW_API}/workflows/user-monthly`,
134137
async () => {
135138
await delay(1000);
136139
return HttpResponse.json({ workflow_run: 5, workflow_limit: 50 });
137140
}
138141
),
139142
http.post(
140-
'/ga4gh/wes/v2/retry/:workflow',
143+
`${GEN3_WORKFLOW_API}/retry/:workflow`,
141144
async ({ params }) => {
142145
await delay(800);
143146
const { workflow } = params;
@@ -154,7 +157,7 @@ export const MockedSuccessButFailedRetry: Story = {
154157
msw: {
155158
handlers: [
156159
http.get(
157-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
160+
`${GEN3_WORKFLOW_API}/workflows`,
158161
async () => {
159162
await delay(2000);
160163
return HttpResponse.json(getMockWorkflowList());
@@ -184,7 +187,7 @@ export const MockedError: Story = {
184187
parameters: {
185188
msw: {
186189
handlers: [
187-
http.get(`${GEN3_API}/${GwasWorkflowEndpoint}`, async () => {
190+
http.get(`${GEN3_WORKFLOW_API}/workflows`, async () => {
188191
await delay(1000);
189192
return new HttpResponse(null, {
190193
status: 500,
@@ -201,7 +204,7 @@ export const MockedSuccessButExceededWorkflowLimitForRetries: Story = {
201204
msw: {
202205
handlers: [
203206
http.get(
204-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
207+
`${GEN3_WORKFLOW_API}/workflows`,
205208
async () => {
206209
await delay(2000);
207210
return HttpResponse.json(getMockWorkflowList());
@@ -224,7 +227,7 @@ export const MockedSuccessButWorkflowLimitReturnsMalformedDataForRetries: Story
224227
msw: {
225228
handlers: [
226229
http.get(
227-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
230+
`${GEN3_WORKFLOW_API}/workflows`,
228231
async () => {
229232
await delay(2000);
230233
return HttpResponse.json(getMockWorkflowList());
@@ -250,14 +253,14 @@ export const MockedSuccessButWorkflowLimitReturns500ForRetries: Story = {
250253
msw: {
251254
handlers: [
252255
http.get(
253-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
256+
`${GEN3_WORKFLOW_API}/workflows`,
254257
async () => {
255258
await delay(2000);
256259
return HttpResponse.json(getMockWorkflowList());
257260
},
258261
),
259262
http.get(
260-
`${GEN3_API}/${GwasWorkflowEndpoint}`,
263+
`${GEN3_WORKFLOW_API}/workflows`,
261264
async () => {
262265
await delay(3000);
263266
return new HttpResponse('error', {

src/lib/AnalysisApps/GWASResults/Views/Home/Home.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import React from 'react';
22
import HomeTable from './HomeTable/HomeTable';
33
import LoadingErrorMessage from '../../../SharedUtils/LoadingErrorMessage/LoadingErrorMessage';
44
import { Loader } from '@mantine/core';
5-
import { GEN3_API } from '@gen3/core';
6-
import useSWR from 'swr';
7-
import { GwasWorkflowEndpoint } from '../../../SharedUtils/Endpoints';
5+
import { useGetWorkflowsQuery } from '@/lib/AnalysisApps/Results/Utils/workflowApi';
86

97
const Home = ({ selectedTeamProject }: { selectedTeamProject: string }) => {
108
const tranformDates = (data: any) => {
@@ -15,12 +13,9 @@ const Home = ({ selectedTeamProject }: { selectedTeamProject: string }) => {
1513
finishedAt: new Date(item.finishedAt),
1614
}));
1715
};
18-
const { data, error, isLoading, isValidating } = useSWR(
19-
`${GEN3_API}/${GwasWorkflowEndpoint}?team_projects=${selectedTeamProject}`,
20-
(...args) => fetch(...args).then((res) => res.json().then(tranformDates)),
21-
);
16+
const {data, error, isLoading, isFetching } = useGetWorkflowsQuery(selectedTeamProject);
2217

23-
if (isLoading || isValidating) {
18+
if (isLoading || isFetching) {
2419
return (
2520
<React.Fragment>
2621
<div className="spinner-container">
@@ -35,7 +30,7 @@ const Home = ({ selectedTeamProject }: { selectedTeamProject: string }) => {
3530
return <LoadingErrorMessage />;
3631
}
3732
return (
38-
<HomeTable data={data} />
33+
<HomeTable data={tranformDates(data)} />
3934
);
4035
};
4136

src/lib/AnalysisApps/GWASResults/Views/Home/HomeTable/HomeTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ const HomeTable = ({ data }: { data: GWASResultsJobs[] }) => {
133133
const record = cell.row.original;
134134
return (
135135
<div className='flex items-center gap-2'>
136-
{/*<Button
136+
<Button
137137
onClick={() => {
138138
setSelectedRowData(record);
139139
setCurrentView(VIEWS.input);
140140
}}
141141
>
142142
Input
143143
</Button>
144-
<Button
144+
{/*<Button
145145
onClick={() => {
146146
setSelectedRowData(record);
147147
setCurrentView(VIEWS.execution);

src/lib/AnalysisApps/GWASResults/Views/Input/Input.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { useEffect, useState } from 'react';
2+
import { Provider } from 'react-redux';
3+
import { coreStore } from '@gen3/core';
24
import { Meta, StoryObj } from '@storybook/nextjs';
35
//import { QueryClient, QueryClientProvider } from 'react-query';
46
import SharedContext from '../../Utils/SharedContext';
@@ -34,6 +36,7 @@ const meta: Meta<typeof Input> = {
3436
alert(`setCurrentView called with ${currentView}`);
3537
}, [currentView]);*/
3638
return (
39+
<Provider store={coreStore}>
3740
<SharedContext.Provider
3841
value={{
3942
selectedRowData: selectedRowData,
@@ -44,6 +47,7 @@ const meta: Meta<typeof Input> = {
4447
<Story />
4548
</div>
4649
</SharedContext.Provider>
50+
</Provider>
4751
);
4852
},
4953
],
Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import React, { useContext } from 'react';
22
import { Loader } from '@mantine/core';
3-
//import { useQuery } from 'react-query';
43
import DetailPageHeader from '../../Components/DetailPageHeader/DetailPageHeader';
54
import JobDetails from './JobDetails/JobDetails';
6-
import AttritionTableWrapper from './AttritionTable/AttrtitionTableWrapper';
5+
//import AttritionTableWrapper from './AttritionTable/AttrtitionTableWrapper';
76
import SharedContext from '../../Utils/SharedContext';
8-
import { getDataForWorkflowArtifact } from '../../Utils/gwasWorkflowApi';
97
//import queryConfig from '../../../SharedUtils/QueryConfig';
108
import LoadingErrorMessage from '../../../SharedUtils/LoadingErrorMessage/LoadingErrorMessage';
9+
import { useGetWorkflowDetailsQuery } from '@/lib/AnalysisApps/Results/Utils/workflowApi';
1110

1211
const Input = () => {
1312
const { selectedRowData } = useContext(SharedContext);
1413
if (!selectedRowData) {
1514
throw new Error('selectedRowData is not defined in SharedContext');
1615
}
1716
const { name, uid } = selectedRowData;
18-
const { data, error, isLoading } = getDataForWorkflowArtifact(name, uid, 'attrition_json_index');
17+
const {data, error, isLoading, isFetching } = useGetWorkflowDetailsQuery({
18+
workflowName: name,
19+
workflowUid: uid,
20+
});
1921

2022
const displayTopSection = () => (
2123
<section className='results-top'>
@@ -26,18 +28,8 @@ const Input = () => {
2628
</div>
2729
</section>
2830
);
29-
// Placeholder till feature is implemented
30-
return (
31-
<React.Fragment>
32-
{displayTopSection()}
33-
<LoadingErrorMessage
34-
data-testid='loading-error-message'
35-
message={'If you want to get the input details, download the results zip file'}
36-
/>
37-
</React.Fragment>
38-
);
3931

40-
/*if (isLoading) {
32+
if (isLoading || isFetching) {
4133
return (
4234
<React.Fragment>
4335
{displayTopSection()}
@@ -54,31 +46,18 @@ const Input = () => {
5446
{displayTopSection()}
5547
<LoadingErrorMessage
5648
data-testid='loading-error-message'
57-
message={`Error getting attrition table data due to status: ${error}`}
49+
message={`Error getting job details due to status: ${(error as {error: string})?.error ? (error as {error: string}).error : error}`}
5850
/>
5951
</React.Fragment>
6052
);
6153
}
6254

63-
if (
64-
!data
65-
|| data.length === 0
66-
|| data[0].table_type !== 'case'
67-
) {
68-
return (
69-
<React.Fragment>
70-
{displayTopSection()}
71-
<LoadingErrorMessage message='Error Getting Attrition Table Data' />
72-
</React.Fragment>
73-
);
74-
}
75-
7655
return (
7756
<div className='results-view'>
7857
{displayTopSection()}
79-
<AttritionTableWrapper data={data} />
80-
<JobDetails attritionTableData={data} />
58+
{/*<AttritionTableWrapper data={data} />*/}
59+
<JobDetails data={data}/>
8160
</div>
82-
);*/
61+
);
8362
};
8463
export default Input;

0 commit comments

Comments
 (0)