architecture-building-systems / CityEnergyAnalyst

The City Energy Analyst (CEA)
https://www.cityenergyanalyst.com/
MIT License
196 stars 66 forks source link

failed _temp_directory call in demand-script #3396

Closed MatNif closed 1 year ago

MatNif commented 1 year ago

Describe the bug Not too sure what creates this yet. But this popped up when running the 'demand'-script on a district of industrial and office buildings in south-western Singapore:

City Energy Analyst version 3.34.2
Running `cea demand` with the following parameters:
- general:scenario = C:\Users\nimathia\Documents\CEA_Testing\Quick_Test_Scenarios\Supply_system_outputs
  (default: {general:project}\{general:scenario-name})
- general:multiprocessing = True
  (default: True)
- general:number-of-cpus-to-keep-free = 4
  (default: 1)
- general:debug = False
  (default: False)
- demand:buildings = ['B1000', 'B1001', 'B1002', 'B1003', 'B1004', 'B1005', 'B1006', 'B1007', 'B1008', 'B1009', 'B1010', 'B1011', 'B1012', 'B1013', 'B1014', 'B1015', 'B1016', 'B1017', 'B1018', 'B1019', 'B1020', 'B1021', 'B1022', 'B1023', 'B1024', 'B1025', 'B1026', 'B1027', 'B1028', 'B1031', 'B1032', 'B1033']
  (default: [])
- demand:loads-output = ['PV', 'GRID', 'GRID_a', 'GRID_l', 'GRID_v', 'GRID_ve', 'GRID_data', 'GRID_pro', 'GRID_aux', 'GRID_ww', 'GRID_hs', 'GRID_cs', 'GRID_cdata', 'GRID_cre', 'E_sys', 'Eal', 'Ea', 'El', 'Ev', 'Eve', 'Edata', 'Epro', 'Eaux', 'E_ww', 'E_hs', 'E_cs', 'E_cre', 'E_cdata', 'Qhs_sen_shu', 'Qhs_sen_ahu', 'Qhs_lat_ahu', 'Qhs_sen_aru', 'Qhs_lat_aru', 'Qhs_sen_sys', 'Qhs_lat_sys', 'Qhs_em_ls', 'Qhs_dis_ls', 'Qhs_sys_shu', 'Qhs_sys_ahu', 'Qhs_sys_aru', 'Qcs_sys_scu', 'Qcs_sys_ahu', 'Qcs_sys_aru', 'DH_hs', 'Qhs_sys', 'Qhs', 'DH_ww', 'Qww_sys', 'Qww', 'DC_cs', 'Qcs_sys', 'Qcs', 'DC_cre', 'Qcre_sys', 'Qcre', 'DC_cdata', 'Qcdata_sys', 'Qcdata', 'NG_hs', 'COAL_hs', 'OIL_hs', 'WOOD_hs', 'SOLAR_hs', 'NG_ww', 'COAL_ww', 'OIL_ww', 'WOOD_ww', 'SOLAR_ww', 'Qcs_sen_scu', 'Qcs_sen_ahu', 'Qcs_lat_ahu', 'Qcs_sen_aru', 'Qcs_lat_aru', 'Qcs_sen_sys', 'Qcs_lat_sys', 'Qcs_em_ls', 'Qcs_dis_ls', 'Qhpro_sys', 'Qcpro_sys', 'QH_sys', 'QC_sys']
  (default: [])
- demand:massflows-output = ['mcpww_sys', 'mcptw', 'mcpcs_sys', 'mcphs_sys', 'mcpcs_sys_ahu', 'mcpcs_sys_aru', 'mcpcs_sys_scu', 'mcphs_sys_ahu', 'mcphs_sys_aru', 'mcphs_sys_shu', 'mcpcre_sys', 'mcpcdata_sys']
  (default: [])
- demand:temperatures-output = ['T_int', 'T_ext', 'theta_o', 'Tww_sys_sup', 'Tww_sys_re', 'Tcre_sys_re', 'Tcre_sys_sup', 'Tcdata_sys_re', 'Tcdata_sys_sup', 'Ths_sys_sup_aru', 'Ths_sys_sup_ahu', 'Ths_sys_sup_shu', 'Ths_sys_re_aru', 'Ths_sys_re_ahu', 'Ths_sys_re_shu', 'Tcs_sys_sup_aru', 'Tcs_sys_sup_ahu', 'Tcs_sys_sup_scu', 'Tcs_sys_re_aru', 'Tcs_sys_re_ahu', 'Tcs_sys_re_scu', 'Ths_sys_sup', 'Ths_sys_re', 'Tcs_sys_sup', 'Tcs_sys_re']
  (default: [])
- demand:resolution-output = hourly
  (default: hourly)
- demand:use-dynamic-infiltration-calculation = False
  (default: False)
- demand:overheating-warning = True
  (default: True)
Running demand calculation for scenario C:\Users\nimathia\Documents\CEA_Testing\Quick_Test_Scenarios\Supply_system_outputs
Running demand calculation with dynamic infiltration=False
Running demand calculation with multiprocessing=True
Running demand calculation for the following buildings=['B1000', 'B1001', 'B1002', 'B1003', 'B1004', 'B1005', 'B1006', 'B1007', 'B1008', 'B1009', 'B1010', 'B1011', 'B1012', 'B1013', 'B1014', 'B1015', 'B1016', 'B1017', 'B1018', 'B1019', 'B1020', 'B1021', 'B1022', 'B1023', 'B1024', 'B1025', 'B1026', 'B1027', 'B1028', 'B1031', 'B1032', 'B1033']
read input files
done
Using 12 CPU's
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "C:\Users\nimathia\Documents\GitHub\CityEnergyAnalyst\Dependencies\Python\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\nimathia\Documents\GitHub\CityEnergyAnalyst\Dependencies\Python\lib\multiprocessing\pool.py", line 48, in mapstar
    return list(map(*args))
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\utilities\parallel.py", line 131, in __apply_func_with_worker_stream
    result = func(*args)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\demand\thermal_loads.py", line 162, in calc_thermal_loads
    write_results(bpr, building_name, date_range, loads_output, locator, massflows_output,
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\demand\thermal_loads.py", line 191, in write_results
    writer.results_to_csv(tsd, bpr, locator, date, building_name)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\demand\demand_writers.py", line 57, in results_to_csv
    locator.get_temporary_file('%(building_name)sT.csv' % locals()),
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\inputlocator.py", line 1130, in get_temporary_file
    return os.path.join(self.get_temporary_folder(), filename)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\inputlocator.py", line 1124, in get_temporary_folder
    if self._temp_directory is None:
AttributeError: 'InputLocator' object has no attribute '_temp_directory'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\worker.py", line 146, in worker
    run_job(config, job, server)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\worker.py", line 108, in run_job
    script(config=config, **parameters)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\api.py", line 60, in __call__
    self._runner.__call__(*args, **kwargs)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\api.py", line 38, in script_runner
    script_module.main(config)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\demand\demand_main.py", line 145, in main
    demand_calculation(locator=locator, config=config)
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\demand\demand_main.py", line 106, in demand_calculation
    calc_thermal_loads(
  File "c:\users\nimathia\documents\github\cityenergyanalyst\cityenergyanalyst\cea\utilities\parallel.py", line 96, in wrapper
    result = map_result.get()
  File "C:\Users\nimathia\Documents\GitHub\CityEnergyAnalyst\Dependencies\Python\lib\multiprocessing\pool.py", line 771, in get
    raise self._value
AttributeError: 'InputLocator' object has no attribute '_temp_directory'

Expected behaviour I wouldn't have expected an attempt at a '_temp_directory' call here. The radiation outputs and all previous outputs should be stored in the outputs file. I don't quite see what the 'demand'-script would need to fetch from a temporary directory.

Hardware (please complete the following information):

MatNif commented 1 year ago

I tried rerunning it, and the issue seemed resolved. I'm not sure why the error popped up twice but did not later.