Comments (11)
One more. Based on this post it has something to do with the order of loading libraries. I will give it a try soon.
from butterfly.
For now I added a force reload from this post which does the job but I need to get this fixed at some point.
def reload_package(root_module):
package_name = root_module.__name__
# get a reference to each loaded module
loaded_package_modules = dict([
(key, value) for key, value in sys.modules.items()
if key.startswith(package_name) and isinstance(value, types.ModuleType)])
# delete references to these loaded modules from sys.modules
for key in loaded_package_modules:
del sys.modules[key]
# load each of the modules again;
# make old modules share state with new modules
for key in loaded_package_modules:
# print 'loading %s' % key
newmodule = __import__(key)
oldmodule = loaded_package_modules[key]
oldmodule.__dict__.clear()
oldmodule.__dict__.update(newmodule.__dict__)
from butterfly.
I don't know. If you dig deep enough in the darkest corners of IronPython, I am not sure what you could find :) maybe something horrific :D
Is there any way you could do things more simply?
from butterfly.
Can you explain what you are trying to do? I am too stupid to understand this part: "re-structuring the folders when all the libraries where in the same level".
from butterfly.
In general, .Net types are defined by their location as well. If you load two assemblies that are a copy of each other, but from two different paths, their symbols will be different and, for example, methods accepting one type will not accept the other.
from butterfly.
Hi @piac. Thanks for your comments.
I'm not doing anything crazy. It's just using super for subclasses. I spent some time reading about the issue and it seems to be a common problem with super
if module gets reloaded during the process.
What happens is that the id of the older version (which still exists because some other data are pointing to it) and the new version won't match and so super(subclass, self)
returns False.
I couldn't recreate it in python which is easier to debug but it happens in Grasshopper/IronPython on every single run. Looks like it also frequently happens in IPython (which reloads the modules frequently). There are a couple of solutions suggested on the web but none of them worked for me except for removing the old module and force reloading it.
Disregard my comment about changing the structure. I tested and it still gives me the error. What I meant is that I moved all the files with Rhino dependencies under a separate folder and started to use relative import which I suspected is causing the issue. I was wrong though. I copied all the files back and it didn't solve the problem.
Anyways I'm good for now but it's good if at some point we can figure out what's exactly going on. That dark corners that you mentioned! :D
from butterfly.
I think you should investigate why this reloading happens, and under which conditions this super() call fails. This is, though, 99% a IronPython question. If one of the parent classes is a .Net class, in which case, it's still a IronPython issue, I think it might be difficult to make this work for the developers of IronPython.
I couldn't recreate it in python which is easier to debug but it happens in Grasshopper/IronPython on every single run.
Did you mean this seems not to happen in the _EditPythonScript editor?
from butterfly.
No I mean out of Grasshopper/Rhino just loading the libraries in python. I haven't tested it in _EditPythonScript.
from butterfly.
@mostaphaRoudsari Oh, I understand. Please mention me again when you are able to test there. Maybe it will help.
from butterfly.
Finally found the reason why this was happening. In a different GHPython component I was reloading butterfly which was causing all the issues. Now it has been fixed.
Sorry @piac! I should have double checked the components more carefully. Thank you for the support.
from butterfly.
Awesome, very good to know this!
from butterfly.
Related Issues (20)
- blockmesh :1.solution exception:windowserror. Who can help me!!! HOT 4
- Solution exception: WindowsError HOT 2
- Running time for Butterfly HOT 3
- Runtime error (UnauthorizedAccessException): Access to the path is denied
- butterfly doesn't seem to wake up blueCFD HOT 1
- Butterfly, Rhino, and BlueCore2020? HOT 6
- 1. Solution exception:WindowsError (wind analysis)
- Butterfly BlueCFD Installation. Followed instructions for both but still receiving error '1. Solution exception: Failed to import butterfly: No module named butterfly_grasshopper.timer'
- Blockmesh Component Error HOT 2
- Blockmesh Component Error HOT 2
- SnappyHexMesh Failed!
- 1. Solution exception:'"C:\Program Files\blueCFD-Core-2020\setvars.bat"' is not recognized as an internal or external command, operable program or batch file HOT 1
- Deleted
- Solution exception:Failed to find points file at C:\Users\An'd's\butterfly\outdoor_airflow\constant\polyMesh
- help,butterfly block mesh is warning HOT 4
- AddLayers output empty with True input in SnappyHexMesh HOT 2
- Moving or dynamic mesh
- Butterfly Python API documentation link broken.
- Butterfly Help WindowsError HOT 2
- Butterfly installation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from butterfly.