Skip to content

Commit

Permalink
Revert "add docstrings with help from copilot", diff eol
Browse files Browse the repository at this point in the history
This reverts commit 7068ee0.
  • Loading branch information
StephanieKemna committed Jul 23, 2024
1 parent 7068ee0 commit 14a8a65
Show file tree
Hide file tree
Showing 15 changed files with 1,292 additions and 1,910 deletions.
20 changes: 6 additions & 14 deletions src/mlfmu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,8 @@ def __init__(
logger.debug(f"Created temp folder: {self.temp_folder_path}")

def __del__(self):
"""
Destructor for the MlFmuBuilder class.
This method is automatically called when the object is about to be destroyed.
The destructor should automatically delete the temporary directory (goes out of scope).
"""
logger.debug("MlFmuBuilder: destructor called, removing temporary build directory.")
# The destructor should automatically delete the temporary directory (goes out of scope).

def build(self):
"""
Expand Down Expand Up @@ -196,7 +191,7 @@ def build(self):

def generate(self):
"""
Generate FMU C++ source code and model description from ml_model_file and interface_file and saves it to source_folder.
Generate FMU c++ source code and model description from ml_model_file and interface_file and saves it to source_folder.
If the paths to the necessary files and directories are not given the function will try to find files and directories that match the ones needed.
Expand Down Expand Up @@ -237,7 +232,7 @@ def generate(self):

def compile(self):
"""
Compile FMU from FMU C++ source code and model description contained in source_folder and saves it to fmu_output_folder.
Compile FMU from FMU c++ source code and model description contained in source_folder and saves it to fmu_output_folder.
If the paths to the necessary files and directories are not given the function will try to find files and directories that match the ones needed.
Expand Down Expand Up @@ -421,8 +416,7 @@ def __init__(
)

def run(self):
"""
Run the mlfmu process.
"""Run the mlfmu process.
Runs the mlfmu process in a self-terminated loop.
"""
Expand All @@ -446,16 +440,14 @@ def run_number(self) -> int:

@property
def max_number_of_runs(self) -> int:
"""
Example for a read/write property implemented through a pair of explicit
"""Example for a read/write property implemented through a pair of explicit
getter and setter methods (see below for the related setter method).
"""
return self._max_number_of_runs

@max_number_of_runs.setter
def max_number_of_runs(self, value: int):
"""
Setter method that belongs to above getter method.
"""Setter method that belongs to above getter method.
Note that implementing specific getter- and setter methods is in most cases not necessary.
The same can be achieved by simply making the instance variable a public attribute.
Expand Down
11 changes: 1 addition & 10 deletions src/mlfmu/cli/mlfmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@


def _argparser() -> argparse.ArgumentParser:
"""
Create and return an ArgumentParser object for parsing command line arguments.
Returns
-------
argparse.ArgumentParser: The ArgumentParser object.
"""

parser = argparse.ArgumentParser(
prog="mlfmu",
epilog="_________________mlfmu___________________",
Expand Down Expand Up @@ -136,8 +128,7 @@ def _argparser() -> argparse.ArgumentParser:


def main():
"""
Entry point for console script as configured in setup.cfg.
"""Entry point for console script as configured in setup.cfg.
Runs the command line interface and parses arguments and options entered on the console.
"""
Expand Down
21 changes: 10 additions & 11 deletions src/mlfmu/cli/publish_docs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging

from mlfmu.utils.interface import publish_interface_schema

logger = logging.getLogger(__name__)


def main():
"""Start the publishing process for the mlfmu interface docs, by calling the publish_interface_schema function."""
logger.info("Start publish-interface-docs.py")
publish_interface_schema()
import logging

from mlfmu.utils.interface import publish_interface_schema

logger = logging.getLogger(__name__)


def main():
logger.info("Start publish-interface-docs.py")
publish_interface_schema()
82 changes: 23 additions & 59 deletions src/mlfmu/fmu_build/templates/fmu/fmu_template.cpp
Original file line number Diff line number Diff line change
@@ -1,59 +1,23 @@
#include "fmu-uuid.h"
#include "model_definitions.h"

#include <cppfmu_cs.hpp>
#include <onnxFmu.hpp>


/**
* \class {FmuName}
* \brief A class representing an {FmuName} FMU.
*
* This class is derived from the OnnxFmu class and provides functionality specific to the {FmuName} FMU.
*/
class
{
FmuName
} : public OnnxFmu {{
public :
/**
* \brief Constructs a new {FmuName} object.
*
* \param fmuResourceLocation The location of the FMU resource.
*/
{FmuName}(cppfmu::FMIString fmuResourceLocation) : OnnxFmu(fmuResourceLocation) {}

private :
// Add private members and functions here
}};

/**
* \brief Instantiate a `slave` instance of the FMU.
*
* \param instanceName The name of the FMU instance.
* \param fmuGUID The GUID of the FMU.
* \param fmuResourceLocation The location of the FMU resource.
* \param mimeType The MIME type of the FMU.
* \param timeout The timeout value for the instantiation process.
* \param visible Flag indicating whether the FMU should be visible.
* \param interactive Flag indicating whether the FMU should be interactive.
* \param memory The memory to be used for the FMU instance.
* \param logger The logger to be used for logging messages.
* \returns A unique pointer to the instantiated slave instance.
*
* \throws std::runtime_error if the FMU GUID does not match.
*/
cppfmu::UniquePtr<cppfmu::SlaveInstance> CppfmuInstantiateSlave(
cppfmu::FMIString /*instanceName*/, cppfmu::FMIString fmuGUID, cppfmu::FMIString fmuResourceLocation,
cppfmu::FMIString /*mimeType*/, cppfmu::FMIReal /*timeout*/, cppfmu::FMIBoolean /*visible*/,
cppfmu::FMIBoolean /*interactive*/, cppfmu::Memory memory, cppfmu::Logger /*logger*/)
{
{
if (std::strcmp(fmuGUID, FMU_UUID) != 0) {
{
throw std::runtime_error("FMU GUID mismatch");
}
}
return cppfmu::AllocateUnique<{FmuName}>(memory, fmuResourceLocation);
}
}
#include "fmu-uuid.h"
#include "model_definitions.h"

#include <cppfmu_cs.hpp>
#include <onnxFmu.hpp>


class {FmuName} : public OnnxFmu {{
public :
{FmuName}(cppfmu::FMIString fmuResourceLocation) : OnnxFmu(fmuResourceLocation) {{}} private :
}};


cppfmu::UniquePtr<cppfmu::SlaveInstance> CppfmuInstantiateSlave(
cppfmu::FMIString /*instanceName*/, cppfmu::FMIString fmuGUID, cppfmu::FMIString fmuResourceLocation,
cppfmu::FMIString /*mimeType*/, cppfmu::FMIReal /*timeout*/, cppfmu::FMIBoolean /*visible*/,
cppfmu::FMIBoolean /*interactive*/, cppfmu::Memory memory, cppfmu::Logger /*logger*/)
{{
if (std::strcmp(fmuGUID, FMU_UUID) != 0) {{
throw std::runtime_error("FMU GUID mismatch");
}}
return cppfmu::AllocateUnique<{FmuName}>(memory, fmuResourceLocation);
}}
Loading

0 comments on commit 14a8a65

Please sign in to comment.