@@ -122,95 +122,62 @@ def list_systems(
122122 return pd .DataFrame (rows )
123123
124124
125- def list_system_queues (t : Tapis , system_id : str , verbose : bool = True ) -> List [Any ]:
126- """
127- Retrieves the list of batch logical queues available on a specific Tapis execution system.
125+ def list_system_queues (
126+ t : Tapis ,
127+ system_id : str ,
128+ output : str = "df" ,
129+ ) -> Union [pd .DataFrame , List [Any ]]:
130+ """List batch queues available on a Tapis execution system.
128131
129132 Args:
130- t: Authenticated Tapis client instance.
131- system_id: The ID of the execution system (e.g., 'frontera', 'stampede2' ).
132- verbose: If True, prints the found queues .
133+ t (Tapis) : Authenticated Tapis client instance.
134+ system_id (str) : The ID of the execution system (e.g., "stampede3" ).
135+ output (str, optional): "df" for DataFrame (default), "raw" for Tapis objects .
133136
134137 Returns:
135- A list of queue objects (typically TapisResult instances or similar dict-like structures)
136- defined for the system. Returns an empty list if the system exists but has no queues defined.
138+ Union[pd.DataFrame, List]: Queues with name, maxNodes, maxMinutes, maxCoresPerNode, etc.
137139
138140 Raises:
139141 SystemInfoError: If the system is not found or an API error occurs.
142+ ValueError: If system_id is empty or output is invalid.
140143 """
141144 if not system_id :
142145 raise ValueError ("system_id cannot be empty." )
146+ if output not in ("df" , "raw" ):
147+ raise ValueError (f"output must be 'df' or 'raw', got '{ output } '" )
143148
144149 try :
145- if verbose :
146- print (f"\n Fetching queue information for system '{ system_id } '..." )
147-
148- # Get system details - Fetch the full object to ensure queues are included
149- # Removed 'select' parameter for simplicity and robustness against API variations
150150 system_details = t .systems .getSystem (systemId = system_id )
151-
152- # Use 'batchLogicalQueues' based on the direct API call result
153151 queues = getattr (system_details , "batchLogicalQueues" , [])
154152
155153 if not queues :
156- # Check if the system itself was found but just has no queues
157- try :
158- # Minimal check to confirm system existence if queues list was empty
159- # This might be slightly redundant if getSystem above succeeded, but safe.
160- t .systems .getSystem (systemId = system_id , select = "id" )
161- if verbose :
162- # Updated message
163- print (
164- f"System '{ system_id } ' found, but it has no batch logical queues defined."
165- )
166- return [] # Return empty list as system exists but has no queues
167- except BaseTapyException as e_check :
168- # If this minimal check fails with 404, the system wasn't found initially
169- if (
170- hasattr (e_check , "response" )
171- and e_check .response
172- and e_check .response .status_code == 404
173- ):
174- raise SystemInfoError (
175- f"Execution system '{ system_id } ' not found."
176- ) from e_check
177- else : # Other error during the existence check
178- raise SystemInfoError (
179- f"Error confirming existence of system '{ system_id } ': { e_check } "
180- ) from e_check
181-
182- if verbose :
183- # Updated message
184- print (f"Found { len (queues )} batch logical queues for system '{ system_id } ':" )
185- for q in queues :
186- name = getattr (q , "name" , "N/A" )
187- hpc_queue = getattr (
188- q , "hpcQueueName" , "N/A"
189- ) # Actual scheduler queue name
190- max_jobs = getattr (q , "maxJobs" , "N/A" )
191- max_user_jobs = getattr (q , "maxUserJobs" , "N/A" )
192- max_mins = getattr (q , "maxMinutes" , "N/A" )
193- max_nodes = getattr (q , "maxNodeCount" , "N/A" )
194- # Add more attributes if desired (e.g., maxMemoryMB, maxCoresPerNode)
195- print (
196- f" - Name: { name } (HPC Queue: { hpc_queue } , Max Jobs: { max_jobs } , Max User Jobs: { max_user_jobs } , Max Mins: { max_mins } , Max Nodes: { max_nodes } )"
197- )
198-
199- print ()
200-
201- # The items in the list are TapisResult objects themselves
202- return queues
154+ if output == "raw" :
155+ return []
156+ return pd .DataFrame ()
157+
158+ if output == "raw" :
159+ return queues
160+
161+ rows = []
162+ for q in queues :
163+ rows .append (
164+ {
165+ "name" : getattr (q , "name" , "" ),
166+ "hpcQueue" : getattr (q , "hpcQueueName" , "" ),
167+ "maxNodes" : getattr (q , "maxNodeCount" , None ),
168+ "maxCoresPerNode" : getattr (q , "maxCoresPerNode" , None ),
169+ "maxMinutes" : getattr (q , "maxMinutes" , None ),
170+ "maxMemoryMB" : getattr (q , "maxMemoryMB" , None ),
171+ "maxJobsPerUser" : getattr (q , "maxJobsPerUser" , None ),
172+ }
173+ )
174+ return pd .DataFrame (rows )
203175
204176 except BaseTapyException as e :
205177 if hasattr (e , "response" ) and e .response and e .response .status_code == 404 :
206178 raise SystemInfoError (f"Execution system '{ system_id } ' not found." ) from e
207- else :
208- raise SystemInfoError (
209- f"Failed to retrieve queues for system '{ system_id } ': { e } "
210- ) from e
211- except Exception as e :
212179 raise SystemInfoError (
213- f"An unexpected error occurred while fetching queues for system '{ system_id } ': { e } "
180+ f"Failed to retrieve queues for system '{ system_id } ': { e } "
214181 ) from e
215182
216183
0 commit comments