pyiron_base.jobs.job.base.JobCore#

class pyiron_base.jobs.job.base.JobCore(project: ProjectHDFio, job_name: str)[source]#

Bases: HasGroups

The JobCore the most fundamental pyiron job class. From this class the GenericJob as well as the reduced JobPath class are derived. While JobPath only provides access to the HDF5 file it is about one order faster.

Implements HasGroups. Groups are HDF groups in the HDF file associated with the job and any child jobs, nodes are HDF dataset in the HDF file.

Parameters:
  • project (ProjectHDFio) – ProjectHDFio instance which points to the HDF5 file the job is stored in

  • job_name (str) – name of the job, which has to be unique within the project

.. attribute:: job_name

name of the job, which has to be unique within the project

.. attribute:: status
execution status of the job, can be one of the following [initialized, appended, created, submitted,

running, aborted, collect, suspended, refresh, busy, finished]

.. attribute:: job_id

unique id to identify the job in the pyiron database

.. attribute:: parent_id

job id of the predecessor job - the job which was executed before the current one in the current job series

.. attribute:: master_id
job id of the master job - a meta job which groups a series of jobs, which are executed either in parallel

or in serial.

.. attribute:: child_ids

list of child job ids - only meta jobs have child jobs - jobs which list the meta job as their master

.. attribute:: project

Project instance the jobs is located in

.. attribute:: project_hdf5

ProjectHDFio instance which points to the HDF5 file the job is stored in

.. attribute:: job_info_str

short string to describe the job by it is job_name and job ID - mainly used for logging

.. attribute:: working_directory

working directory of the job is executed in - outside the HDF5 file

.. attribute:: path

path to the job as a combination of absolute file system path and path within the HDF5 file.

__init__(project: ProjectHDFio, job_name: str)[source]#

Methods

__init__(project, job_name)

check_if_job_exists([job_name, project])

Check if a job already exists in an specific project.

compress([files_to_compress, files_to_remove])

Compress the output files of a job object.

copy()

Copy the JobCore object which links to the HDF5 file

copy_to(project[, new_job_name, input_only, ...])

Copy the content of the job including the HDF5 file to a new location

decompress()

Decompress the output files of a compressed job object.

from_hdf([hdf, group_name])

Restore object from hdf5 format - The function has to be implemented by the derived classes - usually the GenericJob class

get(name[, default])

Internal wrapper function for __getitem__() - self[name]

get_from_table(path, name)

Get a specific value from a pandas.Dataframe

get_job_id([job_specifier])

get the job_id for job named job_name in the local project path from database

inspect(job_specifier)

Inspect an existing pyiron object - most commonly a job - from the database

is_compressed()

Check if the job is already compressed or not.

is_master_id(job_id)

Check if the job ID job_id is the master ID for any child job

is_self_archived()

Check if the HDF5 file of the Job is compressed as tar-archive

list_all()

Returns dictionary of :method:`.list_groups()` and :method:`.list_nodes()`.

list_childs()

List child jobs as JobPath objects - not loading the full GenericJob objects for each child

list_files()

List files inside the working directory

list_groups()

Return a list of names of all nested groups.

list_nodes()

Return a list of names of all nested nodes.

load(job_specifier[, convert_to_object])

Load an existing pyiron object - most commonly a job - from the database

move_to(project)

Move the content of the job including the HDF5 file to a new location

relocate_hdf5([h5_path])

Relocate the hdf file.

remove([_protect_childs])

Remove the job - this removes the HDF5 file, all data stored in the HDF5 file an the corresponding database entry.

remove_child()

internal function to remove command that removes also child jobs.

rename(new_job_name)

Rename the job - by changing the job name

reset_job_id([job_id])

The reset_job_id function has to be implemented by the derived classes - usually the GenericJob class

save()

The save function has to be implemented by the derived classes - usually the GenericJob class

self_archive()

Compress HDF5 file of the job object to tar-archive

self_unarchive()

Decompress HDF5 file of the job object from tar-archive

show_hdf()

Iterating over the HDF5 datastructure and generating a human readable graph.

to_hdf([hdf, group_name])

Store object in hdf5 format - The function has to be implemented by the derived classes - usually the GenericJob class

to_object([object_type])

Load the full pyiron object from an HDF5 file

Attributes

child_ids

list of child job ids - only meta jobs have child jobs - jobs which list the meta job as their master

content

database_entry

files

Allows to browse the files in a job directory.

files_to_compress

files_to_remove

id

Unique id to identify the job in the pyiron database - use self.job_id instead

job_id

Unique id to identify the job in the pyiron database

job_info_str

Short string to describe the job by it is job_name and job ID - mainly used for logging

job_name

Get name of the job, which has to be unique within the project

master_id

Get job id of the master job - a meta job which groups a series of jobs, which are executed either in parallel or in serial.

name

Get name of the job, which has to be unique within the project

parent_id

Get job id of the predecessor job - the job which was executed before the current one in the current job series

path

Absolute path of the HDF5 group starting from the system root - combination of the absolute system path plus the absolute path inside the HDF5 file starting from the root group.

project

Project instance the jobs is located in

project_hdf5

Get the ProjectHDFio instance which points to the HDF5 file the job is stored in

status

Execution status of the job, can be one of the following [initialized, appended, created, submitted, running,

working_directory

working directory of the job is executed in - outside the HDF5 file

check_if_job_exists(job_name: str | None = None, project: ProjectHDFio | pyiron_base.project.generic.Project | None = None)[source]#

Check if a job already exists in an specific project.

Parameters:
  • job_name (str) – Job name (optional)

  • project (ProjectHDFio, Project) – Project path (optional)

Returns:

True / False

Return type:

(bool)

property child_ids: list#

list of child job ids - only meta jobs have child jobs - jobs which list the meta job as their master

Returns:

list of child job ids

Return type:

list

compress(files_to_compress: List[str] | None = None, files_to_remove: List[str] | None = None) None[source]#

Compress the output files of a job object.

Parameters:

files_to_compress (list)

copy() JobCore[source]#

Copy the JobCore object which links to the HDF5 file

Returns:

New FileHDFio object pointing to the same HDF5 file

Return type:

JobCore

copy_to(project: JobCore | ProjectHDFio | pyiron_base.project.generic.Project, new_job_name: str | None = None, input_only: bool = False, new_database_entry: bool = True, copy_files: bool = True) JobCore[source]#

Copy the content of the job including the HDF5 file to a new location

Parameters:
  • project (JobCore/ProjectHDFio/Project) – project to copy the job to

  • new_job_name (str) – The new name to assign the duplicate job. Required if the project is None or the same project as the copied job. (Default is None, try to keep the same name.)

  • input_only (bool) – [True/False] Whether to copy only the input. (Default is False.)

  • new_database_entry (bool) – [True/False] Whether to create a new database entry. If input_only is True then new_database_entry is False. (Default is True.)

  • copy_files (bool) – [True/False] copy the files inside the working directory - default True

Returns:

JobCore object pointing to the new location.

Return type:

JobCore

decompress() None[source]#

Decompress the output files of a compressed job object.

property files: FileBrowser#

Allows to browse the files in a job directory.

By default this object prints itself as a listing of the job directory and the files inside.

>>> job.files
/path/to/my/job:
    pyiron.log
    error.out

Access to the names of files is provided with list()

>>> job.files.list()
['pyiron.log', 'error.out', 'INCAR']

Access to the contents of files is provided by indexing into this object, which returns a list of lines in the file

>>> job.files['error.out']
["Oh no

“, “Something went wrong! “]

The tail() method prints the last lines of a file to stdout

>>> job.files.tail('error.out', lines=1)
Something went wrong!

For files that have valid python variable names can also be accessed by attribute notation

>>> job.files.INCAR 
File('INCAR')
from_hdf(hdf: ProjectHDFio | None = None, group_name: str = 'group') None[source]#

Restore object from hdf5 format - The function has to be implemented by the derived classes - usually the GenericJob class

Parameters:
  • hdf (ProjectHDFio) – Optional hdf5 file, otherwise self is used.

  • group_name (str) – Optional hdf5 group in the hdf5 file.

get(name: str, default: Any | None = None) Any[source]#

Internal wrapper function for __getitem__() - self[name]

Parameters:
  • key (str, slice) – path to the data or key of the data object

  • default (any, optional) – return this if key cannot be found

Returns:

data or data object

Return type:

dict, list, float, int

Raises:

ValueError – key cannot be found and default is not given

get_from_table(path: str, name: str) dict | list | float | int[source]#

Get a specific value from a pandas.Dataframe

Parameters:
  • path (str) – relative path to the data object

  • name (str) – parameter key

Returns:

the value associated to the specific parameter key

Return type:

dict, list, float, int

get_job_id(job_specifier: int | str | None = None) int | None[source]#

get the job_id for job named job_name in the local project path from database

Parameters:

job_specifier (str, int) – name of the job or job ID

Returns:

job ID of the job

Return type:

int

property id: int#

Unique id to identify the job in the pyiron database - use self.job_id instead

Returns:

job id

Return type:

int

inspect(job_specifier: str | int) JobCore[source]#

Inspect an existing pyiron object - most commonly a job - from the database

Parameters:

job_specifier (str, int) – name of the job or job ID

Returns:

Access to the HDF5 object - not a GenericJob object - use load() instead.

Return type:

JobCore

is_compressed() bool[source]#

Check if the job is already compressed or not.

Returns:

[True/False]

Return type:

bool

is_master_id(job_id: int) bool[source]#

Check if the job ID job_id is the master ID for any child job

Parameters:

job_id (int) – job ID of the master job

Returns:

[True/False]

Return type:

bool

is_self_archived() bool[source]#

Check if the HDF5 file of the Job is compressed as tar-archive

Returns:

[True/False]

Return type:

bool

property job_id: int#

Unique id to identify the job in the pyiron database

Returns:

job id

Return type:

int

property job_info_str: str#

Short string to describe the job by it is job_name and job ID - mainly used for logging

Returns:

job info string

Return type:

str

property job_name: str#

Get name of the job, which has to be unique within the project

Returns:

job name

Return type:

str

list_all()#

Returns dictionary of :method:`.list_groups()` and :method:`.list_nodes()`.

Returns:

results of :method:`.list_groups() under the key "groups"; results of :method:`.list_nodes()` und the

key “nodes”

Return type:

dict

list_childs() list[source]#

List child jobs as JobPath objects - not loading the full GenericJob objects for each child

Returns:

list of child jobs

Return type:

list

list_files() list[source]#

List files inside the working directory

Parameters:

extension (str) – filter by a specific extension

Returns:

list of file names

Return type:

list

list_groups()#

Return a list of names of all nested groups.

Returns:

group names

Return type:

list of str

list_nodes()#

Return a list of names of all nested nodes.

Returns:

node names

Return type:

list of str

load(job_specifier: str | int, convert_to_object: bool = True) pyiron_base.job.generic.GenericJob | JobCore[source]#

Load an existing pyiron object - most commonly a job - from the database

Parameters:
  • job_specifier (str, int) – name of the job or job ID

  • convert_to_object (bool) – convert the object to an pyiron object or only access the HDF5 file - default=True accessing only the HDF5 file is about an order of magnitude faster, but only provides limited functionality. Compare the GenericJob object to JobCore object.

Returns:

Either the full GenericJob object or just a reduced JobCore object

Return type:

GenericJob, JobCore

property master_id: int#

Get job id of the master job - a meta job which groups a series of jobs, which are executed either in parallel or in serial.

Returns:

master id

Return type:

int

move_to(project: ProjectHDFio) None[source]#

Move the content of the job including the HDF5 file to a new location

Parameters:

project (ProjectHDFio) – project to move the job to

property name: str#

Get name of the job, which has to be unique within the project

Returns:

job name

Return type:

str

property parent_id: int#

Get job id of the predecessor job - the job which was executed before the current one in the current job series

Returns:

parent id

Return type:

int

property path: str#

Absolute path of the HDF5 group starting from the system root - combination of the absolute system path plus the absolute path inside the HDF5 file starting from the root group.

Returns:

absolute path

Return type:

str

property project: pyiron_base.project.generic.Project#

Project instance the jobs is located in

Returns:

project the job is located in

Return type:

Project

property project_hdf5: ProjectHDFio#

Get the ProjectHDFio instance which points to the HDF5 file the job is stored in

Returns:

HDF5 project

Return type:

ProjectHDFio

relocate_hdf5(h5_path: str | None = None)[source]#

Relocate the hdf file. This function is needed when the child job is spawned by a parent job (cf. pyiron_base.jobs.master.generic)

remove(_protect_childs: bool = True) None[source]#

Remove the job - this removes the HDF5 file, all data stored in the HDF5 file an the corresponding database entry.

Parameters:

_protect_childs (bool) – [True/False] by default child jobs can not be deleted, to maintain the consistency - default=True

remove_child() None[source]#

internal function to remove command that removes also child jobs. Do never use this command, since it will destroy the integrity of your project.

rename(new_job_name: str) None[source]#

Rename the job - by changing the job name

Parameters:

new_job_name (str) – new job name

reset_job_id(job_id: int | None = None) None[source]#

The reset_job_id function has to be implemented by the derived classes - usually the GenericJob class

Parameters:

job_id (int/ None)

save() None[source]#

The save function has to be implemented by the derived classes - usually the GenericJob class

self_archive() None[source]#

Compress HDF5 file of the job object to tar-archive

self_unarchive() None[source]#

Decompress HDF5 file of the job object from tar-archive

show_hdf() None[source]#

Iterating over the HDF5 datastructure and generating a human readable graph.

property status: str#
Execution status of the job, can be one of the following [initialized, appended, created, submitted, running,

aborted, collect, suspended, refresh, busy, finished]

Returns:

status

Return type:

(str/pyiron_base.job.jobstatus.JobStatus)

to_hdf(hdf: ProjectHDFio | None = None, group_name: str = 'group') None[source]#

Store object in hdf5 format - The function has to be implemented by the derived classes - usually the GenericJob class

Parameters:
  • hdf (ProjectHDFio) – Optional hdf5 file, otherwise self is used.

  • group_name (str) – Optional hdf5 group in the hdf5 file.

to_object(object_type: str | None = None, **qwargs) pyiron_base.job.generic.GenericJob[source]#

Load the full pyiron object from an HDF5 file

Parameters:
  • object_type – if the ‘TYPE’ node is not available in the HDF5 file a manual object type can be set - optional

  • **qwargs – optional parameters [‘job_name’, ‘project’] - to specify the location of the HDF5 path

Returns:

pyiron object

Return type:

GenericJob

property working_directory: str#

working directory of the job is executed in - outside the HDF5 file

Returns:

working directory

Return type:

str