def start_or_stop_cronjob(batch_update_interval: int, workflow: Workflow):
    """start a cronjob for workflow if batch_update_interval is valid

    Args:
        batch_update_interval (int): restart workflow interval, unit is minutes

    Returns:
        raise when workflow is_left is False
    """
    item_name = f'workflow_cron_job_{workflow.id}'
    batch_update_interval = batch_update_interval * 60
    if workflow.get_config().is_left and batch_update_interval > 0:
        status = composer.get_item_status(name=item_name)
        # create a cronjob
        if not status:
            composer.collect(name=item_name,
                                items=[WorkflowCronJobItem(workflow.id)],
                                metadata={},
                                interval=batch_update_interval)
            return
        if status == ItemStatus.OFF:
            raise InvalidArgumentException(
                f'cannot set item [{item_name}], since item is off')
        # patch a cronjob
        try:
            composer.patch_item_attr(name=item_name,
                                     key='interval_time',
                                     value=batch_update_interval)
        except ValueError as err:
            raise InvalidArgumentException(details=repr(err))


    elif batch_update_interval < 0:
        composer.finish(name=item_name)
    elif not workflow.get_config().is_left:
        raise InvalidArgumentException('Only left can operate this')
    else:
        logging.info('skip cronjob since batch_update_interval is -1')
start a cronjob for workflow if batch_update_interval is valid

    Args:
        batch_update_interval (int): restart workflow interval, unit is minutes

    Returns:
        raise when workflow is_left is False
    
web_console_v2/api/fedlearner_webconsole/workflow/apis.py