'''
Settings for the canonical `TissueMAPS` workflow.

In principle, workflow steps can be arranged in arbitrary order and
interdependencies between steps are checked dynamically while the workflow
progresses. If a dependency is not fullfilled upon progression to the
next step, i.e. if a required input has not been generated by another
upstream step, the workflow would stop. However, for the standard
workflow we would like to ensure that the sequence of steps in the workflow
description is correct and thereby prevent submission of an incorrectly
described workflow in the first place.
'''

#: Stages:
#: For more information please refer to the corresponding section in
#: :ref:`introduction <workflow>`
STAGES = {
    [
        {
            'name': 'image_conversion',
            'steps': [
                {'name': 'metaextract'},
                {'name': 'metaconfig'},
                {'name': 'imextract'}
            ]
        },
        {
            'name': 'image_preprocessing',
            'steps': [
                {'name': 'corilla'},
                {'name': 'align'}
            ]
        },
        {
            'name': 'pyramid_creation',
            'steps': [
                {'name': 'illuminati'}
            ]
        },
        {
            'name': 'image_analysis',
            'steps': [
                {'name': 'jterator'}
            ]
        }
    ]
}


#: Interdependencies between individual workflow steps.
DEPENDENCIES = {
    'metaextract': set(),
    'metaconfig': {'metaextract'},
    'imextract': {'metaconfig'},
    'align': {'imextract'},
    'corilla': {'imextract'},
    'illuminati': {'imextract'},
    'jterator': {'imextract'}
}


#: Optional dependencies of workflow steps.
OPTIONAL_DEPENDENCIES = {
   'illuminati': {'align', 'corilla'},
   'jterator': {'align', 'corilla'}
}

'''
Settings for the canonical `TissueMAPS` workflow.

In principle, workflow steps can be arranged in arbitrary order and
interdependencies between steps are checked dynamically while the workflow
progresses. If a dependency is not fullfilled upon progression to the
next step, i.e. if a required input has not been generated by another
upstream step, the workflow would stop. However, for the standard
workflow we would like to ensure that the sequence of steps in the workflow
description is correct and thereby prevent submission of an incorrectly
described workflow in the first place.
'''

#: Implemented workflow stages:
#: For more information please refer to the corresponding section in
#: :ref:`introduction <workflow>`
STAGES = {
    'image_conversion', 'image_conversion',
    'pyramid_creation', 'image_analysis'
}

STEPS_PER_STAGE = {
    'image_conversion':
        ['metaextract', 'metaconfig', 'imextract'],
    'image_preprocessing':
        ['corilla', 'align'],
    'pyramid_creation':
        ['illuminati'],
    'image_analysis':
        ['jterator']
}
# Note: there could be more than one pipeline!

#: Dependencies between individual workflow stages.
INTER_STAGE_DEPENDENCIES = {
    'image_conversion': {

    },
    'image_preprocessing': {
        'image_conversion'
    },
    'pyramid_creation': {
        'image_conversion', 'image_preprocessing'
    },
    'image_analysis': {
        'image_conversion', 'image_preprocessing'
    }
}

#: Dependencies between individual workflow steps within one stage.
INTRA_STAGE_DEPENDENCIES = {
    'metaextract': {

    },
    'metaconfig': {
        'metaextract'
    },
    'imextract': {
        'metaconfig'
    }
}

Update workflow dependendies