TMSS-216: removed dataformat property when creating TaskRelations. Added...
TMSS-216: removed dataformat property when creating TaskRelations. Added TaskRelations to the cleanup convenience method, and added a big rationale explaining it's usage
'''create a cleanuptask for the given scheduling_unit which will cleanup all output dataproducts from tasks in this scheduling_unit which aren't already cleaned up'''
# Rationale:
# adding a cleanup task(blueprint) to a scheduling_unit_blueprint adds a task to the graph (which breaks the immutable blueprint concept),
# but it does not modify observation/pipeline behaviour, hence we allow it.
# Regard this as a convenience function to allow users to simplify cleaning up after themselves if they forgot to specificy a cleanup task.
#
# Note: We do modify the graph (both in draft and blueprint),
# but we do NOT update the specifications_doc because that doc (blueprint) is immutable, and shows the user what was specified.
# The fact that the graph in the specifications_doc and in real instances are different (with an addded cleanup task) shows the users that cleanup
# was apparently forgotten at specification time, and added later, which is explainable.
#
# Maybe we want to split this function in the future into a "add cleanup to draft" and/or "add cleanup to blueprint"
# For now, we present it as a friendly convenience function to cleanup after yourself once the blueprint is already running / already ran with experimental scheduling units.
# In practice we will instantiate most scheduling units from properly defined observation_strategy_templates which include cleanup.
logger.info("Created Cleanup Task id=%d for scheduling_unit id=%s, adding the outputs of all producing tasks in the scheduling unit to the cleanup...",cleanup_task_blueprint.id,scheduling_unit_blueprint.id)
# ... and connect the outputs of the producing tasks to the cleanup, so the cleanup task knows what to remove.