import requests
import json


def get_cogatlas_concepts(url=None):
    """ Fetches list of concepts from the Cognitive Atlas

    Parameters
    ----------
    url : str
        URL to Cognitive Atlas API

    Returns
    -------
    concepts : set
        Unordered set of terms
    """

    if url is None:
        url = 'https://cognitiveatlas.org/api/v-alpha/concept'

    req = requests.get(url)
    req.raise_for_status()
    concepts = set([f.get('name') for f in json.loads(req.content)])

    return concepts