Skip to content

Add beam.focus() action #171

Draft
jennmald wants to merge 9 commits intopcdshub:run23from
jennmald:focus
Draft

Add beam.focus() action #171
jennmald wants to merge 9 commits intopcdshub:run23from
jennmald:focus

Conversation

@jennmald
Copy link
Collaborator

Starting development for #148, will update as the day goes on

@jennmald
Copy link
Collaborator Author

@mrakitin what we are stuck on:

Details
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 )

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'

@fredericpoitevin fredericpoitevin linked an issue Apr 24, 2025 that may be closed by this pull request
@fredericpoitevin fredericpoitevin added this to the auto_beam milestone Apr 24, 2025
@fredericpoitevin fredericpoitevin added the automfx Adds to the AutoMFX Project label Apr 24, 2025
@github-project-automation github-project-automation bot moved this to Todo in AutoMFX Apr 24, 2025
@fredericpoitevin fredericpoitevin moved this from Todo to In Progress in AutoMFX Apr 24, 2025
@jennmald
Copy link
Collaborator Author

@mrakitin what we are stuck on:

@mrakitin I think the descriptor has to be a dictionary and not a uid, see here: https://blueskyproject.io/bluesky/main/event_descriptors.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automfx Adds to the AutoMFX Project

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

add beam.focus() action

4 participants