def build_bundle(self, s, l, term): bundle = s.resolve_bundle(term) bundle.library = l bundle.clean() bundle.pre_prepare() bundle.prepare() bundle.post_prepare() bundle.pre_build() bundle.build() bundle.post_build() bundle.install()
def test_versions(self): import testbundle.bundle from databundles.run import get_runconfig idnt = self.bundle.identity #Test.rm_rf(self.bundle.filesystem.build_path()) l = self.get_library() print "Database: ", l.database.dsn vnames = {} name = None for i in [1,2,3]: idnt.revision = i bundle = Bundle() bundle.config.rewrite(identity=idnt.to_dict()) get_runconfig.clear() print 'Building version {}'.format(i) bundle = Bundle() bundle.clean() bundle.prepare() bundle.build() bundle.update_configuration() print "Installing ", bundle.identity.vname l = self.get_library() r = l.put(bundle) name = bundle.identity.name # Same every time. vnames[i] = bundle.identity.vname r = l.get(name) for i,vname in vnames.items(): r = l.get(vname) print i, vname, r, r.identity.vname idnt.revision = 1 self.bundle.config.rewrite(identity=idnt.to_dict())
def test_versions(self): import testbundle.bundle from ambry.run import get_runconfig from ambry.library.query import Resolver import shutil idnt = self.bundle.identity l = self.get_library() l.purge() orig = os.path.join(self.bundle.bundle_dir,'bundle.yaml') save = os.path.join(self.bundle.bundle_dir,'bundle.yaml.save') shutil.copyfile(orig,save) datasets = {} try: for i in [1,2,3]: idnt._on.revision = i idnt.name.version_major = i idnt.name.version_minor = i*10 bundle = Bundle() bundle.config.rewrite(identity=idnt.ident_dict, names=idnt.names_dict) get_runconfig.clear() #clear runconfig cache print 'Building version {}'.format(i) bundle = Bundle() bundle.clean() bundle.pre_prepare() bundle.prepare() bundle.post_prepare() bundle.pre_build() bundle.build_small() #bundle.build() bundle.post_build() bundle = Bundle() print "Installing ", bundle.identity.vname l.put(bundle) finally: pass os.rename(save, orig) # # Save the list of datasets for version analysis in other # tests # db = l.database for d in db.list().values(): datasets[d.vid] = d.dict datasets[d.vid]['partitions'] = {} for p_vid, p in d.partitions.items(): datasets[d.vid]['partitions'][p_vid] = p.dict with open(self.bundle.filesystem.path('meta','version_datasets.json'),'w') as f: import json f.write(json.dumps(datasets)) r = Resolver(db.session) ref = idnt.id_ ref = "source-dataset-subset-variation-=2.20" ip, results = r.resolve_ref_all(ref) for row in results: print row