Example #1
0
 def __init__(self, dset_name=None, basename=None, *args, **kwargs):
     super(GridFSGraph, self).__init__(encoding='UTF-8', *args, **kwargs)
     self._check_args(dset_name=dset_name, basename=basename)
     self.dset_name = dset_name
     self.basename = basename
     self.filename = self._make_filename()
     self.fs = gridfs.GridFS(db.get_pymongo_db(), collection=self.FS_COLL)
Example #2
0
 def remove_old_files(self):
     fs = gridfs.GridFS(db.get_pymongo_db(), collection='tmp')
     encode_name = urllib.quote(self.name)
     filenames = [f for f in fs.list() if encode_name in f]
     for filename in filenames:
         last_version = fs.get_last_version(filename)
         file_id = last_version._id
         fs.delete(file_id)
Example #3
0
 def setUp(self):
     self.data = {
         'constraints': ['c1', 'c2', 'c3', 'c4'],
         'candidates': ot.data.voweldset,
         'name': 'voweldset',
         'apriori_ranking': [['c1', 'c2']]
     }
     self.d = models.Dataset(data=self.data, data_is_from_form=False)
     self.d.classical = False
     self.entailments_fname = "".join([self.d.name, "/", 'entailments.png'])
     self.grammar_format_str = self.d.name + "/grammar%d.png"
     self.fs = gridfs.GridFS(db.get_pymongo_db(), collection='tmp')
Example #4
0
    def build_poot(self):
        """Builds the PoOT object and attaches it to self.poot.

        Relies on self._ot_candidates for the ot-compatible candidates

        """
        mongo_db = db.get_pymongo_db()
        poot = OTStats(lat_dir=None, mongo_db=mongo_db,
                       apriori=self.apriori_ranking.raw_grammar)
        if self._ot_candidates is not None:
            poot.dset = self._ot_candidates
        return poot
Example #5
0
def erase_temp_files():
    fs = gridfs.GridFS(db.get_pymongo_db(), collection='tmp')
    filenames = [f for f in fs.list() if 'temp' in f]
    for filename in filenames:
        fs.delete(fs.get_last_version(filename)._id)
Example #6
0
 def fs(self):
     return gridfs.GridFS(db.get_pymongo_db(), collection='tmp')
Example #7
0
 def tearDown(self):
     pymongodb = db.get_pymongo_db()
     pymongodb.tmp.files.drop()
     pymongodb.tmp.chunks.drop()
     delete_bad_datasets()