Skip to content

Commit

Permalink
consolidate
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Sep 17, 2024
1 parent 9e7c596 commit eef279d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 97 deletions.
13 changes: 1 addition & 12 deletions src/depiction_targeted_preproc/pipeline/prepare_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from pathlib import Path

import yaml

from bfabric import Bfabric
from bfabric.entities import Resource
from bfabric.experimental.app_interface.input_preparation import prepare_folder


def _get_ibd_resource_id(imzml_resource_id: int, client: Bfabric) -> int:
Expand Down Expand Up @@ -58,14 +58,3 @@ def write_inputs_spec(dataset_id: int, imzml_resource_id: int, client: Bfabric,
inputs_yaml = sample_dir / "inputs.yml"
with inputs_yaml.open("w") as file:
yaml.safe_dump(inputs_spec, file)


def prepare_inputs(
client: Bfabric,
sample_dir: Path,
dataset_id: int,
imzml_resource_id: int,
ssh_user: str | None,
) -> None:
write_inputs_spec(dataset_id=dataset_id, imzml_resource_id=imzml_resource_id, client=client, sample_dir=sample_dir)
prepare_folder(inputs_yaml=sample_dir / "inputs.yml", target_folder=sample_dir, client=client, ssh_user=ssh_user)
50 changes: 1 addition & 49 deletions src/depiction_targeted_preproc/pipeline/prepare_params.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from pathlib import Path

import cyclopts
import yaml
from bfabric import Bfabric
from bfabric.entities import Workunit
from bfabric.experimental.app_interface.workunit.definition import WorkunitExecutionDefinition
from loguru import logger
from pydantic import BaseModel

from bfabric.experimental.app_interface.workunit.definition import WorkunitExecutionDefinition
from depiction_targeted_preproc.pipeline_config.model import PipelineArtifact


Expand All @@ -31,44 +24,3 @@ def parse_params(definition: WorkunitExecutionDefinition) -> dict[str, str | int
requested_artifacts=requested_artifacts,
mass_list_id=definition.raw_parameters.get("mass_list_id"),
).model_dump(mode="json")


def prepare_params(
client: Bfabric,
sample_dir: Path,
workunit_id: int,
override: bool,
) -> None:
sample_dir.mkdir(parents=True, exist_ok=True)
params_yaml = sample_dir / "params.yml"
if params_yaml.is_file() and not override:
logger.info(f"Skipping params generation for {workunit_id} as it already exists and override is not set")
return
definition = WorkunitExecutionDefinition.from_workunit(Workunit.find(id=workunit_id, client=client))
with params_yaml.open("w") as file:
yaml.safe_dump(parse_params(definition), file)


app = cyclopts.App()


@app.default
def prepare_params_from_cli(
sample_dir: Path,
config_preset: str,
requested_artifacts: list[str],
n_jobs: int = 32,
) -> None:
sample_dir.mkdir(parents=True, exist_ok=True)
params_yaml = sample_dir / "params.yml"
with params_yaml.open("w") as file:
yaml.safe_dump(
Params(config_preset=config_preset, requested_artifacts=requested_artifacts, n_jobs=n_jobs).model_dump(
mode="json"
),
file,
)


if __name__ == "__main__":
app()
36 changes: 0 additions & 36 deletions src/depiction_targeted_preproc/pipeline/store_outputs.py

This file was deleted.

0 comments on commit eef279d

Please sign in to comment.