fastoad.cmd.api module

API

class fastoad.cmd.api.UserFileType(value)[source]

Bases: enum.Enum

An enumeration.

CONFIGURATION = 'configuration'
SOURCE_DATA = 'source_data'
fastoad.cmd.api.get_plugin_information(print_data=False) Dict[str, fastoad.module_management._plugins.DistributionPluginDefinition][source]

Provides information about available FAST-OAD plugins.

Parameters

print_data – if True, plugin data are displayed.

Returns

a dict with installed package names as keys and matching FAST-OAD plugin definitions as values.

fastoad.cmd.api.generate_notebooks(destination_path: str, overwrite: bool = False, distribution_name=None)[source]

Copies notebook folder(s) from available plugin(s).

Parameters
  • destination_path – the inner structure of the folders will depend on the number of installed package and the number of plugins they contain.

  • overwrite – if True and destination_path exists, it will be removed before writing.

  • distribution_name – the name of an installed package that provides notebooks

fastoad.cmd.api.generate_configuration_file(configuration_file_path: str, overwrite: bool = False, distribution_name=None, sample_file_name=None)[source]

Copies a sample configuration file from an available plugin.

Parameters
  • configuration_file_path – the path of file to be written

  • overwrite – if True, the file will be written, even if it already exists

  • distribution_name – the name of the installed package that provides the sample configuration file (can be omitted if only one plugin is available)

  • sample_file_name – the name of the sample configuration file (can be omitted if the plugin provides only one configuration file)

Returns

path of generated file

Raises

FastPathExistsError – if overwrite==False and configuration_file_path already exists

fastoad.cmd.api.generate_source_data_file(source_data_file_path: str, overwrite: bool = False, distribution_name=None, sample_file_name=None)[source]

Copies a sample source data file from an available plugin.

Parameters
  • source_data_file_path – the path of file to be written

  • overwrite – if True, the file will be written, even if it already exists

  • distribution_name – the name of the installed package that provides the sample source data file (can be omitted if only one plugin is available)

  • sample_file_name – the name of the sample source data file (can be omitted if the plugin provides only one source data file)

Returns

path of generated file

Raises

FastPathExistsError – if overwrite==False and source_file_path already exists

fastoad.cmd.api.generate_inputs(configuration_file_path: str, source_data_path: Optional[str] = None, source_data_path_schema='native', overwrite: bool = False) str[source]

Generates input file for the problem specified in configuration_file_path.

Parameters
  • configuration_file_path – where the path of input file to write is set

  • source_data_path – path of source data file data will be taken from

  • source_data_path_schema – set to ‘legacy’ if the source file come from legacy FAST

  • overwrite – if True, file will be written even if one already exists

Returns

path of generated file

Raises

FastPathExistsError – if overwrite==False and configuration_file_path already exists

fastoad.cmd.api.list_variables(configuration_file_path: str, out: Optional[Union[IO, str]] = None, overwrite: bool = False, force_text_output: bool = False, tablefmt: str = 'grid')[source]

Writes list of variables for the problem specified in configuration_file_path.

List is generally written as text. It can be displayed as a scrollable table view if: - function is used in an interactive IPython shell - out == sys.stdout - force_text_output == False

Parameters
  • configuration_file_path

  • out – the output stream or a path for the output file (None means sys.stdout)

  • overwrite – if True and out parameter is a file path, the file will be written even if one already exists

  • force_text_output – if True, list will be written as text, even if command is used in an interactive IPython shell (Jupyter notebook). Has no effect in other shells or if out parameter is not sys.stdout

  • tablefmt – The formatting of the requested table. Options are the same as those available to the tabulate package. See tabulate.tabulate_formats for a complete list. If “var_desc” the file will use the variable_descriptions.txt format.

Returns

path of generated file, or None if no file was generated.

Raises

FastPathExistsError – if overwrite==False and out is a file path and the file exists

fastoad.cmd.api.list_modules(source_path: Optional[Union[List[str], str]] = None, out: Optional[Union[IO, str]] = None, overwrite: bool = False, verbose: bool = False, force_text_output: bool = False)[source]

Writes list of available systems. If source_path is given and if it defines paths where there are registered systems, they will be listed too.

Parameters
  • source_path – either a configuration file path, folder path, or list of folder path

  • out – the output stream or a path for the output file (None means sys.stdout)

  • overwrite – if True and out is a file path, the file will be written even if one already exists

  • verbose – if True, shows detailed information for each system if False, shows only identifier and path of each system

  • force_text_output – if True, list will be written as text, even if command is used in an interactive IPython shell (Jupyter notebook). Has no effect in other shells or if out parameter is not sys.stdout

Returns

path of generated file, or None if no file was generated.

Raises

FastPathExistsError – if overwrite==False and out is a file path and the file exists

fastoad.cmd.api.write_n2(configuration_file_path: str, n2_file_path: Optional[str] = None, overwrite: bool = False)[source]

Write the N2 diagram of the problem in file n2.html

Parameters
  • configuration_file_path

  • n2_file_path – if None, will default to n2.html

  • overwrite

Returns

path of generated file.

Raises

FastPathExistsError – if overwrite==False and n2_file_path already exists

fastoad.cmd.api.write_xdsm(configuration_file_path: str, xdsm_file_path: Optional[str] = None, overwrite: bool = False, depth: int = 2, wop_server_url: Optional[str] = None, dry_run: bool = False)[source]
Parameters
  • configuration_file_path

  • xdsm_file_path – the path for HTML file to be written (will overwrite if needed)

  • overwrite – if False, will raise an error if file already exists.

  • depth – the depth analysis for WhatsOpt

  • wop_server_url – URL of WhatsOpt server (if None, ether.onera.fr/whatsopt will be used)

  • dry_run – if True, will run wop without sending any request to the server. Generated XDSM will be empty. (for test purpose only)

Returns

path of generated file.

Raises

FastPathExistsError – if overwrite==False and xdsm_file_path already exists

fastoad.cmd.api.evaluate_problem(configuration_file_path: str, overwrite: bool = False) fastoad.openmdao.problem.FASTOADProblem[source]

Runs model according to provided problem file

Parameters
  • configuration_file_path – problem definition

  • overwrite – if True, output file will be overwritten

Returns

the OpenMDAO problem after run

Raises

FastPathExistsError – if overwrite==False and output data file of problem already exists

fastoad.cmd.api.optimize_problem(configuration_file_path: str, overwrite: bool = False, auto_scaling: bool = False) fastoad.openmdao.problem.FASTOADProblem[source]

Runs driver according to provided problem file

Parameters
  • configuration_file_path – problem definition

  • overwrite – if True, output file will be overwritten

  • auto_scaling – if True, automatic scaling is performed for design variables and constraints

Returns

the OpenMDAO problem after run

Raises

FastPathExistsError – if overwrite==False and output data file of problem already exists

fastoad.cmd.api.optimization_viewer(configuration_file_path: str)[source]

Displays optimization information and enables its editing

Parameters

configuration_file_path – problem definition

Returns

display of the OptimizationViewer

fastoad.cmd.api.variable_viewer(file_path: str, file_formatter: Optional[fastoad.io.formatter.IVariableIOFormatter] = None, editable=True)[source]

Displays a widget that enables to visualize variables information and edit their values.

Parameters
  • file_path – the path of file to interact with

  • file_formatter – the formatter that defines file format. If not provided, default format will be assumed.

  • editable – if True, an editable table with variable filters will be displayed. If False, the table will not be editable nor searchable, but can be stored in an HTML file.

Returns

display handle of the VariableViewer