AttributeError: ‘numpy.int64’ object has no attribute ‘dict’

I have the following protocol to add liquid to plates based on volumes given in a spreadsheet:

while vol_water_added < vol_water:

   tip_loc = [next(tip_iterator) for x in range(num_channels)]
   await lh.pick_up_tips(tip_loc)

   vol = min(max_vol, vol_water-vol_water_added)
   await lh.aspirate(tube_rack1["A3"], vols=[vol])
   await lh.dispense(lh.deck.get_resource(plate)[loc], vols=[vol])
   await lh.discard_tips()
   vol_water_added += vol

It aspirates approximately 100 uL over several aspirations using a 20 uL pipette. The first several aspirations work, but when it gets to the final one for the first well, I get an error message. I use essentially the same steps in another protocol and it works fine, so I was wondering if someone could help me debug the issue.

Error message:


AttributeError Traceback (most recent call last)
Cell In[21], line 21
19 vol = min(max_vol, vol_water-vol_water_added)
20 await lh.aspirate(tube_rack1[“A3”], vols=[vol])
—> 21 await lh.dispense(lh.deck.get_resource(plate)[loc], vols=[vol])
22 await lh.discard_tips()
23 vol_water_added += vol

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\machines\machine.py:25, in need_setup_finished..wrapper(self, *args, **kwargs)
23 if not self.setup_finished:
24 raise RuntimeError(“The setup has not finished. See setup.”)
—> 25 return await func(self, *args, **kwargs)

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\liquid_handling\liquid_handler.py:932, in LiquidHandler.dispense(self, resources, vols, use_channels, flow_rates, offsets, liquid_height, blow_out_air_volume, **backend_kwargs)
929 op.tip.tracker.liquid_history.update(op.resource.tracker.liquid_history)
931 for liquid, volume in op.liquids:
→ 932 op.resource.tracker.add_liquid(liquid=liquid, volume=volume)
933 op.tip.tracker.remove_liquid(op.volume)
935 # fix the backend kwargs

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\resources\volume_tracker.py:156, in VolumeTracker.add_liquid(self, liquid, volume)
153 self.pending_liquids.append((liquid, volume))
155 if self._callback is not None:
→ 156 self._callback()

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\resources\resource.py:691, in Resource._state_updated(self)
689 def _state_updated(self):
690 for callback in self._resource_state_updated_callbacks:
→ 691 callback(self.serialize_state())

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\resources\container.py:55, in Container.serialize_state(self)
54 def serialize_state(self) → Dict[str, Any]:
—> 55 return self.tracker.serialize()

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\resources\volume_tracker.py:211, in VolumeTracker.serialize(self)
206 “”" Serialize the volume tracker. “”"
208 if not self.is_cross_contamination_tracking_disabled:
209 return {
210 “liquids”: [serialize(l) for l in self.liquids],
→ 211 “pending_liquids”: [serialize(l) for l in self.pending_liquids],
212 “liquid_history”: [serialize(l) for l in self.liquid_history],
213 }
215 return {
216 “liquids”: [serialize(l) for l in self.liquids],
217 “pending_liquids”: [serialize(l) for l in self.pending_liquids],
218 }

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\serializer.py:33, in serialize(obj)
31 return obj
32 if isinstance(obj, (list, tuple, set)):
—> 33 return [serialize(item) for item in obj]
34 if isinstance(obj, dict):
35 return {k: serialize(v) for k, v in obj.items()}

File c:\users\jaren\documents\pipetting programs\pylabrobot\pylabrobot\serializer.py:43, in serialize(obj)
41 else:
42 data: Dict[str, Any] = {}
—> 43 for key, value in obj.dict.items():
44 if key.startswith(“_”):
45 continue

AttributeError: ‘numpy.int64’ object has no attribute ‘dict

My guess is that vol_water, or whichever variable is loaded from the spreadsheet, is a numpy.int64 rather than a float/int. PLR only supports float/int. Can you confirm the type of the numbers you load? print(type(num)) It is easy to convert the number using num = float(num).

1 Like

PLR only supports float/int.

Actually, just added the conversion in PLR methods so you don’t have to convert manually. let me know if this update fixes it.

1 Like

This solved my problem, thank you. My working protocol used type numpy.float64 which was apparently acceptable to PLR (whereas numpy.int64 was not).

1 Like

nice to hear it’s working!