Пример #1
0
def create_task_with_existing_basemap(basemap_id, heatmap_task_parameters):
    """heatmap_task_parameters:
        'heatmap_starting_year': (int, "starting_year"),
        'heatmap_ending_year': (int, "ending_year"),
        'heatmap_sample_size': (int, "sample_size"),
        'heatmap_author': (str, 'author'),
        'heatmap_conference': (str, 'conference'),
        'heatmap_journal': (str, 'journal'),
        'heatmap_term_type': (int, 'term_type'),
    """
    basemap = Basemap.objects.get(id=basemap_id)
    heatmap_params = filter_heatmap_args(heatmap_task_parameters)
    heatmap_params['term_type'] = basemap.term_type

    heatmap = Heatmap(finished=False, **heatmap_params)
    heatmap.save()
    task = Task(basemap=basemap, heatmap=heatmap)
    task.save()
    return task
Пример #2
0
def create_task_and_maps(task_parameters, include_heatmap=True):
    '''
    task_parameters:
        'basemap_ending_year': (int, "ending_year"),
        'basemap_sample_size': (int, "sample_size"),
        'basemap_starting_year': (int, "starting_year"),
        'number_of_terms': int,
        'ranking_algorithm': int,
        'similarity_algorithm': int,
        'filtering_algorithm': int,
        'basemap_author': (str, 'author'),
        'basemap_conference': (str, 'conference'),
        'basemap_journal': (str, 'journal'),
        'term_type': int,

    if include_heatmap then also pass the following:
        'heatmap_starting_year': (int, "starting_year"),
        'heatmap_ending_year': (int, "ending_year"),
        'heatmap_sample_size': (int, "sample_size"),
        'heatmap_author': (str, 'author'),
        'heatmap_conference': (str, 'conference'),
        'heatmap_journal': (str, 'journal'),
        'term_type': int,
)
    '''
    # set up new objects
    basemap = Basemap(finished=False, **filter_basemap_args(task_parameters))
    basemap.save()
    if include_heatmap:
        heatmap = Heatmap(finished=False, **filter_heatmap_args(task_parameters))
        heatmap.save()
        task = Task(basemap=basemap, heatmap=heatmap)
    else:
        task = Task(basemap=basemap)
    task.save()
    return task