Conversation
Collaborator
Author
|
@mrakitin what we are stuck on: DetailsIn [1]: %run -i run.py
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/src/mfx/run.py:148
145 from event_model import compose_event_page
147 descriptor_uid = descriptor["uid"]
--> 148 new_doc = compose_event_page(
149 descriptor=descriptor,
150 event_counters={descriptor_uid:[1]},
151 data={descriptor_uid:event_data},
152 timestamps={descriptor_uid: [event_data[0]["time"]]},
153 seq_num=[1],
154 )
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2312, in compose_event_page(descriptor, event_counters, data, timestamps, seq_num, filled, uid, time, validate)
2297 def compose_event_page(
2298 *,
2299 descriptor: EventDescriptor,
(...) 2307 validate: bool = True,
2308 ) -> EventPage:
2309 """
2310 Here for backwards compatibility, the Compose class is prefered.
2311 """
-> 2312 return ComposeEventPage(descriptor, event_counters)(
2313 data,
2314 timestamps,
2315 seq_num=seq_num,
2316 filled=filled,
2317 uid=uid,
2318 time=time,
2319 validate=validate,
2320 )
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2272, in ComposeEventPage.__call__(self, data, timestamps, seq_num, filled, uid, time, validate)
2263 if validate:
2264 schema_validators[DocumentNames.event_page].validate(doc)
2266 if not (
2267 set(
2268 keys_without_stream_keys(
2269 self.descriptor["data_keys"], self.descriptor["data_keys"]
2270 )
2271 )
-> 2272 == set(keys_without_stream_keys(data, self.descriptor["data_keys"]))
2273 == set(
2274 keys_without_stream_keys(timestamps, self.descriptor["data_keys"])
2275 )
2276 ):
2277 raise EventModelValidationError(
2278 'These sets of keys must match (other than "STREAM:" keys):\n'
2279 "event['data'].keys(): {}\n"
(...) 2285 )
2286 )
2287 if set(filled) - set(data):
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2328, in keys_without_stream_keys(dictionary, descriptor_data_keys)
2323 def keys_without_stream_keys(dictionary, descriptor_data_keys):
2324 return [
2325 key
2326 for key in dictionary.keys()
2327 if (
-> 2328 "external" not in descriptor_data_keys[key]
2329 or descriptor_data_keys[key]["external"] != "STREAM:"
2330 )
2331 ]
KeyError: 'b2c9a782-533e-42f2-8ace-568244a6c7cc'
In [2]:
Do you really want to exit ([y]/n)?
(mfx-opt-env) jennefermaldonado in ~/src/mfx on focus ● λ ipython
Python 3.12.9 | packaged by conda-forge | (main, Mar 4 2025, 22:44:42) [Clang 18.1.8 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.1.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use `files = !ls *.png`
In [1]: %run -i run.py
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/src/mfx/run.py:148
145 from event_model import compose_event_page
147 descriptor_uid = descriptor["uid"]
--> 148 new_doc = compose_event_page(
149 descriptor=descriptor,
150 event_counters={descriptor_uid:[1]},
151 data={descriptor_uid:event_data},
152 timestamps={descriptor_uid: [event_data[0]["time"]]},
153 seq_num=[1],
154 filled={descriptor_uid: [False]},
155 )
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2312, in compose_event_page(descriptor, event_counters, data, timestamps, seq_num, filled, uid, time, validate)
2297 def compose_event_page(
2298 *,
2299 descriptor: EventDescriptor,
(...) 2307 validate: bool = True,
2308 ) -> EventPage:
2309 """
2310 Here for backwards compatibility, the Compose class is prefered.
2311 """
-> 2312 return ComposeEventPage(descriptor, event_counters)(
2313 data,
2314 timestamps,
2315 seq_num=seq_num,
2316 filled=filled,
2317 uid=uid,
2318 time=time,
2319 validate=validate,
2320 )
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2272, in ComposeEventPage.__call__(self, data, timestamps, seq_num, filled, uid, time, validate)
2263 if validate:
2264 schema_validators[DocumentNames.event_page].validate(doc)
2266 if not (
2267 set(
2268 keys_without_stream_keys(
2269 self.descriptor["data_keys"], self.descriptor["data_keys"]
2270 )
2271 )
-> 2272 == set(keys_without_stream_keys(data, self.descriptor["data_keys"]))
2273 == set(
2274 keys_without_stream_keys(timestamps, self.descriptor["data_keys"])
2275 )
2276 ):
2277 raise EventModelValidationError(
2278 'These sets of keys must match (other than "STREAM:" keys):\n'
2279 "event['data'].keys(): {}\n"
(...) 2285 )
2286 )
2287 if set(filled) - set(data):
File /opt/homebrew/anaconda3/envs/mfx-opt-env/lib/python3.12/site-packages/event_model/__init__.py:2328, in keys_without_stream_keys(dictionary, descriptor_data_keys)
2323 def keys_without_stream_keys(dictionary, descriptor_data_keys):
2324 return [
2325 key
2326 for key in dictionary.keys()
2327 if (
-> 2328 "external" not in descriptor_data_keys[key]
2329 or descriptor_data_keys[key]["external"] != "STREAM:"
2330 )
2331 ]
KeyError: 'b2c9a782-533e-42f2-8ace-568244a6c7cc' |
Collaborator
Author
@mrakitin I think the descriptor has to be a dictionary and not a uid, see here: https://blueskyproject.io/bluesky/main/event_descriptors.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Starting development for #148, will update as the day goes on