from ewoksid02.tasks import (
    ID02ProcessingTask,
    NormalizationTask,
)
from .conftest import (
    RAW_LIMA_FILE,
    RESOURCES,
    RAW_MASTER_FILE,
    FILENAME_PROCESSED_NORM_NEW,
)
from blissdata.redis_engine.scan import Scan

inputs_eiger2 = {
    "detector_name": "eiger2",
    "filename_data": RESOURCES.getfile(RAW_MASTER_FILE),
    "filename_lima": RESOURCES.getfile(RAW_LIMA_FILE),
    "scan_nb": 9,
    "subscan": 1,
    "do_process": True,
    "do_save": False,
}


def _debug_normalizationtask_offline_from_raw(detector_name: str = "eiger2"):
    return NormalizationTask(
        inputs={
            "detector_name": detector_name,
            "filename_data": RESOURCES.getfile(RAW_MASTER_FILE),
            "filename_lima": RESOURCES.getfile(RAW_LIMA_FILE),
            "scan_nb": 9,
            "subscan": 1,
            "do_process": True,
            "do_save": False,
        }
    )


def _debug_normalizationtask_offline_from_processed(detector_name: str = "eiger2"):
    return NormalizationTask(
        inputs={
            "detector_name": detector_name,
            "filename_data": RESOURCES.getfile(FILENAME_PROCESSED_NORM_NEW),
            "do_process": True,
            "do_save": True,
            "processing_filename": "/tmp_14_days/edgar/kkk.h5",
        }
    )


def _debug_processing_task_online(scan: Scan, detector_name: str):
    return ID02ProcessingTask(
        inputs={
            "detector_name": detector_name,
            "scan_memory_url": scan.key,
            "beacon_host": "id02:25000",
            "filename_data": scan.info["filename"],
            "filename_lima": f"{scan.info['images_path'].format(img_acq_device=detector_name)}{'%02d' % 0}.h5",
            "scan_nb": scan.info["scan_nb"],
            "subscan": 1,
            "do_process": False,
            "do_save": False,
            "lima_index_number_format": "%02d",
        }
    )
