Skip to content

Commit

Permalink
Merge pull request #1543 from pyiron/convert_name
Browse files Browse the repository at this point in the history
[patch] Remove redundant conversion of project name
  • Loading branch information
samwaseda authored Jul 20, 2024
2 parents 40d617b + 7ee93a4 commit 7b03591
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
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,
project_instance=pr,
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

0 comments on commit 7b03591

Please sign in to comment.