pyiron_base.jobs.job.core module

The JobCore the most fundamental pyiron job class.

class pyiron_base.jobs.job.core.DatabaseProperties(job_dict=None)

Bases: object

Access the database entry of the job

class pyiron_base.jobs.job.core.HDF5Content(project_hdf5)

Bases: object

Access the HDF5 file of the job

class pyiron_base.jobs.job.core.JobCore(project, job_name)

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.

check_if_job_exists(job_name=None, project=None)

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 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=None, files_to_remove=None)

Compress the output files of a job object.

Parameters:

files_to_compress (list)

property content
copy()

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, new_job_name=None, input_only=False, new_database_entry=True, copy_files=True)

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

property database_entry
decompress()

Decompress the output files of a compressed job object.

property files

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')
property files_to_compress
property files_to_remove
from_hdf(hdf=None, group_name='group')

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, default=None)

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, name)

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=None)

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

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

Returns:

job id

Return type:

int

inspect(job_specifier)

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()

Check if the job is already compressed or not.

Returns:

[True/False]

Return type:

bool

is_master_id(job_id)

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()

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

Returns:

[True/False]

Return type:

bool

property job_id

Unique id to identify the job in the pyiron database

Returns:

job id

Return type:

int

property job_info_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

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

Returns:

job name

Return type:

str

list_childs()

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 files inside the working directory

Parameters:

extension (str) – filter by a specific extension

Returns:

list of file names

Return type:

list

load(job_specifier, convert_to_object=True)

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

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)

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

Parameters:

project (ProjectHDFio) – project to move the job to

Returns:

JobCore object pointing to the new location.

Return type:

JobCore

property name

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

Returns:

job name

Return type:

str

property parent_id

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

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

Project instance the jobs is located in

Returns:

project the job is located in

Return type:

Project

property project_hdf5

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=None)

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=True)

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()

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)

Rename the job - by changing the job name

Parameters:

new_job_name (str) – new job name

reset_job_id(job_id=None)

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

Parameters:

job_id (int/ None)

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.

property status
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=None, group_name='group')

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=None, **qwargs)

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

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

Returns:

working directory

Return type:

str

pyiron_base.jobs.job.core.recursive_load_from_hdf(project_hdf5: ProjectHDFio, item: str)

Load given item from HDF, but check also for DataContainer along the way.

If item exists as is in HDF, return it, otherwise break it up along every slash and try to load a DataContainer and then try to index with the remainder of the path, i.e.

>>> recursive_load_from_hdf(hdf, 'my/path/to/value')

is equivalent to one of (in this order)

>>> hdf['my/path/to'].to_object()['value']
>>> hdf['my/path'].to_object()['to/value']
>>> hdf['my'].to_object()['path/to/value']

in case

>>> hdf['/my/path/to/value']

doesn’t exist.

Parameters:
  • project_hdf5 (ProjectHDFio) – HDF file to access

  • item (str) – path to value, may contain /

Returns:

whatever was found in the HDF file None: if nothing was found in the HDF file

Return type:

object