IN-CORE / incore-docs

IN-CORE documentations
9 stars 13 forks source link

Retrofit notebooks fails due to the permission error in windows #370

Closed ywkim312 closed 2 months ago

ywkim312 commented 2 months ago

Retrofit notebooks, such as slc_community_app_retrofit in notebook folder has following error. It also happens in other retrofit notebook

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
Cell In[6], line 22
     19 bldg_dmg_retrofit.load_remote_input_dataset("retrofit_strategy", retrofit_strategy_plan_id)
     21 # Run building damage without liquefaction
---> 22 bldg_dmg_retrofit.run_analysis()
     24 end_time = time.time()
     25 print(f"total runtime: {end_time - start_time}")

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\baseanalysis.py:400, in BaseAnalysis.run_analysis(self)
    397         print("Error reading parameter: " + result[1])
    398         return result
--> 400 return self.run()

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\analyses\buildingdamage\buildingdamage.py:107, in BuildingDamage.run(self)
    105 # clean up temp folder if applicable
    106 if tmpdirname is not None:
--> 107     bldg_dataset.delete_temp_folder()
    109 return True

File ~\.conda\envs\pyincore\lib\site-packages\pyincore\dataset.py:347, in Dataset.delete_temp_folder(self)
    345 absolute_path = path.parent.absolute()
    346 if os.path.isdir(absolute_path):
--> 347     shutil.rmtree(absolute_path)

File ~\.conda\envs\pyincore\lib\shutil.py:759, in rmtree(path, ignore_errors, onerror)
    757     # can't continue even if onerror hook returns
    758     return
--> 759 return _rmtree_unsafe(path, onerror)

File ~\.conda\envs\pyincore\lib\shutil.py:629, in _rmtree_unsafe(path, onerror)
    627             os.unlink(fullname)
    628         except OSError:
--> 629             onerror(os.unlink, fullname, sys.exc_info())
    630 try:
    631     os.rmdir(path)

File ~\.conda\envs\pyincore\lib\shutil.py:627, in _rmtree_unsafe(path, onerror)
    625 else:
    626     try:
--> 627         os.unlink(fullname)
    628     except OSError:
    629         onerror(os.unlink, fullname, sys.exc_info())

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\user_name\\AppData\\Local\\Temp\\tmpl_rzhl3c\\tmp_updated_62fea288f5438e1f8c515ef8.dbf'

the cell has an error is

# Analysis setup
start_time = time.time()

bldg_dmg_retrofit = BuildingDamage(client)

bldg_dmg_retrofit.set_input_dataset('dfr3_mapping_set', mapping_set)

bldg_dmg_retrofit.load_remote_input_dataset("buildings", "62fea288f5438e1f8c515ef8") #  Salt Lake County All Building
bldg_dmg_retrofit.set_parameter("result_name", "SLC_bldg_dmg_w_retrofit-withLIQ7.1")

eq = Earthquake.from_hazard_service(hazard_id, hazard_services) #  Mw 7.1
bldg_dmg_retrofit.set_input_hazard("hazard", eq)

bldg_dmg_retrofit.set_parameter("use_liquefaction", True)
bldg_dmg_retrofit.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id)
bldg_dmg_retrofit.set_parameter("num_cpu", 8)

# retrofit strategy
bldg_dmg_retrofit.load_remote_input_dataset("retrofit_strategy", retrofit_strategy_plan_id)

# Run building damage without liquefaction
bldg_dmg_retrofit.run_analysis()

end_time = time.time()
print(f"total runtime: {end_time - start_time}")

This is probably windows specific and it is probably the problem of pyincore not notebook

ywkim312 commented 2 months ago

This one has been moved to pyincore