From 211f1c1251a008a4a1945854dff20ac8e84a4d7a Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 13:16:50 -0500 Subject: [PATCH 01/16] create call to list top 100 most downloaded models --- src/tapis-api/ml-hub/models/list.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/tapis-api/ml-hub/models/list.ts diff --git a/src/tapis-api/ml-hub/models/list.ts b/src/tapis-api/ml-hub/models/list.ts new file mode 100644 index 000000000..c2f37a967 --- /dev/null +++ b/src/tapis-api/ml-hub/models/list.ts @@ -0,0 +1,19 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const list = ( + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => + api.listModels() + ); +}; + +export default list; \ No newline at end of file From 94dfef8f13e436d812aee1f586525e76d38773ae Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 13:17:37 -0500 Subject: [PATCH 02/16] create call to fetch detailed information for a specific model --- src/tapis-api/ml-hub/models/details.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/tapis-api/ml-hub/models/details.ts diff --git a/src/tapis-api/ml-hub/models/details.ts b/src/tapis-api/ml-hub/models/details.ts new file mode 100644 index 000000000..c2f3e06a9 --- /dev/null +++ b/src/tapis-api/ml-hub/models/details.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const details = ( + params: Models.GetModelRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.getModel(params)); +}; + +export default details; \ No newline at end of file From 473609fb28e4a22d1224e997d3ccb1612d8a2e41 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 13:30:32 -0500 Subject: [PATCH 03/16] create api calls for fetch inference server availability and fetch download links --- src/tapis-api/ml-hub/models/downloadLinks.ts | 18 ++++++++++++++++++ .../ml-hub/models/inferenceAvailable.ts | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/tapis-api/ml-hub/models/downloadLinks.ts create mode 100644 src/tapis-api/ml-hub/models/inferenceAvailable.ts diff --git a/src/tapis-api/ml-hub/models/downloadLinks.ts b/src/tapis-api/ml-hub/models/downloadLinks.ts new file mode 100644 index 000000000..a833673a8 --- /dev/null +++ b/src/tapis-api/ml-hub/models/downloadLinks.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const downloadLinks = ( + params: Models.DownloadModelRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.downloadModel(params)); +}; + +export default downloadLinks; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/inferenceAvailable.ts b/src/tapis-api/ml-hub/models/inferenceAvailable.ts new file mode 100644 index 000000000..02951bf63 --- /dev/null +++ b/src/tapis-api/ml-hub/models/inferenceAvailable.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const downloadLinks = ( + params: Models.GetModelInferenceServerRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.getModelInferenceServer(params)); +}; + +export default downloadLinks; \ No newline at end of file From 61da3d94f5e7974911ce1f34dc1ec3a68476efb2 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 13:55:14 -0500 Subject: [PATCH 04/16] api calls to filter models by specified parameters --- src/tapis-api/ml-hub/models/index.ts | 9 +++++++++ src/tapis-api/ml-hub/models/listByAuthor.ts | 18 ++++++++++++++++++ src/tapis-api/ml-hub/models/listByDataset.ts | 18 ++++++++++++++++++ src/tapis-api/ml-hub/models/listByLanguage.ts | 18 ++++++++++++++++++ src/tapis-api/ml-hub/models/listByLibrary.ts | 18 ++++++++++++++++++ src/tapis-api/ml-hub/models/listByQuery.ts | 18 ++++++++++++++++++ src/tapis-api/ml-hub/models/listByTask.ts | 18 ++++++++++++++++++ 7 files changed, 117 insertions(+) create mode 100644 src/tapis-api/ml-hub/models/index.ts create mode 100644 src/tapis-api/ml-hub/models/listByAuthor.ts create mode 100644 src/tapis-api/ml-hub/models/listByDataset.ts create mode 100644 src/tapis-api/ml-hub/models/listByLanguage.ts create mode 100644 src/tapis-api/ml-hub/models/listByLibrary.ts create mode 100644 src/tapis-api/ml-hub/models/listByQuery.ts create mode 100644 src/tapis-api/ml-hub/models/listByTask.ts diff --git a/src/tapis-api/ml-hub/models/index.ts b/src/tapis-api/ml-hub/models/index.ts new file mode 100644 index 000000000..8f5e524e6 --- /dev/null +++ b/src/tapis-api/ml-hub/models/index.ts @@ -0,0 +1,9 @@ +export { default as list } from './list'; +export { default as details } from './details'; +export { default as downloadLinks } from './downloadLinks'; +export { default as listByAuthor } from './listByAuthor'; +export { default as listByDataset } from './listByDataset'; +export { default as listByLanguage } from './listByLanguage'; +export { default as listByLibrary } from './listByLibrary'; +export { default as listByQuery } from './listByQuery'; +export { default as listByTask } from './listByTask'; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByAuthor.ts b/src/tapis-api/ml-hub/models/listByAuthor.ts new file mode 100644 index 000000000..4f029347b --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByAuthor.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByAuthor = ( + params: Models.ListModelsByAuthorRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByAuthor(params)); +}; + +export default listByAuthor; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByDataset.ts b/src/tapis-api/ml-hub/models/listByDataset.ts new file mode 100644 index 000000000..a16ac1506 --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByDataset.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByDataset = ( + params: Models.ListModelsByDatasetRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByDataset(params)); +}; + +export default listByDataset; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByLanguage.ts b/src/tapis-api/ml-hub/models/listByLanguage.ts new file mode 100644 index 000000000..ec2db02c3 --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByLanguage.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByLanguage = ( + params: Models.ListModelsByLanguageRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByLanguage(params)); +}; + +export default listByLanguage; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByLibrary.ts b/src/tapis-api/ml-hub/models/listByLibrary.ts new file mode 100644 index 000000000..007f52604 --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByLibrary.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByLibrary = ( + params: Models.ListModelsByLibraryRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByLibrary(params)); +}; + +export default listByLibrary; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByQuery.ts b/src/tapis-api/ml-hub/models/listByQuery.ts new file mode 100644 index 000000000..868585291 --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByQuery.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByQuery = ( + params: Models.ListModelsByQueryRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByQuery(params)); +}; + +export default listByQuery; \ No newline at end of file diff --git a/src/tapis-api/ml-hub/models/listByTask.ts b/src/tapis-api/ml-hub/models/listByTask.ts new file mode 100644 index 000000000..d4bfda268 --- /dev/null +++ b/src/tapis-api/ml-hub/models/listByTask.ts @@ -0,0 +1,18 @@ +import { Models } from '@tapis/tapis-typescript'; +import { apiGenerator, errorDecoder } from 'tapis-api/utils'; + +const listByTask = ( + params: Models.ListModelsByTaskRequest, + basePath: string, + jwt: string +) => { + const api: Models.ModelsApi = apiGenerator( + Models, + Models.ModelsApi, + basePath, + jwt + ); + return errorDecoder(() => api.listModelsByTask(params)); +}; + +export default listByTask; \ No newline at end of file From 0d38e8d91bb8f81a40aea4eea827f012b2499b09 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 19:01:12 -0500 Subject: [PATCH 05/16] hardcode ml-hub endpoint for 'basePath' for api calls --- src/tapis-hooks/ml-hub/models/modelsPath.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/tapis-hooks/ml-hub/models/modelsPath.ts diff --git a/src/tapis-hooks/ml-hub/models/modelsPath.ts b/src/tapis-hooks/ml-hub/models/modelsPath.ts new file mode 100644 index 000000000..f023f542a --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/modelsPath.ts @@ -0,0 +1,3 @@ +const basePath = 'https://hub.pods.tacc.tapis.io'; + +export default basePath; \ No newline at end of file From 20e552fb5a871f1d2621c6a64a5700dcd6d9b415 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 19:03:00 -0500 Subject: [PATCH 06/16] assign queryKeys and create hooks to fetch 100 top ml models and detailed info for each model --- src/tapis-hooks/ml-hub/models/queryKeys.ts | 13 +++++++++++ src/tapis-hooks/ml-hub/models/useDetails.ts | 26 +++++++++++++++++++++ src/tapis-hooks/ml-hub/models/useList.ts | 26 +++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 src/tapis-hooks/ml-hub/models/queryKeys.ts create mode 100644 src/tapis-hooks/ml-hub/models/useDetails.ts create mode 100644 src/tapis-hooks/ml-hub/models/useList.ts diff --git a/src/tapis-hooks/ml-hub/models/queryKeys.ts b/src/tapis-hooks/ml-hub/models/queryKeys.ts new file mode 100644 index 000000000..8b89dc5cf --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/queryKeys.ts @@ -0,0 +1,13 @@ +const QueryKeys = { + list: 'ml-hub/models/list', + details: 'ml-hub/models/details', + downloadLinks: 'ml-hub/models/downloadLinks', + listByAuthor: 'ml-hub/models/listByAuthor', + listByDataset: 'ml-hub/models/listByDataset', + listByLanguage: 'ml-hub/models/listByLanguage', + listByLibrary: 'ml-hub/models/listByLibrary', + listByQuery: 'ml-hub/models/listByQuery', + listByTask: 'ml-hub/models/listByTask', + }; + + export default QueryKeys; \ No newline at end of file diff --git a/src/tapis-hooks/ml-hub/models/useDetails.ts b/src/tapis-hooks/ml-hub/models/useDetails.ts new file mode 100644 index 000000000..67bda4b6d --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useDetails.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { details } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useDetails = ( + params: Models.GetModelRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.details, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => details(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useDetails; diff --git a/src/tapis-hooks/ml-hub/models/useList.ts b/src/tapis-hooks/ml-hub/models/useList.ts new file mode 100644 index 000000000..61692c832 --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useList.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { list } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useList = ( + options: QueryObserverOptions = {} + ) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.list, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => list(basePath, accessToken?.access_token || ''), + { + ...options, + enabled: !!accessToken, + } + ); + return result; + }; + + export default useList; \ No newline at end of file From c6201f6b83d19d115ed9117dc7d9273f48bc8a59 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Thu, 25 Apr 2024 19:26:20 -0500 Subject: [PATCH 07/16] api hooks to filter models by specified parameters --- src/tapis-hooks/ml-hub/models/index.ts | 9 +++++++ src/tapis-hooks/ml-hub/models/useDetails.ts | 2 +- .../ml-hub/models/useDownloadLinks.ts | 26 ++++++++++++++++++ src/tapis-hooks/ml-hub/models/useList.ts | 2 +- .../ml-hub/models/useListByAuthor.ts | 27 +++++++++++++++++++ .../ml-hub/models/useListByDataset.ts | 27 +++++++++++++++++++ .../ml-hub/models/useListByLanguage.ts | 27 +++++++++++++++++++ .../ml-hub/models/useListByLibrary.ts | 27 +++++++++++++++++++ .../ml-hub/models/useListByQuery.ts | 26 ++++++++++++++++++ .../ml-hub/models/useListByTask.ts | 27 +++++++++++++++++++ 10 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 src/tapis-hooks/ml-hub/models/index.ts create mode 100644 src/tapis-hooks/ml-hub/models/useDownloadLinks.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByAuthor.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByDataset.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByLanguage.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByLibrary.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByQuery.ts create mode 100644 src/tapis-hooks/ml-hub/models/useListByTask.ts diff --git a/src/tapis-hooks/ml-hub/models/index.ts b/src/tapis-hooks/ml-hub/models/index.ts new file mode 100644 index 000000000..3f6ab4ffc --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/index.ts @@ -0,0 +1,9 @@ +export { default as useList } from './useList'; +export { default as useDetails } from './useDetails'; +export { default as useDownloadLinks } from './useDownloadLinks'; +export { default as useListByAuthor } from './useListByAuthor'; +export { default as useListByDataset } from './useListByDataset'; +export { default as useListByLanguage } from './useListByLanguage'; +export { default as useListByLibrary } from './useListByLibrary'; +export { default as useListByQuery } from './useListByQuery'; +export { default as useListByTask } from './useListByTask'; \ No newline at end of file diff --git a/src/tapis-hooks/ml-hub/models/useDetails.ts b/src/tapis-hooks/ml-hub/models/useDetails.ts index 67bda4b6d..bdef56032 100644 --- a/src/tapis-hooks/ml-hub/models/useDetails.ts +++ b/src/tapis-hooks/ml-hub/models/useDetails.ts @@ -10,7 +10,7 @@ const useDetails = ( options: QueryObserverOptions = {} ) => { // const { accessToken, basePath } = useTapisConfig(); - const { accessToken } = useTapisConfig(); // remove and uncomment line above if ml-hub is listed in NGINX + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX const result = useQuery( [QueryKeys.details, params, accessToken], // Default to no token. This will generate a 403 when calling the list function diff --git a/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts b/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts new file mode 100644 index 000000000..ecad038cc --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { downloadLinks } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useDownloadLinks = ( + params: Models.DownloadModelRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.downloadLinks, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => downloadLinks(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useDownloadLinks; \ No newline at end of file diff --git a/src/tapis-hooks/ml-hub/models/useList.ts b/src/tapis-hooks/ml-hub/models/useList.ts index 61692c832..1591a9953 100644 --- a/src/tapis-hooks/ml-hub/models/useList.ts +++ b/src/tapis-hooks/ml-hub/models/useList.ts @@ -9,7 +9,7 @@ const useList = ( options: QueryObserverOptions = {} ) => { // const { accessToken, basePath } = useTapisConfig(); - const { accessToken } = useTapisConfig(); // remove and uncomment line above if ml-hub is listed in NGINX + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX const result = useQuery( [QueryKeys.list, accessToken], // Default to no token. This will generate a 403 when calling the list function diff --git a/src/tapis-hooks/ml-hub/models/useListByAuthor.ts b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts new file mode 100644 index 000000000..fd9066441 --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts @@ -0,0 +1,27 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByAuthor } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByAuthor = ( + params: Models.ListModelsByAuthorRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByAuthor, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByAuthor(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByAuthor; + diff --git a/src/tapis-hooks/ml-hub/models/useListByDataset.ts b/src/tapis-hooks/ml-hub/models/useListByDataset.ts new file mode 100644 index 000000000..bd5aa2b2c --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByDataset.ts @@ -0,0 +1,27 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByDataset } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByDataset = ( + params: Models.ListModelsByDatasetRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByDataset, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByDataset(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByDataset; + diff --git a/src/tapis-hooks/ml-hub/models/useListByLanguage.ts b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts new file mode 100644 index 000000000..0891d7e4f --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts @@ -0,0 +1,27 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByLanguage } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByLanguage = ( + params: Models.ListModelsByLanguageRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByLanguage, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByLanguage(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByLanguage; + diff --git a/src/tapis-hooks/ml-hub/models/useListByLibrary.ts b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts new file mode 100644 index 000000000..d06c2acac --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts @@ -0,0 +1,27 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByLibrary } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByLibrary = ( + params: Models.ListModelsByLibraryRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByLibrary, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByLibrary(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByLibrary; + diff --git a/src/tapis-hooks/ml-hub/models/useListByQuery.ts b/src/tapis-hooks/ml-hub/models/useListByQuery.ts new file mode 100644 index 000000000..4c8c6f39c --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByQuery.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByQuery } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByQuery = ( + params: Models.ListModelsByQueryRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByQuery, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByQuery(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByQuery; \ No newline at end of file diff --git a/src/tapis-hooks/ml-hub/models/useListByTask.ts b/src/tapis-hooks/ml-hub/models/useListByTask.ts new file mode 100644 index 000000000..70f71be8b --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListByTask.ts @@ -0,0 +1,27 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listByTask } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX + +const useListByTask = ( + params: Models.ListModelsByTaskRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listByTask, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listByTask(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListByTask; + From 1d2b8f908d54f26819ccd069ab9cc927a25db105 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 09:33:20 -0500 Subject: [PATCH 08/16] ran prettier and lint --- src/tapis-api/ml-hub/models/details.ts | 2 +- src/tapis-api/ml-hub/models/downloadLinks.ts | 6 ++-- src/tapis-api/ml-hub/models/index.ts | 2 +- .../ml-hub/models/inferenceAvailable.ts | 6 ++-- src/tapis-api/ml-hub/models/list.ts | 11 ++---- src/tapis-api/ml-hub/models/listByAuthor.ts | 6 ++-- src/tapis-api/ml-hub/models/listByDataset.ts | 6 ++-- src/tapis-api/ml-hub/models/listByLanguage.ts | 6 ++-- src/tapis-api/ml-hub/models/listByLibrary.ts | 6 ++-- src/tapis-api/ml-hub/models/listByQuery.ts | 6 ++-- src/tapis-api/ml-hub/models/listByTask.ts | 6 ++-- src/tapis-hooks/ml-hub/models/index.ts | 2 +- src/tapis-hooks/ml-hub/models/modelsPath.ts | 2 +- src/tapis-hooks/ml-hub/models/queryKeys.ts | 24 ++++++------- .../ml-hub/models/useDownloadLinks.ts | 2 +- src/tapis-hooks/ml-hub/models/useList.ts | 36 +++++++++---------- .../ml-hub/models/useListByAuthor.ts | 1 - .../ml-hub/models/useListByDataset.ts | 1 - .../ml-hub/models/useListByLanguage.ts | 1 - .../ml-hub/models/useListByLibrary.ts | 1 - .../ml-hub/models/useListByQuery.ts | 2 +- .../ml-hub/models/useListByTask.ts | 1 - 22 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/tapis-api/ml-hub/models/details.ts b/src/tapis-api/ml-hub/models/details.ts index c2f3e06a9..f34629eb1 100644 --- a/src/tapis-api/ml-hub/models/details.ts +++ b/src/tapis-api/ml-hub/models/details.ts @@ -15,4 +15,4 @@ const details = ( return errorDecoder(() => api.getModel(params)); }; -export default details; \ No newline at end of file +export default details; diff --git a/src/tapis-api/ml-hub/models/downloadLinks.ts b/src/tapis-api/ml-hub/models/downloadLinks.ts index a833673a8..0715204a6 100644 --- a/src/tapis-api/ml-hub/models/downloadLinks.ts +++ b/src/tapis-api/ml-hub/models/downloadLinks.ts @@ -12,7 +12,9 @@ const downloadLinks = ( basePath, jwt ); - return errorDecoder(() => api.downloadModel(params)); + return errorDecoder(() => + api.downloadModel(params) + ); }; -export default downloadLinks; \ No newline at end of file +export default downloadLinks; diff --git a/src/tapis-api/ml-hub/models/index.ts b/src/tapis-api/ml-hub/models/index.ts index 8f5e524e6..820cba47f 100644 --- a/src/tapis-api/ml-hub/models/index.ts +++ b/src/tapis-api/ml-hub/models/index.ts @@ -6,4 +6,4 @@ export { default as listByDataset } from './listByDataset'; export { default as listByLanguage } from './listByLanguage'; export { default as listByLibrary } from './listByLibrary'; export { default as listByQuery } from './listByQuery'; -export { default as listByTask } from './listByTask'; \ No newline at end of file +export { default as listByTask } from './listByTask'; diff --git a/src/tapis-api/ml-hub/models/inferenceAvailable.ts b/src/tapis-api/ml-hub/models/inferenceAvailable.ts index 02951bf63..f0a571cb2 100644 --- a/src/tapis-api/ml-hub/models/inferenceAvailable.ts +++ b/src/tapis-api/ml-hub/models/inferenceAvailable.ts @@ -12,7 +12,9 @@ const downloadLinks = ( basePath, jwt ); - return errorDecoder(() => api.getModelInferenceServer(params)); + return errorDecoder(() => + api.getModelInferenceServer(params) + ); }; -export default downloadLinks; \ No newline at end of file +export default downloadLinks; diff --git a/src/tapis-api/ml-hub/models/list.ts b/src/tapis-api/ml-hub/models/list.ts index c2f37a967..fd77e48eb 100644 --- a/src/tapis-api/ml-hub/models/list.ts +++ b/src/tapis-api/ml-hub/models/list.ts @@ -1,19 +1,14 @@ import { Models } from '@tapis/tapis-typescript'; import { apiGenerator, errorDecoder } from 'tapis-api/utils'; -const list = ( - basePath: string, - jwt: string -) => { +const list = (basePath: string, jwt: string) => { const api: Models.ModelsApi = apiGenerator( Models, Models.ModelsApi, basePath, jwt ); - return errorDecoder(() => - api.listModels() - ); + return errorDecoder(() => api.listModels()); }; -export default list; \ No newline at end of file +export default list; diff --git a/src/tapis-api/ml-hub/models/listByAuthor.ts b/src/tapis-api/ml-hub/models/listByAuthor.ts index 4f029347b..20692c6b9 100644 --- a/src/tapis-api/ml-hub/models/listByAuthor.ts +++ b/src/tapis-api/ml-hub/models/listByAuthor.ts @@ -12,7 +12,9 @@ const listByAuthor = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByAuthor(params)); + return errorDecoder(() => + api.listModelsByAuthor(params) + ); }; -export default listByAuthor; \ No newline at end of file +export default listByAuthor; diff --git a/src/tapis-api/ml-hub/models/listByDataset.ts b/src/tapis-api/ml-hub/models/listByDataset.ts index a16ac1506..bd78a72a0 100644 --- a/src/tapis-api/ml-hub/models/listByDataset.ts +++ b/src/tapis-api/ml-hub/models/listByDataset.ts @@ -12,7 +12,9 @@ const listByDataset = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByDataset(params)); + return errorDecoder(() => + api.listModelsByDataset(params) + ); }; -export default listByDataset; \ No newline at end of file +export default listByDataset; diff --git a/src/tapis-api/ml-hub/models/listByLanguage.ts b/src/tapis-api/ml-hub/models/listByLanguage.ts index ec2db02c3..7b71e19bf 100644 --- a/src/tapis-api/ml-hub/models/listByLanguage.ts +++ b/src/tapis-api/ml-hub/models/listByLanguage.ts @@ -12,7 +12,9 @@ const listByLanguage = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByLanguage(params)); + return errorDecoder(() => + api.listModelsByLanguage(params) + ); }; -export default listByLanguage; \ No newline at end of file +export default listByLanguage; diff --git a/src/tapis-api/ml-hub/models/listByLibrary.ts b/src/tapis-api/ml-hub/models/listByLibrary.ts index 007f52604..78fdafc7d 100644 --- a/src/tapis-api/ml-hub/models/listByLibrary.ts +++ b/src/tapis-api/ml-hub/models/listByLibrary.ts @@ -12,7 +12,9 @@ const listByLibrary = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByLibrary(params)); + return errorDecoder(() => + api.listModelsByLibrary(params) + ); }; -export default listByLibrary; \ No newline at end of file +export default listByLibrary; diff --git a/src/tapis-api/ml-hub/models/listByQuery.ts b/src/tapis-api/ml-hub/models/listByQuery.ts index 868585291..5ea663b16 100644 --- a/src/tapis-api/ml-hub/models/listByQuery.ts +++ b/src/tapis-api/ml-hub/models/listByQuery.ts @@ -12,7 +12,9 @@ const listByQuery = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByQuery(params)); + return errorDecoder(() => + api.listModelsByQuery(params) + ); }; -export default listByQuery; \ No newline at end of file +export default listByQuery; diff --git a/src/tapis-api/ml-hub/models/listByTask.ts b/src/tapis-api/ml-hub/models/listByTask.ts index d4bfda268..332a40b9f 100644 --- a/src/tapis-api/ml-hub/models/listByTask.ts +++ b/src/tapis-api/ml-hub/models/listByTask.ts @@ -12,7 +12,9 @@ const listByTask = ( basePath, jwt ); - return errorDecoder(() => api.listModelsByTask(params)); + return errorDecoder(() => + api.listModelsByTask(params) + ); }; -export default listByTask; \ No newline at end of file +export default listByTask; diff --git a/src/tapis-hooks/ml-hub/models/index.ts b/src/tapis-hooks/ml-hub/models/index.ts index 3f6ab4ffc..3586c0c09 100644 --- a/src/tapis-hooks/ml-hub/models/index.ts +++ b/src/tapis-hooks/ml-hub/models/index.ts @@ -6,4 +6,4 @@ export { default as useListByDataset } from './useListByDataset'; export { default as useListByLanguage } from './useListByLanguage'; export { default as useListByLibrary } from './useListByLibrary'; export { default as useListByQuery } from './useListByQuery'; -export { default as useListByTask } from './useListByTask'; \ No newline at end of file +export { default as useListByTask } from './useListByTask'; diff --git a/src/tapis-hooks/ml-hub/models/modelsPath.ts b/src/tapis-hooks/ml-hub/models/modelsPath.ts index f023f542a..78c52f51a 100644 --- a/src/tapis-hooks/ml-hub/models/modelsPath.ts +++ b/src/tapis-hooks/ml-hub/models/modelsPath.ts @@ -1,3 +1,3 @@ const basePath = 'https://hub.pods.tacc.tapis.io'; -export default basePath; \ No newline at end of file +export default basePath; diff --git a/src/tapis-hooks/ml-hub/models/queryKeys.ts b/src/tapis-hooks/ml-hub/models/queryKeys.ts index 8b89dc5cf..3e459c179 100644 --- a/src/tapis-hooks/ml-hub/models/queryKeys.ts +++ b/src/tapis-hooks/ml-hub/models/queryKeys.ts @@ -1,13 +1,13 @@ const QueryKeys = { - list: 'ml-hub/models/list', - details: 'ml-hub/models/details', - downloadLinks: 'ml-hub/models/downloadLinks', - listByAuthor: 'ml-hub/models/listByAuthor', - listByDataset: 'ml-hub/models/listByDataset', - listByLanguage: 'ml-hub/models/listByLanguage', - listByLibrary: 'ml-hub/models/listByLibrary', - listByQuery: 'ml-hub/models/listByQuery', - listByTask: 'ml-hub/models/listByTask', - }; - - export default QueryKeys; \ No newline at end of file + list: 'ml-hub/models/list', + details: 'ml-hub/models/details', + downloadLinks: 'ml-hub/models/downloadLinks', + listByAuthor: 'ml-hub/models/listByAuthor', + listByDataset: 'ml-hub/models/listByDataset', + listByLanguage: 'ml-hub/models/listByLanguage', + listByLibrary: 'ml-hub/models/listByLibrary', + listByQuery: 'ml-hub/models/listByQuery', + listByTask: 'ml-hub/models/listByTask', +}; + +export default QueryKeys; diff --git a/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts b/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts index ecad038cc..92a44fbac 100644 --- a/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts +++ b/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts @@ -23,4 +23,4 @@ const useDownloadLinks = ( return result; }; -export default useDownloadLinks; \ No newline at end of file +export default useDownloadLinks; diff --git a/src/tapis-hooks/ml-hub/models/useList.ts b/src/tapis-hooks/ml-hub/models/useList.ts index 1591a9953..041a273e6 100644 --- a/src/tapis-hooks/ml-hub/models/useList.ts +++ b/src/tapis-hooks/ml-hub/models/useList.ts @@ -6,21 +6,21 @@ import QueryKeys from './queryKeys'; import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX const useList = ( - options: QueryObserverOptions = {} - ) => { - // const { accessToken, basePath } = useTapisConfig(); - const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX - const result = useQuery( - [QueryKeys.list, accessToken], - // Default to no token. This will generate a 403 when calling the list function - // which is expected behavior for not having a token - () => list(basePath, accessToken?.access_token || ''), - { - ...options, - enabled: !!accessToken, - } - ); - return result; - }; - - export default useList; \ No newline at end of file + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.list, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => list(basePath, accessToken?.access_token || ''), + { + ...options, + enabled: !!accessToken, + } + ); + return result; +}; + +export default useList; diff --git a/src/tapis-hooks/ml-hub/models/useListByAuthor.ts b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts index fd9066441..2584857f2 100644 --- a/src/tapis-hooks/ml-hub/models/useListByAuthor.ts +++ b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts @@ -24,4 +24,3 @@ const useListByAuthor = ( }; export default useListByAuthor; - diff --git a/src/tapis-hooks/ml-hub/models/useListByDataset.ts b/src/tapis-hooks/ml-hub/models/useListByDataset.ts index bd5aa2b2c..e9d237d32 100644 --- a/src/tapis-hooks/ml-hub/models/useListByDataset.ts +++ b/src/tapis-hooks/ml-hub/models/useListByDataset.ts @@ -24,4 +24,3 @@ const useListByDataset = ( }; export default useListByDataset; - diff --git a/src/tapis-hooks/ml-hub/models/useListByLanguage.ts b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts index 0891d7e4f..193ad93ea 100644 --- a/src/tapis-hooks/ml-hub/models/useListByLanguage.ts +++ b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts @@ -24,4 +24,3 @@ const useListByLanguage = ( }; export default useListByLanguage; - diff --git a/src/tapis-hooks/ml-hub/models/useListByLibrary.ts b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts index d06c2acac..33dc77bd5 100644 --- a/src/tapis-hooks/ml-hub/models/useListByLibrary.ts +++ b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts @@ -24,4 +24,3 @@ const useListByLibrary = ( }; export default useListByLibrary; - diff --git a/src/tapis-hooks/ml-hub/models/useListByQuery.ts b/src/tapis-hooks/ml-hub/models/useListByQuery.ts index 4c8c6f39c..c51058f5f 100644 --- a/src/tapis-hooks/ml-hub/models/useListByQuery.ts +++ b/src/tapis-hooks/ml-hub/models/useListByQuery.ts @@ -23,4 +23,4 @@ const useListByQuery = ( return result; }; -export default useListByQuery; \ No newline at end of file +export default useListByQuery; diff --git a/src/tapis-hooks/ml-hub/models/useListByTask.ts b/src/tapis-hooks/ml-hub/models/useListByTask.ts index 70f71be8b..cb85ac691 100644 --- a/src/tapis-hooks/ml-hub/models/useListByTask.ts +++ b/src/tapis-hooks/ml-hub/models/useListByTask.ts @@ -24,4 +24,3 @@ const useListByTask = ( }; export default useListByTask; - From aee8417ab2de999969a05af25bb833e735f2a909 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 10:53:19 -0500 Subject: [PATCH 09/16] updated api calls to 'inferenceServerDetails' and 'listDownloadLinks' --- src/tapis-api/ml-hub/models/index.ts | 3 ++- .../{inferenceAvailable.ts => inferenceServerDetails.ts} | 4 ++-- .../ml-hub/models/{downloadLinks.ts => listDownloadLinks.ts} | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) rename src/tapis-api/ml-hub/models/{inferenceAvailable.ts => inferenceServerDetails.ts} (85%) rename src/tapis-api/ml-hub/models/{downloadLinks.ts => listDownloadLinks.ts} (86%) diff --git a/src/tapis-api/ml-hub/models/index.ts b/src/tapis-api/ml-hub/models/index.ts index 820cba47f..1e589ed5d 100644 --- a/src/tapis-api/ml-hub/models/index.ts +++ b/src/tapis-api/ml-hub/models/index.ts @@ -1,6 +1,7 @@ export { default as list } from './list'; export { default as details } from './details'; -export { default as downloadLinks } from './downloadLinks'; +export { default as inferenceServerDetails } from './inferenceServerDetails'; +export { default as listDownloadLinks } from './listDownloadLinks'; export { default as listByAuthor } from './listByAuthor'; export { default as listByDataset } from './listByDataset'; export { default as listByLanguage } from './listByLanguage'; diff --git a/src/tapis-api/ml-hub/models/inferenceAvailable.ts b/src/tapis-api/ml-hub/models/inferenceServerDetails.ts similarity index 85% rename from src/tapis-api/ml-hub/models/inferenceAvailable.ts rename to src/tapis-api/ml-hub/models/inferenceServerDetails.ts index f0a571cb2..dcbe3b7f1 100644 --- a/src/tapis-api/ml-hub/models/inferenceAvailable.ts +++ b/src/tapis-api/ml-hub/models/inferenceServerDetails.ts @@ -1,7 +1,7 @@ import { Models } from '@tapis/tapis-typescript'; import { apiGenerator, errorDecoder } from 'tapis-api/utils'; -const downloadLinks = ( +const inferenceServerDetails = ( params: Models.GetModelInferenceServerRequest, basePath: string, jwt: string @@ -17,4 +17,4 @@ const downloadLinks = ( ); }; -export default downloadLinks; +export default inferenceServerDetails; diff --git a/src/tapis-api/ml-hub/models/downloadLinks.ts b/src/tapis-api/ml-hub/models/listDownloadLinks.ts similarity index 86% rename from src/tapis-api/ml-hub/models/downloadLinks.ts rename to src/tapis-api/ml-hub/models/listDownloadLinks.ts index 0715204a6..52e050a64 100644 --- a/src/tapis-api/ml-hub/models/downloadLinks.ts +++ b/src/tapis-api/ml-hub/models/listDownloadLinks.ts @@ -1,7 +1,7 @@ import { Models } from '@tapis/tapis-typescript'; import { apiGenerator, errorDecoder } from 'tapis-api/utils'; -const downloadLinks = ( +const listDownloadLinks = ( params: Models.DownloadModelRequest, basePath: string, jwt: string @@ -17,4 +17,4 @@ const downloadLinks = ( ); }; -export default downloadLinks; +export default listDownloadLinks; From 5c7a757c3fb7f08ab8f7d7a86537407a9650ffd9 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 10:55:33 -0500 Subject: [PATCH 10/16] reorganized api folder structure --- src/tapis-api/ml-hub/models/index.ts | 2 +- .../ml-hub/models/{ => inference}/inferenceServerDetails.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/tapis-api/ml-hub/models/{ => inference}/inferenceServerDetails.ts (100%) diff --git a/src/tapis-api/ml-hub/models/index.ts b/src/tapis-api/ml-hub/models/index.ts index 1e589ed5d..680a2bdbd 100644 --- a/src/tapis-api/ml-hub/models/index.ts +++ b/src/tapis-api/ml-hub/models/index.ts @@ -1,6 +1,6 @@ export { default as list } from './list'; export { default as details } from './details'; -export { default as inferenceServerDetails } from './inferenceServerDetails'; +export { default as inferenceServerDetails } from './inference/inferenceServerDetails'; export { default as listDownloadLinks } from './listDownloadLinks'; export { default as listByAuthor } from './listByAuthor'; export { default as listByDataset } from './listByDataset'; diff --git a/src/tapis-api/ml-hub/models/inferenceServerDetails.ts b/src/tapis-api/ml-hub/models/inference/inferenceServerDetails.ts similarity index 100% rename from src/tapis-api/ml-hub/models/inferenceServerDetails.ts rename to src/tapis-api/ml-hub/models/inference/inferenceServerDetails.ts From 24a712ca660864d9c83cea7c43262c5d4949acf2 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:09:15 -0500 Subject: [PATCH 11/16] created useInferenceServerDetails hook --- .../inference/useInferenceServerDetails.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts diff --git a/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts b/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts new file mode 100644 index 000000000..7616ebac9 --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { inferenceServerDetails } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from '../queryKeys'; +import basePath from '../basePath'; // remove if ml-hub is listed in NGINX + +const useInferenceServerDetails = ( + params: Models.DownloadModelRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.inferenceServerDetails, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => inferenceServerDetails(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useInferenceServerDetails; \ No newline at end of file From a0566cc7f01071a1df2bfde15a6042f548154a40 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:09:41 -0500 Subject: [PATCH 12/16] update query keys --- src/tapis-hooks/ml-hub/models/queryKeys.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tapis-hooks/ml-hub/models/queryKeys.ts b/src/tapis-hooks/ml-hub/models/queryKeys.ts index 3e459c179..2eef98274 100644 --- a/src/tapis-hooks/ml-hub/models/queryKeys.ts +++ b/src/tapis-hooks/ml-hub/models/queryKeys.ts @@ -1,13 +1,14 @@ const QueryKeys = { list: 'ml-hub/models/list', details: 'ml-hub/models/details', - downloadLinks: 'ml-hub/models/downloadLinks', + listDownloadLinks: 'ml-hub/models/listDownloadLinks', listByAuthor: 'ml-hub/models/listByAuthor', listByDataset: 'ml-hub/models/listByDataset', listByLanguage: 'ml-hub/models/listByLanguage', listByLibrary: 'ml-hub/models/listByLibrary', listByQuery: 'ml-hub/models/listByQuery', listByTask: 'ml-hub/models/listByTask', + inferenceServerDetails: 'ml-hub/models/inference/inferenceServerDetails', }; export default QueryKeys; From 7ea32e3da48284834c987370cf42fa827fa840aa Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:11:07 -0500 Subject: [PATCH 13/16] changed hook function & filename to 'useListDownloadLinks' --- .../ml-hub/models/useListDownloadLinks.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/tapis-hooks/ml-hub/models/useListDownloadLinks.ts diff --git a/src/tapis-hooks/ml-hub/models/useListDownloadLinks.ts b/src/tapis-hooks/ml-hub/models/useListDownloadLinks.ts new file mode 100644 index 000000000..7916856a1 --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/useListDownloadLinks.ts @@ -0,0 +1,26 @@ +import { useQuery, QueryObserverOptions } from 'react-query'; +import { listDownloadLinks } from 'tapis-api/ml-hub/models'; +import { Models } from '@tapis/tapis-typescript'; +import { useTapisConfig } from 'tapis-hooks'; +import QueryKeys from './queryKeys'; +import basePath from './basePath'; // remove if ml-hub is listed in NGINX + +const useListDownloadLinks = ( + params: Models.DownloadModelRequest, + options: QueryObserverOptions = {} +) => { + // const { accessToken, basePath } = useTapisConfig(); + const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX + const result = useQuery( + [QueryKeys.listDownloadLinks, params, accessToken], + // Default to no token. This will generate a 403 when calling the list function + // which is expected behavior for not having a token + () => listDownloadLinks(params, basePath, accessToken?.access_token ?? ''), + { + enabled: !!accessToken, + } + ); + return result; +}; + +export default useListDownloadLinks; From 6fae54d95f72f4f1ebda9979ecf4ab6e17383efb Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:12:05 -0500 Subject: [PATCH 14/16] changed filename from 'mlhubPath' to 'basePath' --- src/tapis-hooks/ml-hub/models/basePath.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/tapis-hooks/ml-hub/models/basePath.ts diff --git a/src/tapis-hooks/ml-hub/models/basePath.ts b/src/tapis-hooks/ml-hub/models/basePath.ts new file mode 100644 index 000000000..78c52f51a --- /dev/null +++ b/src/tapis-hooks/ml-hub/models/basePath.ts @@ -0,0 +1,3 @@ +const basePath = 'https://hub.pods.tacc.tapis.io'; + +export default basePath; From a2c853098070be376879cf8181435f9fc228cff3 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:12:42 -0500 Subject: [PATCH 15/16] updated basePath imports --- src/tapis-hooks/ml-hub/models/index.ts | 3 ++- src/tapis-hooks/ml-hub/models/modelsPath.ts | 3 --- src/tapis-hooks/ml-hub/models/useDetails.ts | 2 +- .../ml-hub/models/useDownloadLinks.ts | 26 ------------------- src/tapis-hooks/ml-hub/models/useList.ts | 2 +- .../ml-hub/models/useListByAuthor.ts | 2 +- .../ml-hub/models/useListByDataset.ts | 2 +- .../ml-hub/models/useListByLanguage.ts | 2 +- .../ml-hub/models/useListByLibrary.ts | 2 +- .../ml-hub/models/useListByQuery.ts | 2 +- .../ml-hub/models/useListByTask.ts | 2 +- 11 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 src/tapis-hooks/ml-hub/models/modelsPath.ts delete mode 100644 src/tapis-hooks/ml-hub/models/useDownloadLinks.ts diff --git a/src/tapis-hooks/ml-hub/models/index.ts b/src/tapis-hooks/ml-hub/models/index.ts index 3586c0c09..aeddfc023 100644 --- a/src/tapis-hooks/ml-hub/models/index.ts +++ b/src/tapis-hooks/ml-hub/models/index.ts @@ -1,9 +1,10 @@ export { default as useList } from './useList'; export { default as useDetails } from './useDetails'; -export { default as useDownloadLinks } from './useDownloadLinks'; +export { default as useDownloadLinks } from './useListDownloadLinks'; export { default as useListByAuthor } from './useListByAuthor'; export { default as useListByDataset } from './useListByDataset'; export { default as useListByLanguage } from './useListByLanguage'; export { default as useListByLibrary } from './useListByLibrary'; export { default as useListByQuery } from './useListByQuery'; export { default as useListByTask } from './useListByTask'; +export { default as useInferenceServerDetails } from './inference/useInferenceServerDetails'; \ No newline at end of file diff --git a/src/tapis-hooks/ml-hub/models/modelsPath.ts b/src/tapis-hooks/ml-hub/models/modelsPath.ts deleted file mode 100644 index 78c52f51a..000000000 --- a/src/tapis-hooks/ml-hub/models/modelsPath.ts +++ /dev/null @@ -1,3 +0,0 @@ -const basePath = 'https://hub.pods.tacc.tapis.io'; - -export default basePath; diff --git a/src/tapis-hooks/ml-hub/models/useDetails.ts b/src/tapis-hooks/ml-hub/models/useDetails.ts index bdef56032..ec3061770 100644 --- a/src/tapis-hooks/ml-hub/models/useDetails.ts +++ b/src/tapis-hooks/ml-hub/models/useDetails.ts @@ -3,7 +3,7 @@ import { details } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useDetails = ( params: Models.GetModelRequest, diff --git a/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts b/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts deleted file mode 100644 index 92a44fbac..000000000 --- a/src/tapis-hooks/ml-hub/models/useDownloadLinks.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { useQuery, QueryObserverOptions } from 'react-query'; -import { downloadLinks } from 'tapis-api/ml-hub/models'; -import { Models } from '@tapis/tapis-typescript'; -import { useTapisConfig } from 'tapis-hooks'; -import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX - -const useDownloadLinks = ( - params: Models.DownloadModelRequest, - options: QueryObserverOptions = {} -) => { - // const { accessToken, basePath } = useTapisConfig(); - const { accessToken } = useTapisConfig(); // remove this line and uncomment line above if ml-hub is listed in NGINX - const result = useQuery( - [QueryKeys.downloadLinks, params, accessToken], - // Default to no token. This will generate a 403 when calling the list function - // which is expected behavior for not having a token - () => downloadLinks(params, basePath, accessToken?.access_token ?? ''), - { - enabled: !!accessToken, - } - ); - return result; -}; - -export default useDownloadLinks; diff --git a/src/tapis-hooks/ml-hub/models/useList.ts b/src/tapis-hooks/ml-hub/models/useList.ts index 041a273e6..2646af169 100644 --- a/src/tapis-hooks/ml-hub/models/useList.ts +++ b/src/tapis-hooks/ml-hub/models/useList.ts @@ -3,7 +3,7 @@ import { list } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useList = ( options: QueryObserverOptions = {} diff --git a/src/tapis-hooks/ml-hub/models/useListByAuthor.ts b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts index 2584857f2..86ac5457b 100644 --- a/src/tapis-hooks/ml-hub/models/useListByAuthor.ts +++ b/src/tapis-hooks/ml-hub/models/useListByAuthor.ts @@ -3,7 +3,7 @@ import { listByAuthor } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByAuthor = ( params: Models.ListModelsByAuthorRequest, diff --git a/src/tapis-hooks/ml-hub/models/useListByDataset.ts b/src/tapis-hooks/ml-hub/models/useListByDataset.ts index e9d237d32..09da13b21 100644 --- a/src/tapis-hooks/ml-hub/models/useListByDataset.ts +++ b/src/tapis-hooks/ml-hub/models/useListByDataset.ts @@ -3,7 +3,7 @@ import { listByDataset } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByDataset = ( params: Models.ListModelsByDatasetRequest, diff --git a/src/tapis-hooks/ml-hub/models/useListByLanguage.ts b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts index 193ad93ea..58e8e3ede 100644 --- a/src/tapis-hooks/ml-hub/models/useListByLanguage.ts +++ b/src/tapis-hooks/ml-hub/models/useListByLanguage.ts @@ -3,7 +3,7 @@ import { listByLanguage } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByLanguage = ( params: Models.ListModelsByLanguageRequest, diff --git a/src/tapis-hooks/ml-hub/models/useListByLibrary.ts b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts index 33dc77bd5..ebfade970 100644 --- a/src/tapis-hooks/ml-hub/models/useListByLibrary.ts +++ b/src/tapis-hooks/ml-hub/models/useListByLibrary.ts @@ -3,7 +3,7 @@ import { listByLibrary } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByLibrary = ( params: Models.ListModelsByLibraryRequest, diff --git a/src/tapis-hooks/ml-hub/models/useListByQuery.ts b/src/tapis-hooks/ml-hub/models/useListByQuery.ts index c51058f5f..0f31a3371 100644 --- a/src/tapis-hooks/ml-hub/models/useListByQuery.ts +++ b/src/tapis-hooks/ml-hub/models/useListByQuery.ts @@ -3,7 +3,7 @@ import { listByQuery } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByQuery = ( params: Models.ListModelsByQueryRequest, diff --git a/src/tapis-hooks/ml-hub/models/useListByTask.ts b/src/tapis-hooks/ml-hub/models/useListByTask.ts index cb85ac691..04d97216f 100644 --- a/src/tapis-hooks/ml-hub/models/useListByTask.ts +++ b/src/tapis-hooks/ml-hub/models/useListByTask.ts @@ -3,7 +3,7 @@ import { listByTask } from 'tapis-api/ml-hub/models'; import { Models } from '@tapis/tapis-typescript'; import { useTapisConfig } from 'tapis-hooks'; import QueryKeys from './queryKeys'; -import basePath from './modelsPath'; // remove if ml-hub is listed in NGINX +import basePath from './basePath'; // remove if ml-hub is listed in NGINX const useListByTask = ( params: Models.ListModelsByTaskRequest, From 727693bdba821a6f9ef917bdf0b31285ddd2f7a2 Mon Sep 17 00:00:00 2001 From: dhannywi Date: Fri, 26 Apr 2024 11:17:31 -0500 Subject: [PATCH 16/16] ran prettier and lint --- src/tapis-hooks/ml-hub/models/index.ts | 2 +- .../ml-hub/models/inference/useInferenceServerDetails.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tapis-hooks/ml-hub/models/index.ts b/src/tapis-hooks/ml-hub/models/index.ts index aeddfc023..1f8e40a84 100644 --- a/src/tapis-hooks/ml-hub/models/index.ts +++ b/src/tapis-hooks/ml-hub/models/index.ts @@ -7,4 +7,4 @@ export { default as useListByLanguage } from './useListByLanguage'; export { default as useListByLibrary } from './useListByLibrary'; export { default as useListByQuery } from './useListByQuery'; export { default as useListByTask } from './useListByTask'; -export { default as useInferenceServerDetails } from './inference/useInferenceServerDetails'; \ No newline at end of file +export { default as useInferenceServerDetails } from './inference/useInferenceServerDetails'; diff --git a/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts b/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts index 7616ebac9..021096df0 100644 --- a/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts +++ b/src/tapis-hooks/ml-hub/models/inference/useInferenceServerDetails.ts @@ -15,7 +15,8 @@ const useInferenceServerDetails = ( [QueryKeys.inferenceServerDetails, params, accessToken], // Default to no token. This will generate a 403 when calling the list function // which is expected behavior for not having a token - () => inferenceServerDetails(params, basePath, accessToken?.access_token ?? ''), + () => + inferenceServerDetails(params, basePath, accessToken?.access_token ?? ''), { enabled: !!accessToken, } @@ -23,4 +24,4 @@ const useInferenceServerDetails = ( return result; }; -export default useInferenceServerDetails; \ No newline at end of file +export default useInferenceServerDetails;