Ejemplo n.º 1
0
    def reindex_data(self, user, typed_columns=None, column_types=None):
        """
        Reindex the data currently stored for this ``Dataset``.
        """
        self.lock()

        try:
            if typed_columns:
                for i, t in enumerate(typed_columns):
                    self.column_schema[i]["indexed"] = t

            if column_types:
                for i, t in enumerate(column_types):
                    self.column_schema[i]["type"] = t

            self.column_schema = update_indexed_names(self.column_schema)

            self.current_task = TaskStatus.objects.create(task_name="panda.tasks.reindex", creator=user)

            self.save()

            ReindexTask.apply_async(args=[self.slug], kwargs={}, task_id=self.current_task.id)
        except:
            self.unlock()
            raise
Ejemplo n.º 2
0
    def test_generate_typed_column_names_some(self):
        self.dataset.import_data(self.user, self.upload)

        typed_columns = [True, False, True, True]

        for i, c in enumerate(self.dataset.column_schema):
            self.dataset.column_schema[i]['indexed'] = typed_columns.pop(0)

        self.dataset.column_schema = update_indexed_names(self.dataset.column_schema)

        self.assertEqual([c['indexed_name'] for c in self.dataset.column_schema], ['column_int_id', None, 'column_unicode_last_name', 'column_unicode_employer'])
Ejemplo n.º 3
0
    def test_generate_typed_column_names_conflict(self):
        self.dataset.import_data(self.user, self.upload)

        utils.wait()

        typed_columns = [True, False, True, True]

        for i, c in enumerate(self.dataset.column_schema):
            self.dataset.column_schema[i]['name'] = 'test'
            self.dataset.column_schema[i]['indexed'] = typed_columns.pop(0)

        self.dataset.column_schema = update_indexed_names(self.dataset.column_schema)

        self.assertEqual([c['indexed_name'] for c in self.dataset.column_schema], ['column_int_test', None, 'column_unicode_test', 'column_unicode_test2'])
Ejemplo n.º 4
0
    def test_generate_typed_column_names_some(self):
        self.dataset.import_data(self.user, self.upload)

        typed_columns = [True, False, True, True]

        for i, c in enumerate(self.dataset.column_schema):
            self.dataset.column_schema[i]['indexed'] = typed_columns.pop(0)

        self.dataset.column_schema = update_indexed_names(
            self.dataset.column_schema)

        self.assertEqual(
            [c['indexed_name'] for c in self.dataset.column_schema], [
                'column_int_id', None, 'column_unicode_last_name',
                'column_unicode_employer'
            ])
Ejemplo n.º 5
0
    def reindex_data(self, user, typed_columns=None, column_types=None):
        """
        Reindex the data currently stored for this ``Dataset``.
        """
        self.lock()
        
        task_type = ReindexTask

        try:
            typed_column_count = 0

            if typed_columns:
                for i, t in enumerate(typed_columns):
                    self.column_schema[i]['indexed'] = t
                    
                    if t:
                        typed_column_count += 1

            if column_types:
                for i, t in enumerate(column_types):
                    self.column_schema[i]['type'] = t

            self.column_schema = update_indexed_names(self.column_schema)

            self.current_task = TaskStatus.objects.create(
                task_name=task_type.name,
                task_description=_('Reindex %(slug)s with %(typed_column_count)i column filters.') \
                     % {'slug': self.slug, 'typed_column_count': typed_column_count}, 
                creator=user
            )

            self.save()

            task_type.apply_async(
                args=[self.slug],
                kwargs={},
                task_id=self.current_task.id
            )
        except:
            self.unlock()
            raise
Ejemplo n.º 6
0
    def reindex_data(self, user, typed_columns=None, column_types=None):
        """
        Reindex the data currently stored for this ``Dataset``.
        """
        self.lock()

        task_type = ReindexTask

        try:
            typed_column_count = 0

            if typed_columns:
                for i, t in enumerate(typed_columns):
                    self.column_schema[i]['indexed'] = t

                    if t:
                        typed_column_count += 1

            if column_types:
                for i, t in enumerate(column_types):
                    self.column_schema[i]['type'] = t

            self.column_schema = update_indexed_names(self.column_schema)

            self.current_task = TaskStatus.objects.create(
                task_name=task_type.name,
                task_description=_('Reindex %(slug)s with %(typed_column_count)i column filters.') \
                     % {'slug': self.slug, 'typed_column_count': typed_column_count},
                creator=user
            )

            self.save()

            task_type.apply_async(args=[self.slug],
                                  kwargs={},
                                  task_id=self.current_task.id)
        except:
            self.unlock()
            raise