def invoke(self): srcDB = db.databaseFactory(dbName=self.args.srcDB, permission=db.Permissions.READ_ONLY_FME) tarDB = db.databaseFactory(dbName=self.args.tarDB, permission=db.Permissions.CREATE_FILE_TIE) cs = settings.Settings(fName=self.args.csPath) with directoryChangers.DirectoryChanger(cs.inputDirectory): o = armi.init(cs=cs) db.copyDatabase(o.r, srcDB, tarDB)
def test_growToFullCoreFromFactoryWithCS(self): from armi.bookkeeping.db import databaseFactory db = databaseFactory(self.dbName, "r") with db: r = db.load(0, 0, allowMissing=True) r.core.growToFullCore(self.cs) self.assertEqual(r.core.numRings, 9) self.assertEqual(r.p.cycle, 0) self.assertEqual(len(r.core.assembliesByName), 217) self.assertEqual(len(r.core.circularRingList), 0) self.assertEqual(len(r.core.blocksByName), 1085)
def invoke(self): # late imports so that we dont have to import the world to do anything # pylint: disable=import-outside-toplevel from armi.bookkeeping.visualization import vtk from armi.bookkeeping.visualization import xdmf from armi.bookkeeping.db import databaseFactory # a little baroque, but easy to extend with future formats formatMap = { self._FORMAT_VTK: vtk.VtkDumper, self._FORMAT_XDMF: xdmf.XdmfDumper, } dumper = formatMap[self.args.format](self.args.output_name, self.args.h5db) nodes = self.args.nodes db = databaseFactory(self.args.h5db, "r") with db: dbNodes = list(db.genTimeSteps()) if nodes is not None and any(node not in dbNodes for node in nodes): raise RuntimeError( "Some of the requested nodes are not in the source database.\n" "Requested: {}\n" "Present: {}".format(nodes, dbNodes)) with dumper: for cycle, node in dbNodes: if nodes is not None and (cycle, node) not in nodes: continue if (self.args.min_node is not None and (cycle, node) < self.args.min_node): continue if (self.args.max_node is not None and (cycle, node) > self.args.max_node): continue runLog.info( "Creating visualization file for cycle {}, time node {}..." .format(cycle, node)) r = db.load(cycle, node) dumper.dumpState(r)
def invoke(self): nodes = self.args.nodes if self.args.h5db is None: # Just do begining stuff, no database is given... if self.cs is not None: site = createReportFromSettings(cs) if self.args.view: webbrowser.open(site) else: raise RuntimeError( "No Settings with Blueprint or Database, cannot gerenate a report" ) else: report = reports.ReportContent("Overview") pm = getPluginManagerOrFail() db = databaseFactory(self.args.h5db, "r") if self.args.bp is not None: blueprint = self.args.bp with db: with directoryChangers.ForcedCreationDirectoryChanger( "reportsOutputFiles"): dbNodes = list(db.genTimeSteps()) cs = db.loadCS() if self.args.bp is None: blueprint = db.loadBlueprints() r = reactors.factory(cs, blueprint) report.title = r.name pluginContent = getPluginManagerOrFail( ).hook.getReportContents( r=r, cs=cs, report=report, stage=reports.ReportStage.Begin, blueprint=blueprint, ) stage = reports.ReportStage.Standard for cycle, node in dbNodes: if nodes is not None and (cycle, node) not in nodes: continue if (self.args.min_node is not None and (cycle, node) < self.args.min_node): continue if (self.args.max_node is not None and (cycle, node) > self.args.max_node): continue r = db.load(cycle, node) cs = db.loadCS() pluginContent = pm.hook.getReportContents( r=r, cs=cs, report=report, stage=stage, blueprint=blueprint) stage = reports.ReportStage.End pluginContent = pm.hook.getReportContents( r=r, cs=cs, report=report, stage=stage, blueprint=blueprint) site = report.writeReports() if self.args.view: webbrowser.open(site)