Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Remove redundant conversion of project name #1543

Merged
merged 11 commits into from
Jul 20, 2024
29 changes: 4 additions & 25 deletions pyiron_base/project/archiving/export_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ def copy_files_to_archive(
compressed (bool): if True compress archive_directory as a tarball; default True
copy_all_files (bool): if True include job output files in archive, otherwise just include .h5 files; default False
"""
if archive_directory[-7:] == ".tar.gz":
archive_directory = archive_directory[:-7]
if not compressed:
compressed = True

assert isinstance(archive_directory, str) and ".tar.gz" not in archive_directory
# print("directory to transfer: "+directory_to_transfer)
if not copy_all_files:
pfi = PyFileIndex(path=directory_to_transfer, filter_function=filter_function)
Expand Down Expand Up @@ -111,29 +108,11 @@ def copy_files_to_archive(
compress_dir(archive_directory)


def export_database(project_instance, directory_to_transfer, archive_directory):
def export_database(pr, directory_to_transfer, archive_directory):
# here we first check wether the archive directory is a path
# or a project object
if isinstance(archive_directory, str):
if archive_directory[-7:] == ".tar.gz":
archive_directory = archive_directory[:-7]
archive_directory = os.path.basename(archive_directory)
# if the archive_directory is a project
elif static_isinstance(
obj=archive_directory.__class__,
obj_type=[
"pyiron_base.project.generic.Project",
],
):
archive_directory = archive_directory.path
else:
raise RuntimeError(
"""the given path for exporting to,
does not have the correct format paths as string
or pyiron Project objects are expected"""
)
assert isinstance(archive_directory, str) and ".tar.gz" not in archive_directory
directory_to_transfer = os.path.basename(directory_to_transfer)
pr = project_instance.open(os.curdir)
df = pr.job_table()
job_ids_sorted = sorted(df.id.values)
new_job_ids = list(range(len(job_ids_sorted)))
Expand All @@ -151,7 +130,7 @@ def export_database(project_instance, directory_to_transfer, archive_directory):
for job_id in df.parentid
]
df["project"] = update_project(
project_instance,
pr,
samwaseda marked this conversation as resolved.
Show resolved Hide resolved
directory_to_transfer=directory_to_transfer,
archive_directory=archive_directory,
df=df,
Expand Down
3 changes: 3 additions & 0 deletions pyiron_base/project/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,9 @@ def pack(
copy_all_files (bool):
"""
destination_path_abs = os.path.abspath(destination_path)
if ".tar.gz" in destination_path_abs:
destination_path_abs = destination_path_abs.split(".tar.gz")[0]
compress = True
directory_to_transfer = os.path.dirname(self.path)
csv_file_path = os.path.join(
os.path.dirname(destination_path_abs), csv_file_name
Expand Down
Loading