pyiron_base.database.interface.IsDatabase#

class pyiron_base.database.interface.IsDatabase[source]#

Bases: ABC

Captures common interface for all database types in pyiron, e.g. SQL/SQLite/FileTable.

__init__()#

Methods

__init__()

get_db_columns()

Get column names

get_job_ids(sql_query, user, project_path[, ...])

Return the job IDs matching a specific query

get_jobs(sql_query, user, project_path[, ...])

Internal function to return the jobs as dictionary rather than a pandas.Dataframe

get_table_headings([table_name])

Get column names; if given table_name can select one of multiple tables defined in the database, but subclasses may ignore it

item_update(par_dict, item_id)

job_table(sql_query, user, project_path[, ...])

Access the job_table.

set_job_status(status, job_id)

Set status of a job or multiple jobs if job_id is iterable.

Attributes

view_mode

Get view_mode - if view_moded is enable pyiron has read only access to the database.

get_db_columns() List[str][source]#

Get column names

Returns:

list of column names like:

[‘id’, ‘parentid’, ‘masterid’, ‘projectpath’, ‘project’, ‘job’, ‘subjob’, ‘chemicalformula’, ‘status’, ‘hamilton’, ‘hamversion’, ‘username’, ‘computer’, ‘timestart’, ‘timestop’, ‘totalcputime’]

Return type:

list

get_job_ids(sql_query: str, user: str, project_path: str, recursive: bool = True) List[int][source]#

Return the job IDs matching a specific query

Parameters:
  • 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:

a list of job IDs

Return type:

list

get_jobs(sql_query: str, user: str, project_path: str, recursive: bool = True, columns: List[str] | None = None) List[dict][source]#

Internal function to return the jobs as dictionary rather than a pandas.Dataframe

Parameters:
  • 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]

  • columns (list) – by default only the columns [‘id’, ‘project’] are selected, but the user can select a subset of [‘id’, ‘status’, ‘chemicalformula’, ‘job’, ‘subjob’, ‘project’, ‘projectpath’, ‘timestart’, ‘timestop’, ‘totalcputime’, ‘computer’, ‘hamilton’, ‘hamversion’, ‘parentid’, ‘masterid’]

Returns:

columns are used as keys and point to a list of the corresponding values

Return type:

dict

get_table_headings(table_name: str | None = None) List[str][source]#

Get column names; if given table_name can select one of multiple tables defined in the database, but subclasses may ignore it

Parameters:

table_name (str) – simple string of a table_name like: ‘jobs_username’

Returns:

list of column names like:

[‘id’, ‘parentid’, ‘masterid’, ‘projectpath’, ‘project’, ‘job’, ‘subjob’, ‘chemicalformula’, ‘status’, ‘hamilton’, ‘hamversion’, ‘username’, ‘computer’, ‘timestart’, ‘timestop’, ‘totalcputime’]

Return type:

list

job_table(sql_query: str, user: str, project_path: str, recursive: bool = True, columns: List[str] | None = None, all_columns: bool = False, sort_by: str = 'id', max_colwidth: int = 200, full_table: bool = False, element_lst: List[str] | None = None, job_name_contains: str = '', mode: Literal['regex', 'glob'] = 'glob', **kwargs)[source]#

Access the job_table.

Parameters:
  • 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]

  • columns (list) – by default only the columns [‘job’, ‘project’, ‘chemicalformula’] are selected, but the user can select a subset of [‘id’, ‘status’, ‘chemicalformula’, ‘job’, ‘subjob’, ‘project’, ‘projectpath’, ‘timestart’, ‘timestop’, ‘totalcputime’, ‘computer’, ‘hamilton’, ‘hamversion’, ‘parentid’, ‘masterid’]

  • all_columns (bool) – Select all columns - this overwrites the columns option.

  • sort_by (str) – Sort by a specific column

  • max_colwidth (int) – set the column width

  • full_table (bool) – Whether to show the entire pandas table

  • element_lst (list) – list of elements required in the chemical formular - by default None

  • job_name_contains (str) – (deprecated) A string which should be contained in every job_name

  • mode (str) – search mode when kwargs are given.

  • **kwargs (dict) – Optional arguments for filtering with keys matching the project database column name (eg. status=”finished”). Asterisk can be used to denote a wildcard, for zero or more instances of any character

Returns:

Return the result as a pandas.Dataframe object

Return type:

pandas.Dataframe

set_job_status(status: str, job_id: int | List[int]) None[source]#

Set status of a job or multiple jobs if job_id is iterable.

Parameters:
  • status (str) – status

  • job_id (int, Iterable) – job id

property view_mode: bool#

Get view_mode - if view_moded is enable pyiron has read only access to the database.

Some implementations do not allow to set this value.

Returns:

True when view_mode is enabled

Return type:

bool