Skip to content

Commit

Permalink
Inline get_job_ids to IsDatabase
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrv committed Oct 21, 2023
1 parent d2e518e commit c3b1e40
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 41 deletions.
13 changes: 0 additions & 13 deletions pyiron_base/database/filetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,6 @@ def _get_jobs(self, user, sql_query, project=None, recursive=True, columns=None)
].tolist() # ToDo: Check difference of tolist and to_list
return dictionary

def get_job_ids(self, project=None, recursive=True):
"""
Get job IDs from filetable
Args:
project (str/ None): path to the project
recursive (boolean): recursively iterate over all sub projects
Returns:
list/ None: list of job IDs
"""
return self.get_jobs(project=project, recursive=recursive, columns=["id"])["id"]

def get_job_id(self, job_specifier, project=None):
"""
Get job ID from filetable
Expand Down
21 changes: 21 additions & 0 deletions pyiron_base/database/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,27 @@ def get_jobs(self, sql_query, user, project_path, recursive=True, columns=None):
sql_query, user, project_path, recursive, columns
)

def get_job_ids(self, sql_query, user, project_path, recursive=True):
"""
Return the job IDs matching a specific query
Args:
database (DatabaseAccess): Database object
sql_query (str): SQL query to enter a more specific request
user (str): username of the user whoes user space should be searched
project_path (str): root_path - this is in contrast to the project_path in GenericPath
recursive (bool): search subprojects [True/False]
Returns:
list: a list of job IDs
"""
return self.get_jobs(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=recursive,
)["id"]

class ConnectionWatchDog(Thread):
"""
Helper class that closes idle connections after a given timeout.
Expand Down
25 changes: 0 additions & 25 deletions pyiron_base/database/jobtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,6 @@



def get_job_ids(database, sql_query, user, project_path, recursive=True):
"""
Return the job IDs matching a specific query
Args:
database (DatabaseAccess): Database object
sql_query (str): SQL query to enter a more specific request
user (str): username of the user whoes user space should be searched
project_path (str): root_path - this is in contrast to the project_path in GenericPath
recursive (bool): search subprojects [True/False]
Returns:
list: a list of job IDs
"""
if not isinstance(database, FileTable):
return database.get_jobs(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=recursive,
)["id"]
else:
return database.get_job_ids(project=project_path, recursive=recursive)


def get_child_ids(database, sql_query, user, project_path, job_specifier, status=None):
"""
Get the childs for a specific job
Expand Down
4 changes: 1 addition & 3 deletions pyiron_base/project/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from pyiron_base.database.filetable import FileTable
from pyiron_base.state import state
from pyiron_base.database.jobtable import (
get_job_ids,
get_job_id,
set_job_status,
get_child_ids,
Expand Down Expand Up @@ -451,8 +450,7 @@ def get_job_ids(self, recursive=True):
Returns:
list: a list of job IDs
"""
return get_job_ids(
database=self.db,
return self.db.get_job_ids(
sql_query=self.sql_query,
user=self.user,
project_path=self.project_path,
Expand Down

0 comments on commit c3b1e40

Please sign in to comment.