stephensmith25 / pythonfmu3 Goto Github PK
View Code? Open in Web Editor NEWA lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs following version 3.0
License: MIT License
A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs following version 3.0
License: MIT License
The documentation examples suggest to import pythonfmu3 as, for example:
from pythonfmu3 import Fmi3Causality, Fmi3Slave, Boolean, Int32, Float64, String
However, one may wish to import like this:
import pythonfmu3 as pyfmu3
Then, later in the code, do something like this:
class MyFMU(pyfmu3.Fmi3Slave):
...
However, when compiling the FMU, this will fail with the following error message:
File "E:\Pegasus\sensors\fmu_venv\lib\site-packages\pythonfmu3\builder.py", line 27, in get_class_name
return re.search(r'class (\w+)\(\s*Fmi3Slave\s*\)\s*:', data).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
So, it appears that the pythonFMU3 code relies on the import style used in the documentation examples, because it searches for class declarations that look like this:
class PythonSlave(Fmi3Slave):
....
and not like the MyFMU case above.
Users should be able to import the code either way.
Incidentally, is searching for regular expressions in the code the best way to find classes that extend Fmi3Slave? Would it not be better to instantiate classes, test if they are an instance of Fmi3Slave (which will be True for all subclasses), then get the name via reflection? e.g. type(subclass_instance).__name__
Hello! First of all, thank you for working on this project, is very helpful.
I am trying to replicate the bouncingBall example but I am not able to compile the code to Darwin. I am aware this was an issue with the old pythonfmu but they mention they solved the problem with posterior PR. However, that limitation seems to remain. Do you know how to overcome this limitation ?
I have built a test application with pythonfmu3, it works fine being instantiated with fmpy,
But I need to actually run on a second server that has to run python3.9, redhat 8.
When I rebuild - it runs, when I try and instantiate it fails stating it is missing a python3.11 "so" file.
When I grep the folder, and unzip the FMU file, for python3.11 - I can see
grep -R "python3.11"
Binary file FMUWrapper.fmu matches
Binary file binaries/x86_64-linux/FMUWrapper.so matches
But my python version is
python
Python 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:50:21)
[GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
These are two different machines so I don't think I have a polluted environment, I've performed a clean etc. On the second machine I don't have python3.11 installed at all.
Any thoughts? is this a hard coded version of python?
The docs are here: https://pythonfmu3.readthedocs.io/en/latest/usage/
Examples are given.
The second one, BouncingBall, does not compile, with the error message: AttributeError: 'BouncingBall' object has no attribute 'ball'
Documentation shows that the model description should be specified like this:
class PythonSlave(Fmi3Slave):
author = "John Doe"
description = "A simple description"
...
However, if I then run fmpy.dump(...)
on the resultant FMU, it displays the following:
Model Info
FMI Version 3.0
FMI Type Co-Simulation
Model Name PythonSlave
Description None
...
By contrast, if I run fmpy.dump(...)
on an FMU generated by another program, then I get, for example:
Model Info
FMI Version 2.0
FMI Type Co-Simulation
Model Name 160424_V9LCSUT
Description Simcenter Flomaster network with FMI for co-simulation interface
...
i.e. the problem is not with fmpy.dump(...)
.
We should probably incorporate change in the forked project
If we want to build for OSX.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.