def _get_simple_system_list(): cell_list = [[" AVAILABLE MODULE IDENTIFIERS", "MODULE PATH"]] for identifier in sorted(RegisterOpenMDAOSystem.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) cell_list.append([identifier, path]) cell_list.append([" AVAILABLE PROPULSION WRAPPER IDENTIFIERS", "MODULE PATH"]) for identifier in sorted(RegisterPropulsion.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) cell_list.append([identifier, path]) return cell_list
def _get_detailed_system_list(): cell_list = [[ "AVAILABLE MODULE IDENTIFIERS\n============================" ]] for identifier in sorted(RegisterOpenMDAOSystem.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) domain = RegisterOpenMDAOSystem.get_provider_domain(identifier) description = RegisterOpenMDAOSystem.get_provider_description( identifier) if description is None: description = "" # We remove OpenMDAO's native options from the description component = RegisterOpenMDAOSystem.get_system(identifier) component.options.undeclare("assembled_jac_type") component.options.undeclare("distributed") cell_content = ( " IDENTIFIER: %s\nPATH: %s\nDOMAIN: %s\nDESCRIPTION: %s\n" % (identifier, path, domain.value, tw.indent(tw.dedent(description), " "))) if len(list(component.options.items())) > 0: cell_content += component.options.to_table(fmt="grid") + "\n" cell_list.append([cell_content]) cell_list.append([ "AVAILABLE PROPULSION WRAPPER IDENTIFIERS\n========================================" ]) for identifier in sorted(RegisterPropulsion.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) description = RegisterPropulsion.get_provider_description(identifier) if description is None: description = "" cell_content = " IDENTIFIER: %s\nPATH: %s\nDESCRIPTION: %s\n" % ( identifier, path, tw.indent(tw.dedent(description), " "), ) cell_list.append([cell_content]) return cell_list
def list_systems(configuration_file_path: str = None, out: Union[IO, str] = sys.stdout, overwrite: bool = False): """ Writes list of available systems. If configuration_file_path is given and if it defines paths where there are registered systems, they will be listed too. :param configuration_file_path: :param out: the output stream or a path for the output file :param overwrite: if True and out is a file path, the file will be written even if one already exists :raise FastFileExistsError: if overwrite==False and out is a file path and the file exists """ if configuration_file_path: conf = FASTOADProblemConfigurator(configuration_file_path) conf.load(configuration_file_path) # As the problem has been configured, BundleLoader now knows additional registered systems if isinstance(out, str): if not overwrite and pth.exists(out): raise FastFileExistsError( "File %s not written because it already exists. " "Use overwrite=True to bypass." % out, out, ) make_parent_dir(out) out_file = open(out, "w") else: out_file = out out_file.writelines([ "== AVAILABLE SYSTEM IDENTIFIERS " + "=" * 68 + "\n", "-" * 100 + "\n" ]) for identifier in sorted(RegisterOpenMDAOSystem.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) domain = RegisterOpenMDAOSystem.get_provider_domain(identifier) description = RegisterOpenMDAOSystem.get_provider_description( identifier) if description is None: description = "" out_file.write(" IDENTIFIER: %s\n" % identifier) out_file.write(" PATH: %s\n" % path) out_file.write(" DOMAIN: %s\n" % domain.value) out_file.write(" DESCRIPTION: %s\n" % tw.indent(tw.dedent(description), " ")) out_file.write("-" * 100 + "\n") out_file.write("=" * 100 + "\n") out_file.writelines([ "\n== AVAILABLE PROPULSION WRAPPER IDENTIFIERS " + "=" * 56 + "\n", "-" * 100 + "\n" ]) for identifier in sorted(RegisterPropulsion.get_provider_ids()): path = BundleLoader().get_factory_path(identifier) description = RegisterPropulsion.get_provider_description(identifier) if description is None: description = "" out_file.write(" IDENTIFIER: %s\n" % identifier) out_file.write(" PATH: %s\n" % path) out_file.write(" DESCRIPTION: %s\n" % tw.indent(tw.dedent(description), " ")) out_file.write("-" * 100 + "\n") out_file.write("=" * 100 + "\n") if isinstance(out, str): out_file.close() _LOGGER.info("System list written in %s", out_file)