def _get_validated_enabled_regions(json_spec, from_command_line):
    """
    Returns a set of regions (region names) in which the global workflow
    should be enabled. Also validates and synchronizes the regions
    passed via CLI argument and in the regionalOptions field.
    """
    enabled_regions = dxpy.executable_builder.get_enabled_regions('globalworkflow',
                                                                  json_spec,
                                                                  from_command_line,
                                                                  WorkflowBuilderException)
    if not enabled_regions:
        enabled_regions = []
        if not dxpy.WORKSPACE_ID:
            msg = "A context project must be selected to enable a workflow in the project's region."
            msg += " You can use 'dx select' to select a project. Otherwise you can use --region option"
            msg += " to select a region in which the workflow should be enabled"
            raise(WorkflowBuilderException(msg))
        region = dxpy.api.project_describe(dxpy.WORKSPACE_ID,
                                           input_params={"fields": {"region": True}})["region"]

        enabled_regions.append(region)

    if not enabled_regions:
        raise AssertionError("This workflow should be enabled in at least one region")

    return set(enabled_regions)
Returns a set of regions (region names) in which the global workflow
    should be enabled. Also validates and synchronizes the regions
    passed via CLI argument and in the regionalOptions field.