Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading issue for settings.py #662

Closed
jmottster opened this issue Mar 3, 2024 · 3 comments
Closed

Loading issue for settings.py #662

jmottster opened this issue Mar 3, 2024 · 3 comments

Comments

@jmottster
Copy link

I had a problem where .bam files were not being saved properly. It took me a long time to figure it out. One thing I came across in my debugging is an issue when using settings.py to set (reset) application.asset_folder and application.compressed_models_folder.

In mesh.py, the save() method has a variable named "folder" which defaults to application.compressed_models_folder. When this method is called from mesh_importer.py (line 78), it relies on this default setting of folder. However, the mesh.py file must get loaded before a local settings.py file is, because "folder" has the default value of application.compressed_models_folder rather than any changes to the value set by settings.py.

Make sense? This issue might happen in other places with other application vars, this is just where I ran into it. I suspect that load_settings() is getting called too late in some cases. How local settings are pulled in may have to be reworked and pulled in sooner than they currently are.

@pokepetter
Copy link
Owner

Yeah, it need to get the value each time those functions runs, since the default values would be the what the value is at time of import.

@pokepetter
Copy link
Owner

I think the solution is to instead of ...

def load_model(name, folder=application.asset_folder):
    ...

... do this:

def load_model(name, folder=None):
    if folder is None:
        folder = application.asset_folder

Or, if we want to keep the information about the default value in the function declaration :

def load_model(name, folder=Func(getattr, application, 'asset_folder')):
    if callable(folder):
        folder = folder()

@pokepetter
Copy link
Owner

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants