Skip to content

Commit

Permalink
Merge pull request #424 from pyiron/sampleqol
Browse files Browse the repository at this point in the history
Allow to remove job in TrainingContainer.sample
  • Loading branch information
pmrv authored Jun 15, 2022
2 parents 8dd2840 + 7cc8520 commit 0346128
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyiron_contrib/atomistics/atomistics/job/trainingcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ def from_hdf(self, hdf=None, group_name=None):
self.input.from_hdf(self.project_hdf5, "parameters")

def sample(
self, name: str, selector: Callable[[StructureStorage, int], bool]
self, name: str, selector: Callable[[StructureStorage, int], bool],
delete_existing_job: bool = False
) -> "TrainingContainer":
"""
Create a new TrainingContainer with structures filtered by selector.
Expand All @@ -250,14 +251,17 @@ def sample(
Args:
name (str): name of the new TrainingContainer
selector (Callable[[StructureStorage, int], bool]): callable that selects structure to include
delete_existing_job (bool): if job with name exist, remove it first
Returns:
:class:`.TrainingContainer`: new container with selected structures
Raises:
ValueError: if a job with the given `name` already exists.
"""
cont = self.project.create.job.TrainingContainer(name)
if not self.status.finished:
raise ValueError(f"Job must be finished, not '{self.status}'!")
cont = self.project.create.job.TrainingContainer(name, delete_existing_job=delete_existing_job)
if not cont.status.initialized:
raise ValueError(f"Job '{name}' already exists with status: {cont.status}!")
cont._container = self._container.sample(selector)
Expand Down

0 comments on commit 0346128

Please sign in to comment.