|
3 | 3 |
|
4 | 4 | import cyclopts
|
5 | 5 | import yaml
|
6 |
| - |
7 | 6 | from depiction_targeted_preproc.pipeline.prepare_params import Params
|
8 | 7 | from depiction_targeted_preproc.pipeline_config.artifacts_mapping import get_result_files_new
|
9 | 8 | from depiction_targeted_preproc.workflow.snakemake_invoke import SnakemakeInvoke
|
|
12 | 11 |
|
13 | 12 |
|
14 | 13 | @app.default()
|
15 |
| -def run_chunk(chunk_dir: Path): |
16 |
| - zip_file_path = run_workflow(sample_dir=chunk_dir) |
17 |
| - outputs = [ |
18 |
| - { |
19 |
| - "type": "bfabric_copy_resource", |
20 |
| - "local_path": str(zip_file_path.absolute()), |
21 |
| - "store_entry_path": zip_file_path.name, |
22 |
| - } |
23 |
| - ] |
24 |
| - result = {"outputs": outputs} |
25 |
| - with (chunk_dir / "outputs.yml").open("w") as f: |
26 |
| - yaml.safe_dump(result, f) |
27 |
| - |
28 |
| - |
29 |
| -def run_workflow(sample_dir: Path) -> Path: |
| 14 | +def run_workflow(chunk_dir: Path) -> Path: |
| 15 | + chunk_dir = chunk_dir.absolute() |
| 16 | + |
30 | 17 | # TODO to be refactored
|
31 |
| - params = Params.model_validate(yaml.safe_load((sample_dir / "params.yml").read_text())) |
32 |
| - result_files = get_result_files_new(requested_artifacts=params.requested_artifacts, sample_dir=sample_dir) |
| 18 | + params = Params.model_validate(yaml.safe_load((chunk_dir / "params.yml").read_text())) |
| 19 | + result_files = get_result_files_new(requested_artifacts=params.requested_artifacts, sample_dir=chunk_dir) |
33 | 20 |
|
34 | 21 | # invoke snakemake
|
35 | 22 | # TODO note report file is deactivated because it's currently broken due to dependencies (jinja2)
|
36 |
| - SnakemakeInvoke(report_file=None).invoke(work_dir=sample_dir.parent, result_files=result_files) |
| 23 | + SnakemakeInvoke(report_file=None).invoke(work_dir=chunk_dir.parent, result_files=result_files) |
37 | 24 |
|
38 | 25 | # zip the results
|
39 |
| - sample_name = sample_dir.name |
40 |
| - output_dir = sample_dir / "outputs" |
| 26 | + sample_name = chunk_dir.name |
| 27 | + output_dir = chunk_dir / "outputs" |
41 | 28 | output_dir.mkdir(exist_ok=True)
|
42 | 29 | zip_file_path = output_dir / f"{sample_name}.zip"
|
43 | 30 | with zipfile.ZipFile(zip_file_path, "w") as zip_file:
|
44 | 31 | for result_file in result_files:
|
45 |
| - zip_entry_path = result_file.relative_to(sample_dir.parent) |
| 32 | + zip_entry_path = result_file.relative_to(chunk_dir.parent) |
46 | 33 | zip_file.write(result_file, arcname=zip_entry_path)
|
47 | 34 | return zip_file_path
|
48 | 35 |
|
|
0 commit comments