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

Permission denied with glb saving with api_server only #56

Open
GarikDog opened this issue Jan 28, 2025 · 3 comments
Open

Permission denied with glb saving with api_server only #56

GarikDog opened this issue Jan 28, 2025 · 3 comments

Comments

@GarikDog
Copy link

Hello! I encountered a permission denied error while trying to work with the blender addon. Everything is fine with gradio_app itself, I can save and download meshes. But when working with api_server there is such a problem. I tried changing the temp location for the current session, I even tried running everything from the administrator from the general vs code debugging. Unfortunately nothing helped. I even tried to assign a temp folder inside the current conda environment directory. Always the same result.

2025-01-28 19:38:15 | INFO | stdout | Caught Unknown Error [Errno 13] Permission denied: 'e:\temp\tmpxpov9qha.glb'
2025-01-28 19:38:15 | ERROR | stderr | Traceback (most recent call last):
2025-01-28 19:38:15 | ERROR | stderr | File "E:\Hunyuan3D-2\api_server.py", line 208, in generate
2025-01-28 19:38:15 | ERROR | stderr | file_path, uid = worker.generate(uid, params)
2025-01-28 19:38:15 | ERROR | stderr | File "E:\Hunyuan3D-2\condaenv\lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context
2025-01-28 19:38:15 | ERROR | stderr | return func(*args, **kwargs)
2025-01-28 19:38:15 | ERROR | stderr | File "E:\Hunyuan3D-2\api_server.py", line 190, in generate
2025-01-28 19:38:15 | ERROR | stderr | mesh.export(temp_file.name)
2025-01-28 19:38:15 | ERROR | stderr | File "E:\Hunyuan3D-2\condaenv\lib\site-packages\trimesh\base.py", line 2827, in export
2025-01-28 19:38:15 | ERROR | stderr | return export_mesh(mesh=self, file_obj=file_obj, file_type=file_type, **kwargs)
2025-01-28 19:38:15 | ERROR | stderr | File "E:\Hunyuan3D-2\condaenv\lib\site-packages\trimesh\exchange\export.py", line 55, in export_mesh
2025-01-28 19:38:15 | ERROR | stderr | file_obj = open(file_path, "wb")
2025-01-28 19:38:15 | ERROR | stderr | PermissionError: [Errno 13] Permission denied: 'e:\temp\tmpxpov9qha.glb'

@GarikDog
Copy link
Author

I also tried to just directly create something in temp from the current terminal. It turns out to be possible to do this, that is, in theory there should be enough rights

@dwforbes
Copy link

On Windows devices, an opened file cannot be opened again for writing, but this is what is attempted on line 189 and 190, where NamedTemporaryFile opens the file and then mesh.export called from the next line tries to open it again for writing.

Change delete=True to delete=False on line 189 and add appropriate temp_file.Close() and os.unlink(temp_file.name) after the mesh is reloaded within that block.

Hope this helps.

@GarikDog
Copy link
Author

On Windows devices, an opened file cannot be opened again for writing, but this is what is attempted on line 189 and 190, where NamedTemporaryFile opens the file and then mesh.export called from the next line tries to open it again for writing.

Change delete=True to delete=False on line 189 and add appropriate temp_file.Close() and os.unlink(temp_file.name) after the mesh is reloaded within that block.

Hope this helps.

Yes! Thank you! It works! Here is the block code, maybe it will help someone else!

with tempfile.NamedTemporaryFile(suffix='.glb', delete=False) as temp_file:
            mesh.export(temp_file.name)
            mesh = trimesh.load(temp_file.name)
            temp_file.close()
            os.unlink(temp_file.name)
            save_path = os.path.join(SAVE_DIR, f'{str(uid)}.glb')
            mesh.export(save_path)

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