<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def configure_ckan(m):
 """Load groups and organizations, from a file in Metatab format"""

    from ckanapi import RemoteCKAN

    try:
        doc = MetapackDoc(m.mt_file, cache=m.cache)
    except (IOError, MetatabError) as e:
        err("Failed to open metatab '{}': {}".format(m.mt_file, e))

    c = RemoteCKAN(m.ckan_url, apikey=m.api_key)

    groups = { g['name']:g for g in c.action.group_list(all_fields=True) }

    for g in doc['Groups']:

        if g.value not in groups:
            prt('Creating group: ', g.value)
            c.action.group_create(name=g.value,
                                  title=g.get_value('title'),
                                  description=g.get_value('description'),
                                  id=g.get_value('id'),
                                  image_url=g.get_value('image_url'))

    orgs = {o['name']: o for o in c.action.organization_list(all_fields=True)}

    for o in doc['Organizations']:

        if o.value not in orgs:
            prt('Creating organization: ', o.value)
            c.action.organization_create(name=o.value,
                                  title=o.get_value('title'),
                                  description=o.get_value('description'),
                                  id=o.get_value('id'),
                                  image_url=o.get_value('image_url'))