Skip to content

Commit

Permalink
Merge pull request #1319 from pyiron/depworkdir
Browse files Browse the repository at this point in the history
Deprecate workdir path getter in favour of job.files
  • Loading branch information
jan-janssen authored Feb 14, 2024
2 parents 1667c11 + ac42a60 commit b1b7165
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .ci_support/environment-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- pandas =2.0.3
- phonopy =2.20.0
- pint =0.18
- pyiron_base =0.7.3
- pyiron_base =0.7.7
- pylammpsmpi =0.2.7
- pyscal =2.10.4
- scikit-learn =1.2.1
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- pandas =2.2.0
- phonopy =2.21.0
- pint =0.23
- pyiron_base =0.7.5
- pyiron_base =0.7.7
- pylammpsmpi =0.2.13
- pyscal =2.10.18
- scikit-learn =1.4.0
Expand Down
1 change: 1 addition & 0 deletions pyiron_atomistics/atomistics/job/atomistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def restart(self, job_name=None, job_type=None):
new_ham._generic_input["structure"] = "atoms"
return new_ham

@deprecate("use job.files instead!")
def get_workdir_file(self, filename: str) -> None:
"""
Checks if a given file exists within the job's working directory and returns the absolute path to it.
Expand Down
6 changes: 3 additions & 3 deletions pyiron_atomistics/lammps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def compress(self, files_to_compress=None):
"""
if files_to_compress is None:
files_to_compress = [
f for f in list(self.list_files()) if f not in ["restart.out"]
f for f in self.files.list() if f not in ["restart.out"]
]
super(LammpsBase, self).compress(files_to_compress=files_to_compress)

Expand Down Expand Up @@ -831,9 +831,9 @@ def restart(self, job_name=None, job_type=None):
new_ham = super(LammpsBase, self).restart(job_name=job_name, job_type=job_type)
if new_ham.__name__ == self.__name__:
new_ham.potential = self.potential
if "restart.out" in self.list_files():
if "restart.out" in self.files.list():
new_ham.read_restart_file(filename="restart.out")
new_ham.restart_file_list.append(self.get_workdir_file("restart.out"))
new_ham.restart_file_list.append(self.files.restart_out)
return new_ham

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions pyiron_atomistics/sphinx/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,15 +1742,15 @@ def compress(self, files_to_compress=None):
if files_to_compress is None:
files_to_compress = [
f
for f in list(self.list_files())
for f in self.files.list()
if (
f not in ["rho.sxb", "waves.sxb"]
and not stat.S_ISFIFO(
os.stat(os.path.join(self.working_directory, f)).st_mode
)
)
]
for f in list(self.list_files()):
for f in self.files.list():
filename = os.path.join(self.working_directory, f)
if (
f not in files_to_compress
Expand Down Expand Up @@ -1857,7 +1857,7 @@ def run_addon(

# --- link other files
linkfiles = []
for file in self.list_files():
for file in self.files.list():
linkfile = os.path.join(tempd, file)
if not os.path.isfile(linkfile):
os.symlink(
Expand Down
15 changes: 7 additions & 8 deletions pyiron_atomistics/vasp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ def cleanup(self, files_to_remove=("WAVECAR", "CHGCAR", "CHG", "vasprun.xml")):
"""
Removes excess files (by default: WAVECAR, CHGCAR, CHG)
"""
list_files = self.list_files()
for file in list_files:
for file in self.files.list():
if file in files_to_remove:
abs_file_path = os.path.join(self.working_directory, file)
os.remove(abs_file_path)
Expand Down Expand Up @@ -1631,7 +1630,7 @@ def restart_from_charge_density(
new_ham = self.restart(job_name=job_name, job_type=job_type)

if new_ham.__name__ == self.__name__:
new_ham.restart_file_list.append(self.get_workdir_file("CHGCAR"))
new_ham.restart_file_list.append(self.files.CHGCAR)
new_ham.input.incar["ICHARG"] = self.get_icharg_value(
icharg=icharg,
self_consistent_calc=self_consistent_calc,
Expand Down Expand Up @@ -1680,8 +1679,8 @@ def restart_from_wave_and_charge(
"""
new_ham = self.restart(job_name=job_name, job_type=job_type)
if new_ham.__name__ == self.__name__:
new_ham.restart_file_list.append(self.get_workdir_file("CHGCAR"))
new_ham.restart_file_list.append(self.get_workdir_file("WAVECAR"))
new_ham.restart_file_list.append(self.files.CHGCAR)
new_ham.restart_file_list.append(self.files.WAVECAR)
new_ham.input.incar["ISTART"] = istart
new_ham.input.incar["ICHARG"] = self.get_icharg_value(
icharg=icharg,
Expand All @@ -1699,7 +1698,7 @@ def compress(self, files_to_compress=None):
if files_to_compress is None:
files_to_compress = [
f
for f in list(self.list_files())
for f in self.files.list()
if f
not in [
"CHGCAR",
Expand All @@ -1712,7 +1711,7 @@ def compress(self, files_to_compress=None):
]
]
# delete empty files
for f in list(self.list_files()):
for f in self.files.list():
filename = os.path.join(self.working_directory, f)
if (
f not in files_to_compress
Expand All @@ -1736,7 +1735,7 @@ def restart_from_wave_functions(self, job_name=None, job_type=None, istart=1):
"""
new_ham = self.restart(job_name=job_name, job_type=job_type)
if new_ham.__name__ == self.__name__:
new_ham.restart_file_list.append(self.get_workdir_file("WAVECAR"))
new_ham.restart_file_list.append(self.files.WAVECAR)
new_ham.input.incar["ISTART"] = istart
return new_ham

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"pandas==2.2.0",
"phonopy==2.21.0",
"pint==0.23",
"pyiron_base==0.7.5",
"pyiron_base==0.7.7",
"pylammpsmpi==0.2.13",
"scipy==1.12.0",
"scikit-learn==1.4.0",
Expand Down
8 changes: 4 additions & 4 deletions tests/vasp/test_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_run_complete(self):
job_chg_den = self.job_complete.restart_from_charge_density(job_name="chg")
self.assertEqual(job_chg_den.structure, self.job_complete.get_structure(-1))
self.assertTrue(
posixpath.join(self.job_complete.working_directory, "CHGCAR")
os.path.join(self.job_complete.working_directory, "CHGCAR")
in job_chg_den.restart_file_list
)

Expand All @@ -380,11 +380,11 @@ def check_group_is_empty(example_job, group_name):
)
self.assertEqual(job_chg_wave.structure, self.job_complete.get_structure(-1))
self.assertTrue(
posixpath.join(self.job_complete.working_directory, "WAVECAR")
os.path.join(self.job_complete.working_directory, "WAVECAR")
in job_chg_wave.restart_file_list
)
self.assertTrue(
posixpath.join(self.job_complete.working_directory, "CHGCAR")
os.path.join(self.job_complete.working_directory, "CHGCAR")
in job_chg_wave.restart_file_list
)
for key, val in job_chg_wave.restart_file_dict.items():
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_kspacing(self):
job_kspace.input.incar["KSPACING"] = 0.5
with warnings.catch_warnings(record=True) as w:
job_kspace.run(run_mode="manual")
self.assertNotIn("KPOINTS", job_kspace.list_files(), "'KPOINTS' file written even when "
self.assertNotIn("KPOINTS", job_kspace.files.list(), "'KPOINTS' file written even when "
"KPACING tag is present in INCAR")

self.assertTrue(len(w) <= 2)
Expand Down

0 comments on commit b1b7165

Please sign in to comment.