Skip to content

Commit

Permalink
Pass the max_fizzles arguments through metadata calculators and notif…
Browse files Browse the repository at this point in the history
…y about finding running jobs
  • Loading branch information
ktran9891 committed Jul 24, 2019
1 parent f0a2e51 commit eb2d408
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions gaspy/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .utils import read_rc

DFT_CALCULATOR = read_rc('dft_calculator')
MAX_FIZZLES = 5


def pp_version():
Expand Down
7 changes: 6 additions & 1 deletion gaspy/tasks/calculation_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
BULK_SETTINGS = defaults.bulk_settings()
SLAB_SETTINGS = defaults.slab_settings()
ADSLAB_SETTINGS = defaults.adslab_settings()
MAX_FIZZLES = defaults.MAX_FIZZLES


class FindCalculation(luigi.Task):
Expand Down Expand Up @@ -71,7 +72,7 @@ class FindCalculation(luigi.Task):
attributes to the class. This method will be
called automatically at the start of `run`.
'''
max_fizzles = luigi.IntParameter(5)
max_fizzles = luigi.IntParameter(MAX_FIZZLES)

def run(self, _testing=False):
'''
Expand Down Expand Up @@ -108,6 +109,10 @@ def run(self, _testing=False):

# If we're already running, then just move on
else:
print(' You just tried to find a calculation that has not '
'yet finished running. Please try again later. If you '
'know it has finished running, then try updating the '
'`atoms` collection of GASdb.')
pass

def _find_and_save_calculation(self):
Expand Down
33 changes: 24 additions & 9 deletions gaspy/tasks/metadata_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SE_BULK_SETTINGS = defaults.surface_energy_bulk_settings()
SLAB_SETTINGS = defaults.slab_settings()
ADSLAB_SETTINGS = defaults.adslab_settings()
MAX_FIZZLES = defaults.MAX_FIZZLES


def submit_adsorption_calculations(adsorbate, catalog_docs, **kwargs):
Expand Down Expand Up @@ -192,10 +193,12 @@ class CalculateAdsorptionEnergy(luigi.Task):
gas_dft_settings = luigi.DictParameter(GAS_SETTINGS[DFT_CALCULATOR])
bulk_dft_settings = luigi.DictParameter(BULK_SETTINGS[DFT_CALCULATOR])
adslab_dft_settings = luigi.DictParameter(ADSLAB_SETTINGS[DFT_CALCULATOR])
max_fizzles = luigi.IntParameter(MAX_FIZZLES)

def requires(self):
return {'adsorbate_energy': CalculateAdsorbateEnergy(self.adsorbate_name,
self.gas_dft_settings),
self.gas_dft_settings,
max_fizzles=self.max_fizzles),
'bare_slab_doc': FindAdslab(adsorption_site=(0., 0., 0.),
shift=self.shift,
top=self.top,
Expand All @@ -207,7 +210,8 @@ def requires(self):
min_xy=self.min_xy,
slab_generator_settings=self.slab_generator_settings,
get_slab_settings=self.get_slab_settings,
bulk_dft_settings=self.bulk_dft_settings),
bulk_dft_settings=self.bulk_dft_settings,
max_fizzles=self.max_fizzles),
'adslab_doc': FindAdslab(adsorption_site=self.adsorption_site,
shift=self.shift,
top=self.top,
Expand All @@ -219,7 +223,8 @@ def requires(self):
min_xy=self.min_xy,
slab_generator_settings=self.slab_generator_settings,
get_slab_settings=self.get_slab_settings,
bulk_dft_settings=self.bulk_dft_settings)}
bulk_dft_settings=self.bulk_dft_settings,
max_fizzles=self.max_fizzles)}

def run(self):
with open(self.input()['adsorbate_energy'].path, 'rb') as file_handle:
Expand Down Expand Up @@ -260,6 +265,7 @@ class CalculateAdsorbateEnergy(luigi.Task):
'''
adsorbate_name = luigi.Parameter()
dft_settings = luigi.DictParameter(GAS_SETTINGS[DFT_CALCULATOR])
max_fizzles = luigi.IntParameter(MAX_FIZZLES)

def requires(self):
return CalculateAdsorbateBasisEnergies(self.dft_settings)
Expand Down Expand Up @@ -305,12 +311,17 @@ class CalculateAdsorbateBasisEnergies(luigi.Task):
{'H': foo, 'O': bar}
'''
dft_settings = luigi.DictParameter(GAS_SETTINGS[DFT_CALCULATOR])
max_fizzles = luigi.IntParameter(MAX_FIZZLES)

def requires(self):
return {'CO': FindGas(gas_name='CO', dft_settings=self.dft_settings),
'H2': FindGas(gas_name='H2', dft_settings=self.dft_settings),
'H2O': FindGas(gas_name='H2O', dft_settings=self.dft_settings),
'N2': FindGas(gas_name='N2', dft_settings=self.dft_settings)}
return {'CO': FindGas(gas_name='CO', dft_settings=self.dft_settings,
max_fizzles=self.max_fizzles),
'H2': FindGas(gas_name='H2', dft_settings=self.dft_settings,
max_fizzles=self.max_fizzles),
'H2O': FindGas(gas_name='H2O', dft_settings=self.dft_settings,
max_fizzles=self.max_fizzles),
'N2': FindGas(gas_name='N2', dft_settings=self.dft_settings,
max_fizzles=self.max_fizzles)}

def run(self):
# Load each gas and calculate their energies
Expand Down Expand Up @@ -378,6 +389,7 @@ class CalculateSurfaceEnergy(luigi.Task):
get_slab_settings = luigi.DictParameter(SLAB_SETTINGS['get_slab_settings'])
dft_settings = luigi.DictParameter(SLAB_SETTINGS[DFT_CALCULATOR])
bulk_dft_settings = luigi.DictParameter(SE_BULK_SETTINGS[DFT_CALCULATOR])
max_fizzles = luigi.IntParameter(MAX_FIZZLES)

def _static_requires(self):
'''
Expand All @@ -387,7 +399,9 @@ def _static_requires(self):
then just call it first in `run`.
'''
# Define our static dependency, the bulk relaxation
find_bulk_task = FindBulk(mpid=self.mpid, dft_settings=self.bulk_dft_settings)
find_bulk_task = FindBulk(mpid=self.mpid,
dft_settings=self.bulk_dft_settings,
max_fizzles=self.max_fizzles)

# If our dependency is done, then save the relaxed bulk atoms object as
# an attribute for use by the other methods
Expand Down Expand Up @@ -498,7 +512,8 @@ def _dynamic_requires(self):
shift=self.shift,
min_height=min_height,
dft_settings=self.dft_settings,
bulk_dft_settings=self.bulk_dft_settings)
bulk_dft_settings=self.bulk_dft_settings,
max_fizzles=self.max_fizzles)
surface_relaxation_tasks.append(task)

# Save these tasks as an attribute so we can use the actual tasks later.
Expand Down

0 comments on commit eb2d408

Please sign in to comment.