Loading input in a task type

Primitive parameters

Primitive inputs (of type Int, Float, String or Bool; see Parameter Types) can be accessed directly via the Python module xfworkerutil.

For example Lucid.Core.Threshold accesses upper and lower threshold input parameters:

import xfworkerutil

import thres

worker = xfworkerutil.XFWorkerJob()

inputs = worker.job['inputs']
threshold_lower = inputs['threshold_lower0']
threshold_upper = inputs['threshold_upper0']
calibration_name = inputs['calibration']

# Download input files
image = worker.get_omni_image(inputs['image'])

seg_image_omni_path = worker.create_related_path(image.metadata_path, '_seg.omni')
seg_image_pixels_path = worker.create_related_path(image.metadata_path, '_seg.raw')
thres_temp_dir_path = worker.working_dir.path / "thres"

if calibration_name is not None:
    calibrations = image.pixel_calibrations_of_unit_type(calibration_name)
    if len(calibrations) == 0:
        worker.error(f"Image is missing calibration metadata of type {calibration_name}")
    calibration = calibrations[0]
    threshold_lower = calibration.calibrated_to_raw(threshold_lower) if threshold_lower is not None else None
    threshold_upper = calibration.calibrated_to_raw(threshold_upper) if threshold_upper is not None else None

# LUPO
seg_image = thres.thres_image(
    image,
    threshold_lower,
    threshold_upper,
    seg_image_omni_path,
    seg_image_pixels_path,
    thres_temp_dir_path)

# Upload output files
seg_image_output = worker.upload_omni_output(seg_image)

# Save outputs
outputs = {
    "segments": seg_image_output,
}
worker.finish(outputs)

Bulk data

Composite parameters like Image refer to bulk data stored separately on FSS.

OMNI image data can be loaded using the xfworkerutil.XFWorkerJob.get_omni_image() as shown above. See also Loading an OMNI Image.

For other data files xfworkerutil.XFWorkerJob.download_input_file() can be used instead. See Using IPL in a task type for an example.