Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove project.sql_query #1349

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyiron_base/database/filetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def get_jobs(self, project=None, recursive=True, columns=None):
if columns is None:
columns = ["id", "project"]
df = self.job_table(
sql_query=None,
user=None,
project_path=project,
recursive=recursive,
Expand Down Expand Up @@ -599,7 +598,6 @@ def _get_job_status_from_hdf5(self, job_id):

def _get_job_table(
self,
sql_query,
user,
project_path=None,
recursive=True,
Expand Down
15 changes: 0 additions & 15 deletions pyiron_base/database/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ def viewer_mode(self, value):

def _job_dict(
self,
sql_query,
user,
project_path,
recursive,
Expand All @@ -270,7 +269,6 @@ def _job_dict(
Internal function to access the database from the project directly.

Args:
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]
Expand Down Expand Up @@ -315,17 +313,6 @@ def _job_dict(
if user is not None:
dict_clause["username"] = str(user)
# FOR GET_ITEMS_SQL: clause.append("username = '" + self.user + "'")
if sql_query is not None:
# FOR GET_ITEMS_SQL: clause.append(self.sql_query)
if "AND" in sql_query:
cl_split = sql_query.split(" AND ")
elif "and" in sql_query:
cl_split = sql_query.split(" and ")
else:
cl_split = [sql_query]
dict_clause.update(
{str(element.split()[0]): element.split()[2] for element in cl_split}
)
if job is not None:
dict_clause["job"] = str(job)

Expand All @@ -347,15 +334,13 @@ def _job_dict(

def _get_job_table(
self,
sql_query,
user,
project_path,
recursive=True,
columns=None,
element_lst=None,
):
job_dict = self._job_dict(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=recursive,
Expand Down
5 changes: 1 addition & 4 deletions pyiron_base/database/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def viewer_mode(self):
@abstractmethod
def _get_job_table(
self,
sql_query,
user,
project_path,
sql_query=None,
recursive=True,
columns=None,
element_lst=None,
Expand Down Expand Up @@ -116,7 +116,6 @@ def _get_filtered_job_table(

def job_table(
self,
sql_query,
user,
project_path,
recursive=True,
Expand All @@ -134,7 +133,6 @@ def job_table(
Access the job_table.

Args:
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]
Expand Down Expand Up @@ -187,7 +185,6 @@ def job_table(
pandas.set_option("display.max_colwidth", max_colwidth)
df = self._get_job_table(
user=user,
sql_query=sql_query,
project_path=project_path,
recursive=recursive,
columns=columns,
Expand Down
30 changes: 8 additions & 22 deletions pyiron_base/database/jobtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
__date__ = "Sep 1, 2017"


def get_jobs(database, sql_query, user, project_path, recursive=True, columns=None):
def get_jobs(database, user, project_path, recursive=True, columns=None):
"""
Internal function to return the jobs as dictionary rather than a pandas.Dataframe

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]
Expand All @@ -41,7 +40,6 @@ def get_jobs(database, sql_query, user, project_path, recursive=True, columns=No
if columns is None:
columns = ["id", "project"]
df = database.job_table(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=recursive,
Expand All @@ -56,13 +54,12 @@ def get_jobs(database, sql_query, user, project_path, recursive=True, columns=No
)


def get_job_ids(database, sql_query, user, project_path, recursive=True):
def get_job_ids(database, 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]
Expand All @@ -73,7 +70,6 @@ def get_job_ids(database, sql_query, user, project_path, recursive=True):
if not isinstance(database, FileTable):
return get_jobs(
database=database,
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=recursive,
Expand All @@ -83,13 +79,12 @@ def get_job_ids(database, sql_query, user, project_path, recursive=True):
return database.get_job_ids(project=project_path, recursive=recursive)


def get_child_ids(database, sql_query, user, project_path, job_specifier, status=None):
def get_child_ids(database, user, project_path, job_specifier, status=None):
"""
Get the childs for a specific job

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
job_specifier (str): name of the master job or the master jobs job ID
Expand All @@ -99,7 +94,7 @@ def get_child_ids(database, sql_query, user, project_path, job_specifier, status
list: list of child IDs
"""
if not isinstance(database, FileTable):
id_master = get_job_id(database, sql_query, user, project_path, job_specifier)
id_master = get_job_id(database, user, project_path, job_specifier)
if id_master is None:
return []
else:
Expand All @@ -118,13 +113,12 @@ def get_child_ids(database, sql_query, user, project_path, job_specifier, status
return database.get_child_ids(job_specifier=job_specifier, project=project_path)


def get_job_id(database, sql_query, user, project_path, job_specifier):
def get_job_id(database, user, project_path, job_specifier):
"""
get the job_id for job named job_name in the local project path from database

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
job_specifier (str): name of the job or job ID
Expand All @@ -137,15 +131,13 @@ def get_job_id(database, sql_query, user, project_path, job_specifier):
return job_specifier # is id

job_dict = database._job_dict(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=False,
job=job_specifier,
)
if len(job_dict) == 0:
job_dict = database._job_dict(
sql_query=sql_query,
user=user,
project_path=project_path,
recursive=True,
Expand All @@ -165,13 +157,12 @@ def get_job_id(database, sql_query, user, project_path, job_specifier):
return database.get_job_id(job_specifier=job_specifier, project=project_path)


def set_job_status(database, sql_query, user, project_path, job_specifier, status):
def set_job_status(database, user, project_path, job_specifier, status):
"""
Set the status of a particular job

Args:
database (DatabaseAccess/ FileTable): 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
job_specifier (str): name of the job or job ID
Expand All @@ -182,7 +173,6 @@ def set_job_status(database, sql_query, user, project_path, job_specifier, statu
database.set_job_status(
job_id=get_job_id(
database=database,
sql_query=sql_query,
user=user,
project_path=project_path,
job_specifier=job_specifier,
Expand All @@ -191,13 +181,12 @@ def set_job_status(database, sql_query, user, project_path, job_specifier, statu
)


def get_job_status(database, sql_query, user, project_path, job_specifier):
def get_job_status(database, user, project_path, job_specifier):
"""
Get the status of a particular job

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
job_specifier (str): name of the job or job ID
Expand All @@ -210,21 +199,19 @@ def get_job_status(database, sql_query, user, project_path, job_specifier):
return database.get_job_status(
job_id=get_job_id(
database=database,
sql_query=sql_query,
user=user,
project_path=project_path,
job_specifier=job_specifier,
)
)


def get_job_working_directory(database, sql_query, user, project_path, job_specifier):
def get_job_working_directory(database, user, project_path, job_specifier):
"""
Get the working directory of a particular job

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
job_specifier (str): name of the job or job ID
Expand All @@ -235,7 +222,6 @@ def get_job_working_directory(database, sql_query, user, project_path, job_speci
return database.get_job_working_directory(
job_id=get_job_id(
database=database,
sql_query=sql_query,
user=user,
project_path=project_path,
job_specifier=job_specifier,
Expand Down
2 changes: 0 additions & 2 deletions pyiron_base/jobs/datamining.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ def to_hdf(self, hdf=None, group_name=None):
hdf5_input["project"] = {
"path": self._analysis_project.path,
"user": self._analysis_project.user,
"sql_query": self._analysis_project.sql_query,
"filter": self._analysis_project._filter,
"inspect_mode": self._analysis_project._inspect_mode,
}
Expand Down Expand Up @@ -702,7 +701,6 @@ def from_hdf(self, hdf=None, group_name=None):
project = self.project.__class__(
path=project_dict["path"],
user=project_dict["user"],
sql_query=project_dict["sql_query"],
)
project._filter = project_dict["filter"]
project._inspect_mode = project_dict["inspect_mode"]
Expand Down
1 change: 0 additions & 1 deletion pyiron_base/jobs/job/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ def transfer_from_remote(self):
else:
ft = FileTable(index_from=self.project_hdf5.path + "_hdf5/")
df = ft.job_table(
sql_query=None,
user=state.settings.login_user,
project_path=None,
all_columns=True,
Expand Down
Loading
Loading