Retrieve disk usage estimates as CWL ResourceRequirement and hint.

    Disk specification for temporary files and outputs.

    Also optionally includes disk input estimates as a custom hint for
    platforms which need to stage these and don't pre-estimate these when
    allocating machine sizes.

def _get_disk_estimates(name, parallel, inputs, file_estimates, samples, disk,
                        cur_remotes, no_files):
    """Retrieve disk usage estimates as CWL ResourceRequirement and hint.

    Disk specification for temporary files and outputs.

    Also optionally includes disk input estimates as a custom hint for
    platforms which need to stage these and don't pre-estimate these when
    allocating machine sizes.
    """
    tmp_disk, out_disk, in_disk = 0, 0, 0
    if file_estimates:
        if disk:
            for key, multiplier in disk.items():
                if key in file_estimates:
                    out_disk += int(multiplier * file_estimates[key])
        for inp in inputs:
            scale = 2.0 if inp.get("type") == "array" else 1.0
            # Allocating all samples, could remove for `to_rec` when we ensure we
            # don't have to stage. Currently dnanexus stages everything so need to consider
            if parallel in ["multi-combined", "multi-batch"] and "dnanexus" in cur_remotes:
                scale *= (len(samples))
            if workflow.is_cwl_record(inp):
                for f in _get_record_fields(inp):
                    if f["name"] in file_estimates:
                        in_disk += file_estimates[f["name"]] * scale
            elif inp["id"] in file_estimates:
                in_disk += file_estimates[inp["id"]] * scale
        # Round total estimates to integer, assign extra half to temp space
        # It's not entirely clear how different runners interpret this
        tmp_disk = int(math.ceil(out_disk * 0.5))
        out_disk = int(math.ceil(out_disk))

    bcbio_docker_disk = (10 if cur_remotes else 1) * 1024  # Minimum requirements for bcbio Docker image
    disk_hint = {"outdirMin": bcbio_docker_disk + out_disk, "tmpdirMin": tmp_disk}
    # Skip input disk for steps which require only transformation (and thus no staging)
    if no_files:
        in_disk = 0
    # Avoid accidentally flagging as no staging if we don't know sizes of expected inputs
    elif in_disk == 0:
        in_disk = 1
    input_hint = {"class": "dx:InputResourceRequirement", "indirMin": int(math.ceil(in_disk))}
    return disk_hint, input_hint