Skip to content

Commit

Permalink
create a zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Sep 4, 2024
1 parent d8f600d commit 621c73e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions src/depiction_targeted_preproc/pipeline/store_outputs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

from pathlib import Path

import yaml
from bfabric import Bfabric
from bfabric.entities import Workunit


def _get_outputs_spec(zip_file_path: Path, workunit: Workunit) -> dict[str, list[dict[str, str | int | bool]]]:
return {
"outputs": [
{
"type": "bfabric_copy_resource",
"local_path": str(zip_file_path.absolute()),
"store_entry_path": zip_file_path.name,
"workunit_id": workunit.id,
"storage_id": workunit.application.storage.id,
}
]
}


def write_outputs_spec(zip_file_path: Path, workunit: Workunit) -> None:
output_spec = _get_outputs_spec(zip_file_path=zip_file_path, workunit=workunit)
outputs_yaml = zip_file_path.parent / f"{zip_file_path.stem}_outputs_spec.yml"
with outputs_yaml.open("w") as file:
yaml.safe_dump(output_spec, file)


def store_outputs(client: Bfabric, zip_file_path: Path, workunit_id: int):
workunit = Workunit.find(id=workunit_id, client=client)
write_outputs_spec(zip_file_path=zip_file_path, workunit=workunit)
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _invoke_subprocess(self, work_dir: Path, result_files: list[Path], extra_arg
command = self.get_command_create_report(
base_command=base_command, result_files=result_files, work_dir=work_dir
)
logger.info("Executing {command}", command=command)
logger.info("Executing {command}", command=self._args_to_shell_command(command))
subprocess.run(
command,
cwd=self.workflow_dir,
Expand Down

0 comments on commit 621c73e

Please sign in to comment.