33from typing import List , Any , Optional
44from .exceptions import AppDiscoveryError
55
6+
67def find_apps (
78 t : Tapis , search_term : str , list_type : str = "ALL" , verbose : bool = True
89) -> List [Tapis ]:
@@ -24,24 +25,34 @@ def find_apps(
2425 try :
2526 # Use id.like for partial matching, ensure search term is handled
2627 search_query = f"(id.like.*{ search_term } *)" if search_term else None
27- results = t .apps .getApps (search = search_query , listType = list_type , select = "id,version,owner" ) # Select fewer fields for speed
28+ results = t .apps .getApps (
29+ search = search_query , listType = list_type , select = "id,version,owner"
30+ ) # Select fewer fields for speed
2831
2932 if verbose :
3033 if not results :
31- print (f"No apps found matching '{ search_term } ' with listType '{ list_type } '" )
34+ print (
35+ f"No apps found matching '{ search_term } ' with listType '{ list_type } '"
36+ )
3237 else :
3338 print (f"\n Found { len (results )} matching apps:" )
3439 for app in results :
3540 print (f"- { app .id } (Version: { app .version } , Owner: { app .owner } )" )
3641 print ()
3742 return results
3843 except BaseTapyException as e :
39- raise AppDiscoveryError (f"Failed to search for apps matching '{ search_term } ': { e } " ) from e
44+ raise AppDiscoveryError (
45+ f"Failed to search for apps matching '{ search_term } ': { e } "
46+ ) from e
4047 except Exception as e :
41- raise AppDiscoveryError (f"An unexpected error occurred while searching for apps: { e } " ) from e
48+ raise AppDiscoveryError (
49+ f"An unexpected error occurred while searching for apps: { e } "
50+ ) from e
4251
4352
44- def get_app_details (t : Tapis , app_id : str , app_version : Optional [str ] = None , verbose : bool = True ) -> Optional [Tapis ]:
53+ def get_app_details (
54+ t : Tapis , app_id : str , app_version : Optional [str ] = None , verbose : bool = True
55+ ) -> Optional [Tapis ]:
4556 """
4657 Get detailed information for a specific app ID and version (or latest).
4758
@@ -68,23 +79,31 @@ def get_app_details(t: Tapis, app_id: str, app_version: Optional[str] = None, ve
6879 print (f" ID: { app_info .id } " )
6980 print (f" Version: { app_info .version } " )
7081 print (f" Owner: { app_info .owner } " )
71- if hasattr (app_info , 'jobAttributes' ) and hasattr (app_info .jobAttributes , 'execSystemId' ):
72- print (f" Execution System: { app_info .jobAttributes .execSystemId } " )
82+ if hasattr (app_info , "jobAttributes" ) and hasattr (
83+ app_info .jobAttributes , "execSystemId"
84+ ):
85+ print (f" Execution System: { app_info .jobAttributes .execSystemId } " )
7386 else :
74- print (" Execution System: Not specified in jobAttributes" )
87+ print (" Execution System: Not specified in jobAttributes" )
7588 print (f" Description: { app_info .description } " )
7689 return app_info
7790 except BaseTapyException as e :
7891 # Check for 404 specifically
79- if hasattr (e , ' response' ) and e .response and e .response .status_code == 404 :
80- print (f"App '{ app_id } ' (Version: { app_version or 'latest' } ) not found." )
81- # Optionally, try searching for similar apps
82- # print("\nAttempting to find similar apps:")
83- # find_apps(t, app_id, verbose=True)
84- return None
92+ if hasattr (e , " response" ) and e .response and e .response .status_code == 404 :
93+ print (f"App '{ app_id } ' (Version: { app_version or 'latest' } ) not found." )
94+ # Optionally, try searching for similar apps
95+ # print("\nAttempting to find similar apps:")
96+ # find_apps(t, app_id, verbose=True)
97+ return None
8598 else :
86- print (f"Error getting app info for '{ app_id } ' (Version: { app_version or 'latest' } ): { e } " )
87- raise AppDiscoveryError (f"Failed to get details for app '{ app_id } ': { e } " ) from e
99+ print (
100+ f"Error getting app info for '{ app_id } ' (Version: { app_version or 'latest' } ): { e } "
101+ )
102+ raise AppDiscoveryError (
103+ f"Failed to get details for app '{ app_id } ': { e } "
104+ ) from e
88105 except Exception as e :
89106 print (f"An unexpected error occurred getting app info for '{ app_id } ': { e } " )
90- raise AppDiscoveryError (f"Unexpected error getting details for app '{ app_id } ': { e } " ) from e
107+ raise AppDiscoveryError (
108+ f"Unexpected error getting details for app '{ app_id } ': { e } "
109+ ) from e
0 commit comments