BUG: shutil.SameFileError when running Using atomate2 with FireWorks tutorial
**Describe the bug**
Same as https://github.com/materialsproject/atomate2/issues/1248 but I am raising up a new issue because it is related to tutorial which supposed to be run out of the box:
When I run tutorial [Using atomate2 with FireWorks](https://materialsproject.github.io/atomate2/user/fireworks.html), first job completes successfully, but second fails with shutil.SameFileError: PosixPath('...INCAR.gz') and PosixPath('...INCAR.gz') are the same file
**To Reproduce**
Steps to reproduce the behavior:
1. Prepare Fireworks Slurm FireWorker, Launchpad and queue adapter.
2. In python console execute the code from tutorial:
```
from fireworks import LaunchPad
from atomate2.vasp.flows.core import RelaxBandStructureMaker
from atomate2.vasp.powerups import add_metadata_to_flow
from jobflow.managers.fireworks import flow_to_workflow
from pymatgen.core import Structure
# construct a rock salt MgO structure
mgo_structure = Structure(
lattice=[[0, 2.13, 2.13], [2.13, 0, 2.13], [2.13, 2.13, 0]],
species=["Mg", "O"],
coords=[[0, 0, 0], [0.5, 0.5, 0.5]],
)
# make a band structure flow to optimise the structure and obtain the band structure
bandstructure_flow = RelaxBandStructureMaker().make(mgo_structure)
# (Optional) add metadata to the flow task document.
# Could be useful to filter specific results from the database.
# For e.g., adding material project ID for the compound, use following lines
bandstructure_flow = add_metadata_to_flow(
flow=bandstructure_flow,
additional_fields={"mp_id": "mp-190"},
)
# convert the flow to a fireworks WorkFlow object
wf = flow_to_workflow(bandstructure_flow)
# submit the workflow to the FireWorks launchpad
lpad = LaunchPad.auto_load()
lpad.add_wf(wf)
```
Should print something like `2026-03-29 12:30:51,697 INFO Added a workflow. id_map: {-5: 1, -4: 2, -3: 3, -2: 4, -1: 5}` in console.
3. Inspect workflow being ready to submit `get_wflows`:
```
{
"state": "READY",
"name": "relax and band structure--1",
"created_on": "2026-03-29T04:30:50.635000",
"states_list": "W-W-W-W-REA"
}
```
4. Submit first task `qlaunch singleshot`:
```
2026-03-29 12:31:06,261 INFO moving to launch_dir /public/home/xtalgo/tests/a2
2026-03-29 12:31:06,262 INFO submitting queue script
2026-03-29 12:31:06,281 INFO Job submission was successful and job_id is 5135727
```
5. Relaxation task will be submitted and finished quickly. Wait until it completes and all .gz files are generated:
```
ls
AECCAR0.gz CHG.gz EIGENVAL.gz FW_submit.script KPOINTS.gz OUTCAR.gz POTCAR.gz std_err.txt XDATCAR.gz
AECCAR1.gz CONTCAR.gz FW_job-5135727.error IBZKPT.gz KPOINTS.orig.gz PCDAT.gz POTCAR.orig.gz vasp.out.gz
AECCAR2.gz custodian.json.gz FW_job-5135727.out INCAR.gz LOCPOT.gz POSCAR.gz PROCAR.gz vasprun.xml.gz
CHGCAR.gz DOSCAR.gz FW.json INCAR.orig.gz OSZICAR.gz POSCAR.orig.gz REPORT.gz WAVECAR.gz
```
`lpad get_wflows` now reports
```
{
"state": "RUNNING",
"name": "relax and band structure--1",
"created_on": "2026-03-29T04:30:50.635000",
"states_list": "W-W-W-REA-C"
}
```
6. Submit the next task with `qlaunch singleshot`:
```
2026-03-29 12:33:45,493 INFO moving to launch_dir /public/home/xtalgo/tests/a2
2026-03-29 12:33:45,494 INFO submitting queue script
2026-03-29 12:33:45,513 INFO Job submission was successful and job_id is 5135781
```
See the error:
```
lpad get_wflows
{
"state": "FIZZLED",
"name": "relax and band structure--1",
"created_on": "2026-03-29T04:30:50.635000",
"states_list": "W-W-W-F-C"
}
```
```
cat FW_job-5135781.error
Traceback (most recent call last):
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/fireworks/core/rocket.py", line 265, in run
m_action = t.run_task(my_spec)
^^^^^^^^^^^^^^^^^^^
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/jobflow/managers/fireworks.py", line 177, in run_task
response = job.run(store=store)
^^^^^^^^^^^^^^^^^^^^
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/jobflow/core/job.py", line 604, in run
response = function(*self.function_args, **self.function_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/vasp/jobs/base.py", line 214, in make
copy_vasp_outputs(prev_dir, **self.copy_vasp_kwargs)
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/utils/file_client.py", line 586, in gen_file_client
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/vasp/files.py", line 89, in copy_vasp_outputs
copy_files(
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/utils/file_client.py", line 588, in gen_file_client
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/common/files.py", line 73, in copy_files
file_client.copy(from_file, to_file, src_host=src_host)
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/site-packages/atomate2/utils/file_client.py", line 240, in copy
shutil.copy2(src_filename, dest_filename)
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/shutil.py", line 463, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/public/home/xtalgo/miniconda3/envs/camd/lib/python3.12/shutil.py", line 240, in copyfile
raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: PosixPath('/public/home/xtalgo/tests/a2/INCAR.gz') and PosixPath('/public/home/xtalgo/tests/a2/INCAR.gz') are the same file
```
**Expected behavior**
I expect the tutorial to work out of the box without need modifying the source code of the atomate2 package, which should clean up files properly."
0 条评论