diff --git a/ai4papi/routers/v1/catalog/modules.py b/ai4papi/routers/v1/catalog/modules.py index 2c48d646..e8427765 100644 --- a/ai4papi/routers/v1/catalog/modules.py +++ b/ai4papi/routers/v1/catalog/modules.py @@ -1,6 +1,7 @@ import configparser from copy import deepcopy import re +import types from cachetools import cached, TTLCache from fastapi import APIRouter @@ -13,8 +14,7 @@ @cached(cache=TTLCache(maxsize=1024, ttl=6*60*60)) -def get_list( - ): +def get_list(self): """ Retrieve a list of *all* modules. @@ -37,9 +37,10 @@ def get_list( def get_config( + self, item_name: str, vo: str, -): + ): """ Returns the default configuration (dict) for creating a deployment for a specific module. It is prefilled with the appropriate @@ -81,8 +82,8 @@ def get_config( Modules = Catalog() -Modules.get_list = get_list -Modules.get_config = get_config +Modules.get_list = types.MethodType(get_list, Modules) +Modules.get_config = types.MethodType(get_config, Modules) router = APIRouter( diff --git a/ai4papi/routers/v1/catalog/tools.py b/ai4papi/routers/v1/catalog/tools.py index 870d63eb..a8654bd9 100644 --- a/ai4papi/routers/v1/catalog/tools.py +++ b/ai4papi/routers/v1/catalog/tools.py @@ -1,5 +1,6 @@ from copy import deepcopy import json +import types from cachetools import cached, TTLCache from fastapi import APIRouter, HTTPException @@ -13,8 +14,7 @@ @cached(cache=TTLCache(maxsize=1024, ttl=6*60*60)) -def get_list( - ): +def get_list(self): """ Retrieve a list of *all* modules. @@ -27,6 +27,7 @@ def get_list( @cached(cache=TTLCache(maxsize=1024, ttl=6*60*60)) def get_metadata( + self, item_name: str, ): """ @@ -72,6 +73,7 @@ def get_metadata( def get_config( + self, item_name: str, vo: str, ): @@ -110,9 +112,9 @@ def get_config( Tools = Catalog() -Tools.get_list = get_list -Tools.get_config = get_config -Tools.get_metadata = get_metadata +Tools.get_list = types.MethodType(get_list, Tools) +Tools.get_config = types.MethodType(get_config, Tools) +Tools.get_metadata = types.MethodType(get_metadata, Tools) router = APIRouter(