def gen_conf(conf_file, from_package, source, force): """ Generate a sample configuration file with given argument as name. Option "--from_package" has to be used if several FAST-OAD plugins are available. Option "--source_name" has to be used if the targeted plugin provides several sample configuration files. Use "fastoad plugin_info" to get information about available plugins and sample configuration files. """ try: manage_overwrite( api.generate_configuration_file, configuration_file_path=conf_file, overwrite=force, distribution_name=from_package, sample_file_name=source, ) except ( FastNoDistPluginError, FastSeveralDistPluginsError, FastUnknownDistPluginError, FastSeveralConfigurationFilesError, FastUnknownConfigurationFileError, FastNoAvailableConfigurationFileError, ) as exc: click.echo(exc.args[0])
def gen_inputs(conf_file, source_file, force, legacy): """ Generate the input file (specified in the configuration file) with needed variables. \b Examples: --------- # For the problem defined in conf_file.yml, generates the input file with default # values (when default values are defined): fastoad gen_inputs conf_file.yml \b # Same as above, except that values are taken from some_file.xml when possible: fastoad gen_inputs conf_file.yml some_file.xml \b # Same as above, some_file.xml is formatted with the legacy FAST schema fastoad gen_inputs conf_file.yml some_file.xml --legacy """ schema = "legacy" if legacy else "native" manage_overwrite( api.generate_inputs, configuration_file_path=conf_file, source_path=source_file, source_path_schema=schema, overwrite=force, )
def gen_conf(conf_file, force): """Generate a sample configuration file with given argument as name.""" manage_overwrite( api.generate_configuration_file, configuration_file_path=conf_file, overwrite=force, )
def optimize(conf_file, force): """Run the optimization for problem defined in CONF_FILE.""" manage_overwrite( api.optimize_problem, filename_func=lambda pb: pb.output_file_path, configuration_file_path=conf_file, overwrite=force, )
def evaluate(conf_file, force): """Run the analysis for problem defined in CONF_FILE.""" manage_overwrite( api.evaluate_problem, filename_func=lambda pb: pb.output_file_path, configuration_file_path=conf_file, overwrite=force, )
def list_variables(conf_file, out_file, force, table_format): """List the variables of the problem defined in CONF_FILE.""" manage_overwrite( api.list_variables, configuration_file_path=conf_file, out=out_file, overwrite=force, tablefmt=table_format, )
def write_n2(conf_file, n2_file, force): """ Write an HTML file that shows the N2 diagram of the problem defined in CONF_FILE. The name of generated file is `n2.html`, or the given name for argument N2_FILE. """ manage_overwrite( api.write_n2, configuration_file_path=conf_file, n2_file_path=n2_file, overwrite=force, )
def write_xdsm(conf_file, xdsm_file, depth, server, force): """ Write an HTML file that shows the XDSM diagram of the problem defined in CONF_FILE. The name of generated file is `xdsm.html`, or the given name for argument XDSM_FILE. """ manage_overwrite( api.write_xdsm, configuration_file_path=conf_file, xdsm_file_path=xdsm_file, overwrite=force, depth=depth, wop_server_url=server, )
def create_notebooks(path, from_package): """ Creates a FAST-OAD_notebooks/ folder with pre-configured Jupyter notebooks. If PATH is given, FAST-OAD_notebooks/ will be created in that folder. IMPORTANT: Please note that all content of an existing FAST-OAD_notebooks/ will be overwritten. """ root_target_path = pth.abspath(pth.join(path, NOTEBOOK_FOLDER_NAME)) try: if manage_overwrite( api.generate_notebooks, destination_path=root_target_path, overwrite=False, distribution_name=from_package, ): # Give info for running Jupyter click.echo("You may now run Jupyter with:") click.echo(f' jupyter lab "{root_target_path}"') except ( FastNoDistPluginError, FastUnknownDistPluginError, FastNoAvailableNotebookError, ) as exc: click.echo(exc.args[0])
def list_modules(out_file, force, verbose, source_path): """ Provide the identifiers of available systems. SOURCE_PATH argument can be a configuration file, or a list of folders where custom modules are declared. """ # If a configuration file or a single path is provided make sure it is sent as a # string not a list if len(source_path) == 1: source_path = source_path[0] if manage_overwrite( api.list_modules, source_path=source_path, out=out_file, overwrite=force, verbose=verbose, ): print("\nDone. Use --verbose (-v) option for detailed information.")