Query |reclass| for the top data (states of the minions).
486385
def top(**kwargs):
    '''
    
    '''

    # If reclass is installed, __virtual__ put it onto the search path, so we
    # don't need to protect against ImportError:
    # pylint: disable=3rd-party-module-not-gated
    from reclass.adapters.salt import top as reclass_top
    from reclass.errors import ReclassException
    # pylint: enable=3rd-party-module-not-gated

    try:
        # Salt's top interface is inconsistent with ext_pillar (see #5786) and
        # one is expected to extract the arguments to the master_tops plugin
        # by parsing the configuration file data. I therefore use this adapter
        # to hide this internality.
        reclass_opts = __opts__['master_tops']['reclass']

        # the source path we used above isn't something reclass needs to care
        # about, so filter it:
        filter_out_source_path_option(reclass_opts)

        # if no inventory_base_uri was specified, initialise it to the first
        # file_roots of class 'base' (if that exists):
        set_inventory_base_uri_default(__opts__, kwargs)

        # Salt expects the top data to be filtered by minion_id, so we better
        # let it know which minion it is dealing with. Unfortunately, we must
        # extract these data (see #6930):
        minion_id = kwargs['opts']['id']

        # I purposely do not pass any of __opts__ or __salt__ or __grains__
        # to reclass, as I consider those to be Salt-internal and reclass
        # should not make any assumptions about it. Reclass only needs to know
        # how it's configured, so:
        return reclass_top(minion_id, **reclass_opts)

    except ImportError as e:
        if 'reclass' in six.text_type(e):
            raise SaltInvocationError(
                'master_tops.reclass: cannot find reclass module '
                'in {0}'.format(sys.path)
            )
        else:
            raise

    except TypeError as e:
        if 'unexpected keyword argument' in six.text_type(e):
            arg = six.text_type(e).split()[-1]
            raise SaltInvocationError(
                'master_tops.reclass: unexpected option: {0}'.format(arg)
            )
        else:
            raise

    except KeyError as e:
        if 'reclass' in six.text_type(e):
            raise SaltInvocationError('master_tops.reclass: no configuration '
                                      'found in master config')
        else:
            raise

    except ReclassException as e:
        raise SaltInvocationError('master_tops.reclass: {0}'.format(six.text_type(e)))
496634
def get_fun(fun):
    '''
    
    '''
    query = '''SELECT minion_id, last_fun FROM {keyspace}.minions
               WHERE last_fun = ?;'''.format(keyspace=_get_keyspace())

    ret = {}

    # cassandra_cql.cql_query may raise a CommandExecutionError
    try:
        data = __salt__['cassandra_cql.cql_query'](query, 'get_fun', [fun])
        if data:
            for row in data:
                minion = row.get('minion_id')
                last_fun = row.get('last_fun')
                if minion and last_fun:
                    ret[minion] = last_fun
    except CommandExecutionError:
        log.critical('Could not get the list of minions.')
        raise
    except Exception as e:
        log.critical(
            'Unexpected error while getting list of minions: %s', e)
        raise

    return ret
942785
def get_minions():
    '''
    
    '''
    options = _get_options(ret=None)

    # Make sure the views are valid, which includes the minions..
    if not ensure_views():
        return []

    # Make the request for the view..
    _response = _request("GET",
                         options['url'] +
                                 options['db'] +
                                 "/_design/salt/_view/minions?group=true")

    # Verify that we got a response back.
    if 'rows' not in _response:
        log.error('Unable to get available minions: %s', _response)
        return []

    # Iterate over the rows to build up a list return it.
    _ret = []
    for row in _response['rows']:
        _ret.append(row['key'])
    return _ret
560622
def query(self, model, **kwargs):
        ''''''
        sm = self.model(model)
        query_class = sm.manager.query_class or Query
        return query_class(sm._meta, self, **kwargs)
140173
def _ret_minions(self, filter_):
        '''
        
        '''
        minions = {}
        for minion in filter_(self.raw):
            data = self.get_data(minion)
            if data:
                minions[minion] = data.copy()
        return minions
83259
def get_minions():
    '''
    
    '''
    log.debug('sqlite3 returner <get_minions> called')
    conn = _get_conn(ret=None)
    cur = conn.cursor()
    sql = '''SELECT DISTINCT id FROM salt_returns'''
    cur.execute(sql)
    data = cur.fetchall()
    ret = []
    for minion in data:
        ret.append(minion[0])
    _close_conn(conn)
    return ret
150772
def _get_subclasses_recurse(self, model, levels=None):
        
        related_objects = [
            f for f in model._meta.get_fields()
            if isinstance(f, OneToOneRel)]

        rels = [
            rel for rel in related_objects
            if isinstance(rel.field, OneToOneField)
            and issubclass(rel.field.model, model)
            and model is not rel.field.model
            and rel.parent_link
        ]

        subclasses = []
        if levels:
            levels -= 1
        for rel in rels:
            if levels or levels is None:
                for subclass in self._get_subclasses_recurse(
                        rel.field.model, levels=levels):
                    subclasses.append(
                        rel.get_accessor_name() + LOOKUP_SEP + subclass)
            subclasses.append(rel.get_accessor_name())
        return subclasses
1154146
def __query_spec(self):
        """"""
        spec = self.__spec
        if not self.__is_command and "$query" not in self.__spec:
            spec = SON({"$query": self.__spec})
        if self.__ordering:
            spec["$orderby"] = self.__ordering
        if self.__explain:
            spec["$explain"] = True
        if self.__hint:
            spec["$hint"] = self.__hint
        if self.__comment:
            spec["$comment"] = self.__comment
        if self.__snapshot:
            spec["$snapshot"] = True
        if self.__max_scan:
            spec["$maxScan"] = self.__max_scan
        return spec
1034945
def get_minions():
    '''
    
    '''
    serv = _get_serv(ret=None)
    sql = "select distinct(id) from returns"

    data = serv.query(sql)
    ret = []
    if data:
        for jid in data[0]['points']:
            ret.append(jid[1])

    return ret
1287214
def _superclasses_for_subject(self, graph, typeof):
        """"""
        # TODO - this might be replacing a fairly simple graph API query where
        # it doesn't need to
        classes = []
        superclass = typeof
        while True:
            found = False
            for p, o in self.schema_def.ontology[superclass]:
                if self.schema_def.lexicon['subclass'] == str(p):
                    found = True
                    classes.append(o)
                    superclass = o
            if not found:
                break
        return classes
374489
def toposort_classes(classes):
    """"""
    def get_class_topolist(class_name, name_to_class, processed_classes, current_trace):
        """Return a topologically sorted list of this class's dependencies and class itself

        Args:
            class_name: string, name of the class to process
            name_to_class: dict, class_name -> descriptor
            processed_classes: set of strings, a set of classes that have already been processed
            current_trace: list of strings, list of classes traversed during the recursion

        Returns:
            list of dicts, list of classes sorted in topological order
        """
        # Check if this class has already been handled
        if class_name in processed_classes:
            return []

        if class_name in current_trace:
            raise AssertionError(
                'Encountered self-reference in dependency chain of {}'.format(class_name))

        cls = name_to_class[class_name]
        # Collect the dependency classes
        # These are bases and classes from linked properties
        dependencies = _list_superclasses(cls)
        # Recursively process linked edges
        properties = cls['properties'] if 'properties' in cls else []
        for prop in properties:
            if 'linkedClass' in prop:
                dependencies.append(prop['linkedClass'])

        class_list = []
        # Recursively process superclasses
        current_trace.add(class_name)
        for dependency in dependencies:
            class_list.extend(get_class_topolist(
                dependency, name_to_class, processed_classes, current_trace))
        current_trace.remove(class_name)
        # Do the bookkeeping
        class_list.append(name_to_class[class_name])
        processed_classes.add(class_name)

        return class_list

    # Map names to classes
    class_map = {c['name']: c for c in classes}
    seen_classes = set()

    toposorted = []
    for name in class_map.keys():
        toposorted.extend(get_class_topolist(name, class_map, seen_classes, set()))
    return toposorted
456371
def getClassDirectSubs(self, aURI):
        
        aURI = aURI
        qres = self.rdflib_graph.query("""SELECT DISTINCT ?x
                 WHERE {
                     { ?x rdfs:subClassOf <%s> }
                     FILTER (!isBlank(?x))
                 }
                 """ % (aURI))
        return list(qres)
1173139
def compute_state(self):
        
        data = {}
        data['directory'] = self._dir.path
        data['files'] = list(self._dir.files())
        data['subdirs'] = list(self._dir.subdirs())
        data['index'] = self.index()
        return data
119619
def state(self):
        '''

        '''
        return dict(a=self.a.tolist(), b=self.b.tolist(), c=self.c.tolist(),
                    pivot=self.pivot.tolist(), position=self.position.tolist())
1014776
def tops(opts):
    '''
    
    '''
    if 'master_tops' not in opts:
        return {}
    whitelist = list(opts['master_tops'].keys())
    ret = LazyLoader(
        _module_dirs(opts, 'tops', 'top'),
        opts,
        tag='top',
        whitelist=whitelist,
    )
    return FilterDictWrapper(ret, '.top')
1272878
def _get_state(self):
        

        selected = self.view.get_selected_items()
        if not selected:
            return
        shorthand, state_class = self.view.states[selected[0][0]]
        return state_class()
222021
def index(request):
    """"""
    recent_jobs = JobRecord.objects.order_by("-start_time")[0:100]
    recent_trials = TrialRecord.objects.order_by("-start_time")[0:500]

    total_num = len(recent_trials)
    running_num = sum(t.trial_status == Trial.RUNNING for t in recent_trials)
    success_num = sum(
        t.trial_status == Trial.TERMINATED for t in recent_trials)
    failed_num = sum(t.trial_status == Trial.ERROR for t in recent_trials)

    job_records = []
    for recent_job in recent_jobs:
        job_records.append(get_job_info(recent_job))
    context = {
        "log_dir": AUTOMLBOARD_LOG_DIR,
        "reload_interval": AUTOMLBOARD_RELOAD_INTERVAL,
        "recent_jobs": job_records,
        "job_num": len(job_records),
        "trial_num": total_num,
        "running_num": running_num,
        "success_num": success_num,
        "failed_num": failed_num
    }
    return render(request, "index.html", context)