Ejemplo n.º 1
0
    def statement_similarity(self, notebook, snippet, source_platform):
        response = self._get_current_statement(notebook, snippet)
        query = response['statement']

        client = OptimizerClient(self.user)

        return client.similar_queries(source_platform, query)
Ejemplo n.º 2
0
  def statement_risk(self, notebook, snippet):
    response = self._get_current_statement(notebook, snippet)
    query = response['statement']

    client = OptimizerClient(self.user)

    return client.query_risk(query=query, source_platform=snippet['type'], db_name=snippet.get('database') or 'default')
Ejemplo n.º 3
0
  def statement_compatibility(self, notebook, snippet, source_platform, target_platform):
    response = self._get_current_statement(notebook, snippet)
    query = response['statement']

    client = OptimizerClient(self.user)

    return client.query_compatibility(source_platform, target_platform, query)
Ejemplo n.º 4
0
def get_api(request, interface):

    if interface == 'optimizer':
        from metadata.optimizer.optimizer_client import OptimizerClient
        return OptimizerClient(request.user)
    elif interface == 'dummy':
        from metadata.optimizer.dummy_client import DummyClient
        return DummyClient(user=request.user)
    else:
        raise PopupException(
            _('Optimizer connector interface not recognized: %s') % interface)
Ejemplo n.º 5
0
    def setup_class(cls):
        if not has_optimizer():
            raise SkipTest

        cls.client = make_logged_in_client(username='******', is_superuser=False)
        cls.user = User.objects.get(username='******')
        cls.user = rewrite_user(cls.user)
        add_to_group('test')
        grant_access("test", "test", "metadata")
        grant_access("test", "test", "optimizer")

        cls.api = OptimizerClient(user=cls.user)

        if not BaseTestOptimizerClient.UPLOADED:
            cls.upload()
            BaseTestOptimizerClient.UPLOADED = True