Skip to content

Commit

Permalink
Merge pull request #1075 from PintoGideon/bug-fixes
Browse files Browse the repository at this point in the history
Pipelines Rewrite
  • Loading branch information
PintoGideon authored Feb 27, 2024
2 parents 0974e4b + ac1a3ae commit a4f0af0
Show file tree
Hide file tree
Showing 50 changed files with 1,732 additions and 2,776 deletions.
108 changes: 55 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@patternfly/react-table": "^5.2.0",
"@react-hook/resize-observer": "^1.2.6",
"@tanstack/react-query": "^5.17.15",
"antd": "^5.13.2",
"antd": "^5.14.1",
"axios": "^1.6.5",
"chris-utility": "^1.1.6",
"d3-hierarchy": "^1.1.9",
Expand Down
80 changes: 39 additions & 41 deletions src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
type PipelineList,
PluginPiping,
Feed,
PipelineInstance,
Plugin,
PipelinePipingDefaultParameterList,
ComputeResource,
} from "@fnndsc/chrisapi";

export function useSafeDispatch(dispatch: any) {
Expand Down Expand Up @@ -119,7 +121,7 @@ async function fetchResource<T>(
}
return {
resource,
totalCount: resourceList.totalCount,
totalCount: resourceList.totalCount as number,
};
}

Expand Down Expand Up @@ -185,13 +187,6 @@ export const fetchPipelines = async (
search: string,
searchType: string,
) => {
let errorPayload: {
error_message: string;
} = {
error_message: "",
};
let registeredPipelinesList: PipelineList;
let registeredPipelines: PipelineInstance[];
const offset = perPage * (page - 1);
const client = ChrisAPIClient.getClient();
const params = {
Expand All @@ -200,17 +195,17 @@ export const fetchPipelines = async (
[`${searchType}`]: search,
};
try {
registeredPipelinesList = await client.getPipelines(params);
registeredPipelines =
(registeredPipelinesList.getItems() as PipelineInstance[]) || [];
const registeredPipelinesList: PipelineList =
await client.getPipelines(params);
const registeredPipelines =
(registeredPipelinesList.getItems() as Pipeline[]) || [];
return {
registeredPipelines,
registeredPipelinesList,
error: errorPayload,
totalCount: registeredPipelinesList.totalCount,
};
} catch (error) {
const errorObj = catchError(error);
errorPayload = errorObj;
throw new Error(errorObj.error_message);
}
};

Expand All @@ -228,13 +223,12 @@ export async function fetchResources(pipelineInstance: Pipeline) {
params,
boundPipelineFn,
);
const { resource: pipelinePlugins } = await fetchResource(
params,
boundPipelinePluginFn,
);
const parameters = await pipelineInstance.getDefaultParameters({
limit: 1000,
});
const { resource: pipelinePlugins }: { resource: Plugin[] } =
await fetchResource(params, boundPipelinePluginFn);
const parameters: PipelinePipingDefaultParameterList =
await pipelineInstance.getDefaultParameters({
limit: 1000,
});

return {
parameters,
Expand Down Expand Up @@ -271,33 +265,37 @@ export const generatePipelineWithData = async (data: any) => {

export async function fetchComputeInfo(
plugin_id: number,
dictionary_id: number,
dictionary_id: string,
) {
const client = ChrisAPIClient.getClient();
const computeEnvs = await client.getComputeResources({
plugin_id: `${plugin_id}`,
});

if (computeEnvs.getItems()) {
const computeEnvData = {
[dictionary_id]: {
computeEnvs: computeEnvs.data,
currentlySelected: computeEnvs.data[0].name,
},
};
return computeEnvData;
try {
const client = ChrisAPIClient.getClient();
const computeEnvs = await client.getComputeResources({
plugin_id: `${plugin_id}`,
});

if (computeEnvs.getItems()) {
const computeEnvData = {
[dictionary_id]: {
computeEnvs: computeEnvs.getItems() as ComputeResource[],
currentlySelected: computeEnvs.data[0].name as string,
},
};
return computeEnvData;
}
} catch (e) {
throw new Error("Error fetching the compoute Environment");
}
return undefined;
}

export function catchError(errorRequest: any) {
if (errorRequest.response) {
return { error_message: errorRequest.response.data as string };
} else if (errorRequest.message) {
}

if (errorRequest.message) {
return { error_message: errorRequest.message as string };
} else {
return { error_message: errorRequest as string };
}
return { error_message: errorRequest as string };
}

// A function to limit concurrency using Promise.allSettled.
Expand Down Expand Up @@ -386,7 +384,7 @@ export const uploadWrapper = (
const url = `${import.meta.env.VITE_CHRIS_UI_URL}uploadedfiles/`;
return localFiles.map((file) => {
const onUploadProgressWrap = (progressEvent: AxiosProgressEvent) => {
onUploadProgress && onUploadProgress(file, progressEvent);
onUploadProgress?.(file, progressEvent);
};

const promise = uploadFile(
Expand Down
Loading

0 comments on commit a4f0af0

Please sign in to comment.