Comments (4)
UPDATE
For long running jobs using fireworks the following CLI script can be called from the cluster to restart the job from a fizzled state and just copy over the CONTCAR files.
#!/usr/bin/env python3
"""Restart fizzled jobs."""
import json
import logging
from pathlib import Path
import click
from fireworks import LaunchPad
from pymatgen.io.vasp.inputs import Poscar
logger = logging.getLogger(__name__)
LPAD = LaunchPad.auto_load()
def _get_fizzled(query=None):
"""Find the fizzed relaxation jobs.
The atomate2 created fireworks for long running relaxation jobs should be simple.
Basically `spec._tasks.0` should be the relaxation job.
Args:
query: query to use. The basic query is already included.
Returns:
list: list of fizzled fireworks ids
"""
fw_query = {
"spec._tasks.0.job.function.@callable": "BaseVaspMaker.make",
"state": "FIZZLED",
"$or": [
{"spec._tasks.0.job.function_args.0.@class": "Structure"},
{"spec._tasks.0.job.function_args.0.@class": "OutputReference"},
],
}
fw_query.update(query or {})
return LPAD.get_fw_ids(query=fw_query)
def _get_last_launch_dir(fw_id):
"""Get the last launch directory for a fizzled job.
Args:
fw_id: fireworks id
Returns:
str: last launch directory
"""
return LPAD.get_fw_dict_by_id(fw_id)["launches"][-1]["launch_dir"]
def _read_contcar(dir_name):
"""Read the CONTCAR currently in the directory.
Args:
dir_name: directory to read CONTCAR from
Returns:
Structure: structure from CONTCAR
"""
try:
contcar = Poscar.from_file(Path(dir_name) / "CONTCAR")
except Exception:
contcar = None
return contcar
def _update_fw_db(fw_id, structure):
"""Update the spec structure for a fizzled job.
Args:
fw_id: fireworks id
structure: structure to update to
"""
fw_dict = LPAD.get_fw_dict_by_id(fw_id)
fw_dict["spec"]["_tasks"][0]["job"]["function_args"][0][
"structure"
] = structure.as_dict()
update_dict = {"_tasks.0.job.function_args.0": structure.as_dict()}
LPAD.update_spec([fw_id], update_dict)
@click.command()
@click.option("-q", "--query", default={})
@click.option("-d", "--dry-run", is_flag=True)
def main(query, dry_run):
"""Run the CLI."""
q = json.loads(query)
fizzled = _get_fizzled(q)
for fw_id in fizzled:
dir_name = _get_last_launch_dir(fw_id)
print(f"Reading CONTCAR for {fw_id} from {dir_name}")
contcar = _read_contcar(dir_name)
if contcar is not None:
print(">>>>CONTCAR PARSED")
if contcar is not None:
# start the return first then update the db
# this way the data from the failed calculation is kept
if not dry_run:
print(f"Rerun -- {fw_id}")
LPAD.rerun_fw(fw_id)
_update_fw_db(fw_id, contcar)
if __name__ == "__main__":
main()
from atomate2.
Thanks for this code @jmmshn. What do you think about adding this as part of the command line utility for atomate2. So the command would be something like:
atm fireworks-continue ...
from atomate2.
The only question I have is whether we can ensure the position of the structure argument
from atomate2.
I think this could easily be modified to enable people to run VASP jobs on preempt-able queues, as well. I'll work on that and get back if I get it functioning
from atomate2.
Related Issues (20)
- BUG: ElasticMaker deepcopy error HOT 4
- BUG: not able to read potcars correctly HOT 5
- Adding git tags HOT 3
- Path to next atomate2 release HOT 9
- Ensuring MP workflow compatibility when switching to Pymatgen for input sets
- `BadInputSetWarning` should not be raised for ISMEAR = 0 relaxations with metals if SIGMA is small
- How to cite? HOT 2
- New pymatgen breaks lobster and phonopy workflows HOT 5
- Design of a universal base DFT task document
- Advertising the atomate2 paper writing HOT 66
- Convergence check for relaxation with forcefields
- Dealing with large structures in the phonon workflow for forcefields HOT 5
- BUG: WAVECAR deletion HOT 8
- Discussion: sigma value in NSCF calculation
- BUG: custom CHGNET model in PhononFlow throws `jsanitize` error HOT 27
- BUG:ValueError: dictionary update sequence element #0 has length 1; 2 is required HOT 1
- FEATURE: GW workflow with VASP HOT 4
- BUG: pip install atomate2 does not automatically install phonopy and seekpath HOT 2
- Feature: add an additional step to the LOBSTER workflow to reduce run times
- Improve failed perturbations handling in elastic workflow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atomate2.