Skip to content
Snippets Groups Projects
Commit 7cc87888 authored by Ronald Jäpel's avatar Ronald Jäpel
Browse files

Refactor

parent 7e7036ca
No related branches found
No related tags found
No related merge requests found
import shlex
import subprocess import subprocess
import click import click
......
...@@ -779,24 +779,24 @@ class ProjectRepo(BaseRepo): ...@@ -779,24 +779,24 @@ class ProjectRepo(BaseRepo):
"Python sys args": str(sys.argv), "Python sys args": str(sys.argv),
"Tags": ", ".join(self.tags), "Tags": ", ".join(self.tags),
} }
csv_header = "\t".join(meta_info_dict.keys()) tsv_header = "\t".join(meta_info_dict.keys())
csv_data = "\t".join([str(x) for x in meta_info_dict.values()]) tsv_data = "\t".join([str(x) for x in meta_info_dict.values()])
with open(json_filepath, "w") as f: with open(json_filepath, "w") as f:
json.dump(meta_info_dict, f, indent=2) json.dump(meta_info_dict, f, indent=2)
if not tsv_filepath.exists(): if not tsv_filepath.exists():
with open(tsv_filepath, "w") as f: with open(tsv_filepath, "w") as f:
f.write(csv_header + "\n") f.write(tsv_header + "\n")
# csv.writer(csv_header + "\n") # csv.writer(tsv_header + "\n")
with open(tsv_filepath, "r") as f: with open(tsv_filepath, "r") as f:
existing_header = f.readline().replace("\n", "") existing_header = f.readline().replace("\n", "")
if existing_header != csv_header: if existing_header != tsv_header:
raise ValueError("The used structure of the meta_dict doesn't match the header found in log.tsv") raise ValueError("The used structure of the meta_dict doesn't match the header found in log.tsv")
with open(tsv_filepath, "a") as f: with open(tsv_filepath, "a") as f:
f.write(csv_data + "\n") f.write(tsv_data + "\n")
self.dump_package_list(logs_folderpath) self.dump_package_list(logs_folderpath)
...@@ -882,12 +882,12 @@ class ProjectRepo(BaseRepo): ...@@ -882,12 +882,12 @@ class ProjectRepo(BaseRepo):
return file_path return file_path
if branch_name is None and not os.path.exists(file_path): if branch_name is None and not os.path.exists(file_path):
branch_name_and_path = file_path.split("_cached")[-1] branch_name_and_path = file_path.split("_cached/")[-1]
if os.sep not in branch_name_and_path: if os.sep not in branch_name_and_path:
sep = "/" sep = "/"
else: else:
sep = os.sep sep = os.sep
branch_name, file_path = file_path.split(sep, maxsplit=1) branch_name, file_path = branch_name_and_path.split(sep, maxsplit=1)
if self.output_repo.exist_uncomitted_changes: if self.output_repo.exist_uncomitted_changes:
self.output_repo.stash_all_changes() self.output_repo.stash_all_changes()
...@@ -1034,6 +1034,7 @@ class ProjectRepo(BaseRepo): ...@@ -1034,6 +1034,7 @@ class ProjectRepo(BaseRepo):
commit_return = self.output_repo._git.commit("-m", message) commit_return = self.output_repo._git.commit("-m", message)
self.copy_data_to_cache() self.copy_data_to_cache()
self.update_output_master_logs() self.update_output_master_logs()
self.copy_data_to_cache("master")
print("\n" + commit_return + "\n") print("\n" + commit_return + "\n")
except git.exc.GitCommandError as e: except git.exc.GitCommandError as e:
self.output_repo.delete_active_branch_if_branch_is_empty() self.output_repo.delete_active_branch_if_branch_is_empty()
...@@ -1063,11 +1064,16 @@ class ProjectRepo(BaseRepo): ...@@ -1063,11 +1064,16 @@ class ProjectRepo(BaseRepo):
try: try:
yield new_branch_name yield new_branch_name
except Exception as e: except Exception as e:
self.capture_error(e)
self.output_repo.delete_active_branch_if_branch_is_empty() self.output_repo.delete_active_branch_if_branch_is_empty()
raise e raise e
else: else:
self.exit_context(message=results_commit_message) self.exit_context(message=results_commit_message)
def capture_error(self, error):
print(traceback.format_exc())
write_lines_to_file(self.output_path / "error.stack", traceback.format_exc())
class OutputRepo(BaseRepo): class OutputRepo(BaseRepo):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment