Ejemplo n.º 1
0
    def matches(self, obj):
        """
        Returns the string names of the matches pair for a given objects,
        returned as a list of (test,model) pairs.
        """

        obj = str(obj)
        typ = database.get_leader(obj).lower()

        cursor = self.conn.cursor()
        if typ == 'te':
            o = cursor.execute("SELECT test,model FROM matches WHERE test==?", (obj,))
        if typ == 'mo':
            o = cursor.execute("SELECT test,model FROM matches WHERE model==?", (obj,))
        if typ == 'td':
            o = cursor.execute(
                    """
                    SELECT matches.test, matches.model FROM matches
                        INNER JOIN obj ON matches.test==obj.id
                        WHERE obj.driver==?
                    """,
                    (obj,)
                )
        if typ == 'md':
            o = cursor.execute(
                    """
                    SELECT matches.test, matches.model FROM matches
                        INNER JOIN obj ON matches.model==obj.id
                        WHERE obj.driver==?
                    """,
                    (obj,)
                )

        return [i for i in o.fetchall()]
Ejemplo n.º 2
0
    def _insert_match(self, obj0, obj1, check=False):
        """ Insert the match data for a single kim object into `matches` """
        cursor = self.conn.cursor()
        te,mo = [str(i) for i in [obj0, obj1]]

        # make sure it is in runner, subject order
        if database.get_leader(te).lower() != 'te':
            te,mo = mo,te

        # if we have this item already, return its index
        o = cursor.execute("SELECT * FROM matches WHERE test==? AND model==?", (te, mo)).fetchone()
        if o is not None:
            return o[0]

        # if it actually isn't a match, don't put it in!
        if check and not kimapi.valid_match(kimobjects.kim_obj(te), kimobjects.kim_obj(mo)):
            return None

        # insert if not present
        cursor.execute(
            "INSERT INTO matches VALUES (NULL, ?, ?)",
            (str(te), str(mo))
        )
        matchid = cursor.lastrowid
        self.conn.commit()
        return matchid
Ejemplo n.º 3
0
    def new(self, itemid, status='approved', priority='normal', force=False):
        """ New KIM object submitted to web-app """
        priority = network.transform_priority(priority)
        leader = database.get_leader(itemid).lower()
        approved = (status == 'approved')

        self.rsync_kimid(itemid, approved=approved)

        # insert this object into the database
        if database.isuuid(itemid):
            mongodb.insert_one_result(leader, itemid)
        else:
            mongodb.insert_one_object(itemid)

        # pass the message along to the director
        msg = network.director_update_message(
            itemid=itemid, status=status, priority=priority, force=force
        )
        self.send_job('pipeline.tasks.director_run', kwargs=msg)
Ejemplo n.º 4
0
    def process_kimcode_pending(self, kimid, priority=None):
        self.sync_pending(kimid)

        leader = database.get_leader(kimid)

        if leader == "TE":
            # run against all test verifications
            runners = list(kimobjects.TestVerification.all())
            subjects = [kimobjects.Test(kimid, search=False)]*len(runners)

        elif leader == "MO":
            # run against all model verifications
            runners = list(kimobjects.ModelVerification.all())
            subjects = [kimobjects.Model(kimid, search=False)]*len(runners)

        elif leader not in ["TD", "MD"]:
            self.logger.error("Tried to update an invalid KIM ID!: %r",kimid)

        for r, s in zip(runners, subjects):
            self.submit(r, s, priority, status='pending')
Ejemplo n.º 5
0
 def _typ(self, obj):
     return database.get_leader(obj)