diff --git a/pyiron_base/jobs/job/extension/server/queuestatus.py b/pyiron_base/jobs/job/extension/server/queuestatus.py index 59891b58e..f7ca28d26 100644 --- a/pyiron_base/jobs/job/extension/server/queuestatus.py +++ b/pyiron_base/jobs/job/extension/server/queuestatus.py @@ -25,12 +25,13 @@ QUEUE_SCRIPT_PREFIX = "pi_" -def queue_table(job_ids=None, project_only=True, full_table=False): +def queue_table(job_ids=None, working_directory_lst=None, project_only=True, full_table=False): """ Display the queuing system table as pandas.Dataframe Args: job_ids (list): check for a specific list of job IDs - empty list by default + working_directory_lst (list): list of working directories to include - empty list by default project_only (bool): Query only for jobs within the current project - True by default full_table (bool): Return all entries from the queuing system without filtering - False by default @@ -38,7 +39,8 @@ def queue_table(job_ids=None, project_only=True, full_table=False): pandas.DataFrame: Output from the queuing system - optimized for the Sun grid engine """ job_ids = [] if job_ids is None else job_ids - if project_only and not job_ids: + working_directory_lst = [] if working_directory_lst is None else working_directory_lst + if project_only and not job_ids and not working_directory_lst: return [] if state.queue_adapter is not None: if full_table: @@ -56,13 +58,21 @@ def queue_table(job_ids=None, project_only=True, full_table=False): ] ] else: - job_name_lst = [QUEUE_SCRIPT_PREFIX + str(job_id) for job_id in job_ids] - return df[ - [ - True if job_name in job_name_lst else False - for job_name in list(df.jobname) + if len(job_ids) > len(working_directory_lst): + job_name_lst = [QUEUE_SCRIPT_PREFIX + str(job_id) for job_id in job_ids] + return df[ + [ + True if job_name in job_name_lst else False + for job_name in list(df.jobname) + ] + ] + else: + return df[ + [ + any([working_dir.startswith(p) for p in working_directory_lst]) + for working_dir in list(df.working_directory) + ] ] - ] else: return None diff --git a/pyiron_base/project/generic.py b/pyiron_base/project/generic.py index 6753da0d3..746f083cb 100644 --- a/pyiron_base/project/generic.py +++ b/pyiron_base/project/generic.py @@ -902,11 +902,18 @@ def queue_table(self, project_only=True, recursive=True, full_table=False): Returns: pandas.DataFrame: Output from the queuing system - optimized for the Sun grid engine """ - return queue_table( - job_ids=self.get_job_ids(recursive=recursive), - project_only=project_only, - full_table=full_table, - ) + if not isinstance(self.db, FileTable): + return queue_table( + job_ids=self.get_job_ids(recursive=recursive), + project_only=project_only, + full_table=full_table, + ) + else: + return queue_table( + project_only=project_only, + full_table=full_table, + working_directory_lst=[self.path] + ) def queue_table_global(self, full_table=False): """ @@ -920,15 +927,40 @@ def queue_table_global(self, full_table=False): """ df = queue_table(job_ids=[], project_only=False, full_table=full_table) if len(df) != 0 and self.db is not None: - return pandas.DataFrame( - [ - self.db.get_item_by_id( - int(str(queue_ID).replace("pi_", "").replace(".sh", "")) - ) - for queue_ID in df["jobname"] - if str(queue_ID).startswith("pi_") - ] - ) + if not isinstance(self.db, FileTable): + return pandas.DataFrame( + [ + self.db.get_item_by_id( + int(str(queue_ID).replace("pi_", "").replace(".sh", "")) + ) + for queue_ID in df["jobname"] + if str(queue_ID).startswith("pi_") + ] + ) + else: + def get_id_from_job_table(job_table, job_path): + job_dir = "_hdf5".join(job_path.split("_hdf5")[:-1]) + job_name = os.path.basename(job_dir) + project = os.path.dirname(job_dir) + "/" + return job_table[ + (job_table.job == job_name) & + (job_table.project == project) + ].id.values[0] + + job_table_df = self.job_table() + + return pandas.DataFrame( + [ + self.db.get_item_by_id( + int(get_id_from_job_table( + job_table=job_table_df, + job_path=working_directory + )) + ) + for queue_ID, working_directory in zip(df["jobname"], df["working_directory"]) + if str(queue_ID).startswith("pi_") + ] + ) else: return None