When we launch a simulation, it sometimes fails with pcse.exceptions.PCSEError: Empty CABO file!. We traced back the error to this line of code.
In fact, what happens is that each time we create a new Irrigation object, we download the soil data. Not only is it not effective, it is also error prone. We assume that the retrieve could possibly go wrong due to network error during the simulation.
Solution
Refactor the code by extracting a get_soil_data to download the soil data only if the ec3.soil doesn't exist.
Context
When we launch a simulation, it sometimes fails with
pcse.exceptions.PCSEError: Empty CABO file!
. We traced back the error to this line of code.In fact, what happens is that each time we create a new
Irrigation
object, we download the soil data. Not only is it not effective, it is also error prone. We assume that the retrieve could possibly go wrong due to network error during the simulation.Solution
Refactor the code by extracting a
get_soil_data
to download the soil data only if theec3.soil
doesn't exist.