diff --git a/.ci_support/environment-docs.yml b/.ci_support/environment-docs.yml index 0b6f4e3cc..4063f5d2a 100644 --- a/.ci_support/environment-docs.yml +++ b/.ci_support/environment-docs.yml @@ -19,7 +19,7 @@ dependencies: - psutil =6.0.0 - pyfileindex =0.0.27 - pyiron_snippets =0.1.4 -- executorlib =0.0.1 +- executorlib =0.0.2 - pysqa =0.1.21 - pytables =3.10.1 - sqlalchemy =2.0.32 diff --git a/.ci_support/environment-mini.yml b/.ci_support/environment-mini.yml index aafc597ba..65e3cd8f0 100644 --- a/.ci_support/environment-mini.yml +++ b/.ci_support/environment-mini.yml @@ -10,7 +10,7 @@ dependencies: - psutil =6.0.0 - pyfileindex =0.0.27 - pyiron_snippets =0.1.3 -- executorlib =0.0.1 +- executorlib =0.0.2 - pysqa =0.1.21 - pytables =3.10.1 - sqlalchemy =2.0.32 diff --git a/.ci_support/environment.yml b/.ci_support/environment.yml index de400c55a..d58fc18d9 100644 --- a/.ci_support/environment.yml +++ b/.ci_support/environment.yml @@ -17,7 +17,7 @@ dependencies: - psutil =6.0.0 - pyfileindex =0.0.27 - pyiron_snippets =0.1.4 -- executorlib =0.0.1 +- executorlib =0.0.2 - pysqa =0.1.21 - pytables =3.10.1 - sqlalchemy =2.0.32 diff --git a/binder/environment.yml b/binder/environment.yml index aae94e696..afe8e4750 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -16,7 +16,7 @@ dependencies: - psutil =6.0.0 - pyfileindex =0.0.27 - pyiron_snippets =0.1.4 -- executorlib =0.0.1 +- executorlib =0.0.2 - pysqa =0.1.21 - pytables =3.10.1 - sqlalchemy =2.0.32 diff --git a/pyiron_base/jobs/job/extension/executable.py b/pyiron_base/jobs/job/extension/executable.py index b2417d744..8df0492b6 100644 --- a/pyiron_base/jobs/job/extension/executable.py +++ b/pyiron_base/jobs/job/extension/executable.py @@ -3,7 +3,7 @@ # Distributed under the terms of "New BSD License", see the LICENSE file. import os -from dataclasses import asdict +from dataclasses import asdict, fields from pyiron_snippets.resources import ExecutableResolver @@ -218,14 +218,7 @@ def _to_dict(self): return asdict(self.storage) def _from_dict(self, obj_dict, version=None): - data_container_keys = [ - "version", - "name", - "operation_system_nt", - "executable", - "mpi", - "accepted_return_codes", - ] + data_container_keys = tuple(f.name for f in fields(ExecutableDataClass)) executable_class_dict = {} # Backwards compatibility; dict state used to be nested one level deeper if "executable" in obj_dict.keys() and isinstance(obj_dict["executable"], dict): diff --git a/pyiron_base/jobs/job/util.py b/pyiron_base/jobs/job/util.py index bbb66b377..1bc03a995 100644 --- a/pyiron_base/jobs/job/util.py +++ b/pyiron_base/jobs/job/util.py @@ -95,12 +95,12 @@ def _get_project_for_copy(job, project, new_job_name): ): file_project = project.project hdf5_project = project.project_hdf5.open(new_job_name) - elif isinstance(project, job.project.__class__): + elif isinstance(job.project, project.__class__): file_project = project hdf5_project = job.project_hdf5.__class__( project=project, file_name=new_job_name, h5_path="/" + new_job_name ) - elif isinstance(project, job.project_hdf5.__class__): + elif isinstance(job.project_hdf5, project.__class__): file_project = project.project hdf5_project = project.open(new_job_name) elif project is None: diff --git a/pyiron_base/project/archiving/import_archive.py b/pyiron_base/project/archiving/import_archive.py index 07d6c4255..775cc5dd3 100644 --- a/pyiron_base/project/archiving/import_archive.py +++ b/pyiron_base/project/archiving/import_archive.py @@ -1,4 +1,5 @@ import os +import posixpath import tarfile import tempfile from shutil import copytree @@ -57,8 +58,8 @@ def import_jobs(project_instance, archive_directory): pr_import = project_instance.open(os.curdir) df["project"] = [ - os.path.normpath( - os.path.join(pr_import.project_path, os.path.relpath(p, common_path)) + posixpath.normpath( + posixpath.join(pr_import.project_path, posixpath.relpath(p, common_path)) ) + "/" for p in df["project"].values @@ -105,8 +106,8 @@ def transfer_files(origin_path: str, project_path: str): str: Common path. """ df = get_dataframe(origin_path=origin_path) - common_path = os.path.commonpath(list(df["project"])) - copytree(os.path.join(origin_path, common_path), project_path, dirs_exist_ok=True) + common_path = posixpath.commonpath(list(df["project"])) + copytree(posixpath.join(origin_path, common_path), project_path, dirs_exist_ok=True) return df, common_path diff --git a/pyproject.toml b/pyproject.toml index cd064fd2c..8a590e0ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ "cloudpickle==3.0.0", - "executorlib==0.0.1", + "executorlib==0.0.2", "h5io_browser==0.1.0", "h5py==3.11.0", "numpy==2.1.0", diff --git a/tests/static/pack/export.csv b/tests/static/pack/export.csv new file mode 100644 index 000000000..2a0997cb5 --- /dev/null +++ b/tests/static/pack/export.csv @@ -0,0 +1,2 @@ +,id,status,chemicalformula,job,subjob,project,timestart,timestop,totalcputime,computer,hamilton,hamversion,parentid,masterid +0,0,finished,,toy,/toy,test_pack/my_project,2024-08-22 16:10:26.556984,,,pyiron@7720454e9ac5#1,ToyJob,0.4,, diff --git a/tests/static/pack/test_pack.tar.gz b/tests/static/pack/test_pack.tar.gz new file mode 100644 index 000000000..5742bc3f6 Binary files /dev/null and b/tests/static/pack/test_pack.tar.gz differ diff --git a/tests/unit/archiving/test_import.py b/tests/unit/archiving/test_import.py index 15d92ae47..4ccc93d0e 100644 --- a/tests/unit/archiving/test_import.py +++ b/tests/unit/archiving/test_import.py @@ -3,7 +3,7 @@ from pyiron_base import Project from pandas._testing import assert_frame_equal from filecmp import dircmp -from shutil import rmtree +from shutil import rmtree, copytree import tarfile from pyiron_base._tests import PyironTestCase, ToyJob @@ -181,5 +181,26 @@ def test_backwards_compatibility(self): self.imp_pr.unpack(origin_path=self.arch_dir_comp, csv_file_name="ahoy.csv") +class TestUnpackingBackwardsCompatibility(PyironTestCase): + def test_import_old_tar(self): + copytree( + os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "../../static/pack", + ), + os.getcwd(), + dirs_exist_ok=True, + ) + pr = Project("old_tar") + pr.unpack(origin_path="test_pack.tar.gz") + job = pr.load("toy") + self.assertEqual(job.job_name, "toy") + self.assertEqual(job.input.data_in, 100) + self.assertEqual(job.output.data_out, 101) + pr.remove(enable=True, enforce=True) + os.remove("test_pack.tar.gz") + os.remove("export.csv") + + if __name__ == "__main__": unittest.main()