Tap Tool Multiple ColumnDataSource

I have several dozen CDS’s stored in a list, and each CDS is for a separate glyph on my plot (I don’t want to use Multiline because then I can’t have circle glyph and line glyph as part of my combined legend). I can successfully set a tap tool callback for each item in the list as I iterate through the list like this:

cds_availability[i].selected.on_change('indices',tap_callback)

However, when it comes time to actually use the tap_callback function, I don’t know how to reference which CDS in my list I am trying to access to get the selected indices from the tap. All the examples I can find only have one ColumnDataSource in the code, which is then easy to reference and access by index in the callback (with source.indices, for example). How do I know which of my CDS’s in the list cds_availability has been selected with the tap? In other words, in this example, how do I reference the correct selected source to get the indices of that selected source?

In the callback body, cb_data.source is the data source.

Thanks @Bryan, I assume there is something like this. Unfortunately, when I change my callback to look like this…

def tap_callback(attr, old, new):
    source = cb_data.source
    index = source.selected.indices
    print(source.employee[index])

…I get the error message:

error handling message Message ‘PATCH-DOC’ (revision 1) content: {‘events’: [{‘kind’: ‘ModelChanged’, ‘model’: {‘type’: ‘Selection’, ‘id’: ‘27978’}, ‘attr’: ‘indices’, ‘new’: []}], ‘references’: []}: NameError(“name ‘cb_data’ is not defined”). I also tried p.cb_data.source, but the IDE tells me that instance ‘Figure’ has no ‘cb_data’ member. Thanks for any additional assist.

@kagacins Sorry, when you said “Taptool callback” I was thinking you meant TapTool.callback.

For this I would an additional source parameter to the callback, and then use functools.partial to “bake in” the relevant/associated data source for each on_change call.