pyfmu.builder

Package Contents

pyfmu.builder.zipdir(inDir: str, outDir: str)
pyfmu.builder.rm(path)

Delete a file or a directory

Arguments:

p {Path} – path to a directory or a file

pyfmu.builder.compress(in_dir, out_dir=None, fmt='zip', extension: str = None)

Compresses

Arguments:

in_dir {[type]} – the directory to compress

Keyword Arguments:

out_dir {[type]} – output archive (default: {None})

class pyfmu.builder.cd(newPath)

Context manager for changing the current working directory

__enter__(self)
__exit__(self, etype, value, traceback)
pyfmu.builder.has_java()

Checks if java is available in the system’s path.

Returns:

[bool] – true if java is available, otherwise false.

pyfmu.builder.has_fmpy() → bool

Checks if FMPy is available

Returns:

bool – true if FMPy is available, otherwise false.

pyfmu.builder.inPath
class pyfmu.builder.Resources

Singleton object representing static resources.

For example to get path to pyfmu directory: ` pyfmu_dir = Resources.get().pyfmu_dir `

Do not move the file as the resources must are located relative to this file

static get()
pyfmu.builder._create_config(config_path: str, class_name: str, relative_script_path: str)
pyfmu.builder.read_configuration(config_path: str) → object
class pyfmu.builder.PyfmuProject(root: Path, main_class: str = None, main_script: str = None, main_script_path: Path = None, project_configuration: dict = None, project_configuration_path: Path = None, resources_dir: Path = None)

Object representing an pyfmu project.

static from_existing(p: Path)

Instantiates an object representation based on an existing project

Arguments:

p {Path} – path to the root of the project

pyfmu.builder._create_dirs(project_path: str, exist_ok: bool = True)
pyfmu.builder._generate_fmu_template(template_path: str, main_class_name: str, script_output_path: str) → None
pyfmu.builder._write_templateScript_to_project(project: PyfmuProject)
pyfmu.builder._write_projectConfig_to_project(project: PyfmuProject)
pyfmu.builder.create_project(project_path: str, main_class_name: str, overwrite=True) → PyfmuProject

Creates a new PyFMU project at the specified path.

project_pathstr

output path of the project

main_class_namestr

name of the slave script

overwritebool, optional

if true overwrite any existing files at the specified output path, by default True

PyfmuProject

An object representing the exported project. This may be used to access the paths of the various project artifacts.

class pyfmu.builder.Fmi2Causality

Bases: enum.Enum

Defines the causality of the variable, that is whether it is an input, output, parameter, etc.

Values:
  • parameter: a value set by the environment which remains constant during the simulation.

  • calculatedParameter: ?

  • input: An input from another model.

  • output: An output to other models.

  • local: ?

  • independent: Independent variable, typically time. At most one variable of an FMU may be declared as independent.

parameter = parameter
calculatedParameter = calculatedParameter
input = input
output = output
local = local
independent = independent
pyfmu.builder.extract_model_description_v2(fmu_instance) → str
class pyfmu.builder.Resources

Singleton object representing static resources.

For example to get path to pyfmu directory: ` pyfmu_dir = Resources.get().pyfmu_dir `

Do not move the file as the resources must are located relative to this file

static get()
class pyfmu.builder.FMI_Versions

Bases: enum.Enum

FMI2 = fmi2
FMI3 = fmi3
class pyfmu.builder.ValidationResult

Represents the result of validating an FMU with different validation techniques.

set_result_for(self, tool: str, valid: bool, message='')
get_result_for(self, tool: str)
property valid(self)
pyfmu.builder.validate(fmu_archive: str, use_fmpy: bool = True, use_fmucheck: bool = False, use_vdmcheck: bool = False)
pyfmu.builder.validate_project(project) → bool

Validate a project to ensure that it is consistent.

Arguments:

project {PyfmuProject} – The project that is validated

Returns:

bool – [description]

pyfmu.builder.validate_modelDescription(modelDescription: str, use_fmucheck=False, use_vdmcheck=False, vdmcheck_version=FMI_Versions.FMI2) → ValidationResult
pyfmu.builder._validate_vdmcheck(modelDescription: str, validation_results: ValidationResult, fmi_version=FMI_Versions.FMI2)

Validate the model description using the VDMCheck tool.

Arguments:

modelDescription {str} – textual representation of the model description.

Keyword Arguments:

fmi_version {FMI_Versions} – [description] (default: {FMI_Versions.FMI2})

Raises:

ValueError: Raised if an the fmi_version is unknown or if the tool does not support validation thereof.

Notes:

VDMCheck is implemented in Java, as such it requires java to be available in the path.