Replies: 2 comments 1 reply
-
After some further thought + debugging, I think it is likely something along the lines of this answer (https://stackoverflow.com/questions/46813375/multiprocessing-pool-map-drops-attribute-of-subclassed-ndarray), which is that the extra attributes are lost during serialization. |
Beta Was this translation helpful? Give feedback.
-
Hi @mr483, I'm no multiprocessing expert, but yes, it does seem likely to be something to do with the serialization. I assume that the missing attribute I am a bit perplexed at first about why the
self.turbine_type_names_sorted = [turb["turbine_type"] for turb in self.turbine_definitions]
self.turbine_type_map_sorted = np.take_along_axis(
np.reshape(self.turbine_type_names_sorted * n_wind_directions, np.shape(sorted_coord_indices)),
sorted_coord_indices,
axis=2
) to
that is, make Those might help solve the immediate problem, but you could run into serialization issues elsewhere. To be honest, I think the best approach is probably to simply call |
Beta Was this translation helpful? Give feedback.
-
I am working to parallelize some fi.calculate_wake() calls in FLORIS V3.1.1, and have generally the structure shown below (this is my attempt at a minimum reproducible example, to show the principle of the problem).
Effectively, I am configuring a bunch of floris instances with different sets of parameters (using copy.deepcopy() to create unique objects with those settings) and then submitting them to the starmap function. "s" is a label, which makes more sense in full context of the use-case. Now, if I were to run fi.calculate_wake() on the floris instances directly after they are configured (i.e., after fi.reinitialize(...)), everything runs fine. However, within the ts_get_sub_AEPs() function, I get the error:
AttributeError: 'Farm' object has no attribute 'turbine_type_names_sorted'
Within the parallelized function, I added some debugging code and determine the fi instances have the correct wake model parameters and tuning parameters which I have configured. However, they are missing some critical attributes (such as turbine_type_names_sorted). I had the function just return the object floris_inst directly and examined the results, and indeed the input fi which is provided to multiargs does not match the fi which exists in the ts_get_sub_AEPs function, despite there being no intervening operations done with the fi object.
I'm probably missing something very fundamental here, but not sure what it is. The quick fix is that within the function that is parallelized, I just add a fi.reinitialize(), with no change of parameters. It then correctly creates the sorted arrays which I need. But, this of course adds a little overhead, and I can't understand why it's necessary since I haven't done any operations on the fi object which would seemingly necessitate me to reinitialize.
Beta Was this translation helpful? Give feedback.
All reactions