scout/adapter/mongo/variant_loader.py
def upsert_variant(self, variant_obj):
        """Load a variant object, if the object already exists update compounds.

        Args:
            variant_obj(dict)

        Returns:
            result
        """
        LOG.debug("Upserting variant %s", variant_obj['_id'])
        try:
            result = self.variant_collection.insert_one(variant_obj)
        except DuplicateKeyError as err:
            LOG.debug("Variant %s already exists in database", variant_obj['_id'])
            result = self.variant_collection.find_one_and_update(
                {'_id': variant_obj['_id']},
                {
                    '$set': {
                        'compounds': variant_obj.get('compounds',[])
                    }
                }
            )
            variant = self.variant_collection.find_one({'_id': variant_obj['_id']})
        return result
def upsert_variant(self, variant_obj):
        LOG.debug("Upserting variant %s", variant_obj['_id'])
        try:
            result = self.variant_collection.insert_one(variant_obj)
        except DuplicateKeyError as err:
            LOG.debug("Variant %s already exists in database", variant_obj['_id'])
            result = self.variant_collection.find_one_and_update(
                {'_id': variant_obj['_id']},
                {
                    '$set': {
                        'compounds': variant_obj.get('compounds',[])
                    }
                }
            )
            variant = self.variant_collection.find_one({'_id': variant_obj['_id']})
        return result
def upsert_variant ( self , variant_obj ) : LOG . debug ( "Upserting variant %s" , variant_obj [ '_id' ] ) try : result = self . variant_collection . insert_one ( variant_obj ) except DuplicateKeyError as err : LOG . debug ( "Variant %s already exists in database" , variant_obj [ '_id' ] ) result = self . variant_collection . find_one_and_update ( { '_id' : variant_obj [ '_id' ] } , { '$set' : { 'compounds' : variant_obj . get ( 'compounds' , [ ] ) } } ) variant = self . variant_collection . find_one ( { '_id' : variant_obj [ '_id' ] } ) return result
Load a variant object, if the object already exists update compounds.

        Args:
            variant_obj(dict)

        Returns:
            result
Load a variant object if the object already exists update compounds .