Delete simulation folder after run

Hi,

When I run my Honeybee recipe I can specify the simulation output folder with:

settings = RecipeSettings()
settings.workers = WORKERS
settings.report_out = False
settings.folder = SIM_OUT_FOLDER + '/' + model.display_name
    
 # Run the simulation 
project_folder = recipe.run(settings=settings, radiance_check=True, silent=False, queenbee_path='queenbee')

I was wondering if there is any way to auto delete the simulation folder after the simulation has run. Of course I can script it manually, but I noticed that in general, these simulations take up a lot of storage space. Since I am not using the folder afterwards, it would be great if there would be an argument to delete the folder afterwards.

Thank you for your time!

Hi @JobdeVogel ,

The usual way that we deal with this issue is just by not changing the simulation directory each time that we run a simulation that we aren’t particularly concerned about saving the results:

This way, the results just get overwritten each time. We don’t have an “automatic delete” option built into the lbt-recipes command but you can use this nukedir method in ladybug if you want to delete the folder and all of its contents

We wrote it in a way that it won’t fail if certain files in the directory cannot be deleted for whatever reason.

Hi @chris,

Thanks for your answer! I fully understand your reasoning. Perhaps I am working with a bit of an exceptional case, because I am running my recipe in parallel using multiprocessing. Therefore, I think I have to specifically add a directory because processes would otherwise try to access the same simulation files. This in general works pretty good, but after running my simulations for a few hours, I noticed that my disk is lacking in space for the simulation files, and therefore fails to continue.

I was able to find a partial solution by deleting my project directory after the simulation has finished using:

settings = RecipeSettings()
settings.workers = WORKERS
settings.report_out = False
settings.folder = SIM_OUT_FOLDER + '/' + model.display_name
  
# Run the simulation 
project_folder = recipe.run(settings=settings, radiance_check=True, silent=False, queenbee_path='queenbee')

# Retrieve the results
irradiance = recipe.output_value_by_name('cumulative-radiation', project_folder)[0]
  
shutil.rmtree(settings.folder)

However, after running the script for several hours, Radiance/Honeybee starts complaining about certain files that do not exist, such as:

Invalid result folder: d:/graduation_jobdevogel/code/Graduation-Building-Technology/data/simulation/0eae245e-be93-4f69-8cd5-319525c0405e\cumulative_radiation\results/cumulative_radiation

I have not found a reason for this problem, but I can imagine it is probably caused by a bug in my script, or the way Windows is using the multiple process. It is a bit hard to figure out because it only happens after at least 10 hours of running my simulations :slight_smile: If you have ideas what could be causing this issue, please let me know!