def _view_model_cmd(options): """ Process command line args and call view_model on the specified file. Parameters ---------- options : argparse Namespace Command line options. """ filename = options.file[0] if filename.endswith('.py'): # the file is a python script, run as a post_setup hook def _viewmod(prob): view_model(prob, outfile=options.outfile, show_browser=not options.no_browser, title=options.title, embeddable=options.embeddable) exit() # could make this command line selectable later options.func = lambda options: _viewmod _post_setup_exec(options) else: # assume the file is a recording, run standalone view_model(filename, outfile=options.outfile, title=options.title, show_browser=not options.no_browser, embeddable=options.embeddable)
def _viewmod(prob): view_model(prob, outfile=options.outfile, show_browser=not options.no_browser, title=options.title, embeddable=options.embeddable) exit() # could make this command line selectable later
def _viewmod(prob): view_model( prob, outfile=options.outfile, show_browser=not options.no_browser, embeddable=options.embeddable, draw_potential_connections=options.draw_potential_connections) exit() # could make this command line selectable later
def test_view_model_from_problem(self): """ Test that an n2 html file is generated from a Problem. """ p = Problem() p.model = SellarStateConnection() p.setup(check=False) view_model(p, outfile=self.problem_filename, show_browser=False) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.problem_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.problem_html_filename), 100)
def test_view_model_from_problem(self): """ Test that an n2 html file is generated from a Problem. """ p = Problem() p.model = SellarStateConnection() p.setup(check=False) view_model(p, outfile=self.problem_filename, show_browser=False) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.problem_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.problem_html_filename), 100)
def test_view_model_set_title(self): """ Test that an n2 html file is generated from a Problem. """ p = Problem() p.model = SellarStateConnection() p.setup(check=False) view_model(p, outfile=self.problem_html_filename, show_browser=DEBUG, title="Sellar State Connection") # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.problem_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertTrue( 'OpenMDAO Model Hierarchy and N2 diagram: Sellar State Connection' \ in open(self.problem_html_filename).read() )
def test_view_model_from_sqlite(self): """ Test that an n2 html file is generated from a sqlite file. """ p = Problem() p.model = SellarStateConnection() r = SqliteRecorder(self.sqlite_db_filename2) p.driver.add_recorder(r) p.setup(check=False) p.final_setup() r.close() view_model(self.sqlite_db_filename2, outfile=self.sqlite_filename, show_browser=False) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.sqlite_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.sqlite_html_filename), 100)
def test_view_model_from_sqlite(self): """ Test that an n2 html file is generated from a sqlite file. """ p = Problem() p.model = SellarStateConnection() r = SqliteRecorder(self.sqlite_db_filename2) p.driver.add_recorder(r) p.setup(check=False) p.final_setup() r.shutdown() view_model(self.sqlite_db_filename2, outfile=self.sqlite_filename, show_browser=False) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.sqlite_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.sqlite_html_filename), 100)
def test_view_model_set_title(self): """ Test that an n2 html file is generated from a Problem. """ p = Problem() p.model = SellarStateConnection() p.setup() view_model(p, outfile=self.problem_html_filename, show_browser=DEBUG, title="Sellar State Connection") # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.problem_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertTrue( 'OpenMDAO Model Hierarchy and N2 diagram: Sellar State Connection' \ in open(self.problem_html_filename).read() )
def test_view_model_from_sqlite(self): """ Test that an n2 html file is generated from a sqlite file. """ p = Problem() p.model = SellarStateConnection() r = SqliteRecorder(self.sqlite_db_filename2) p.driver.add_recorder(r) p.setup(check=False) p.final_setup() r.shutdown() view_model(self.sqlite_db_filename2, outfile=self.sqlite_html_filename, show_browser=DEBUG) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.sqlite_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.sqlite_html_filename), 100) # Check that there are no errors when running from the command line with a recording. check_call('openmdao view_model --no_browser %s' % self.sqlite_db_filename2)
def test_view_model_from_sqlite(self): """ Test that an n2 html file is generated from a sqlite file. """ p = Problem() p.model = SellarStateConnection() r = SqliteRecorder(self.sqlite_db_filename2) p.driver.add_recorder(r) p.setup() p.final_setup() r.shutdown() view_model(self.sqlite_db_filename2, outfile=self.sqlite_html_filename, show_browser=DEBUG) # Check that the html file has been created and has something in it. self.assertTrue(os.path.isfile(self.sqlite_html_filename), (self.problem_html_filename + " is not a valid file.")) self.assertGreater(os.path.getsize(self.sqlite_html_filename), 100) # Check that there are no errors when running from the command line with a recording. check_call('openmdao view_model --no_browser %s' % self.sqlite_db_filename2)
def _viewmod(prob): view_model(prob, outfile=options.outfile, show_browser=not options.no_browser, embeddable=options.embeddable, draw_potential_connections=options.draw_potential_connections) exit() # could make this command line selectable later