Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IBEX plotting callback #18

Merged
merged 4 commits into from
Aug 28, 2024
Merged

Add IBEX plotting callback #18

merged 4 commits into from
Aug 28, 2024

Conversation

Tom-Willemsen
Copy link
Contributor

@Tom-Willemsen Tom-Willemsen commented Aug 19, 2024

#8

Docs

  • Ensure docs give enough information/pointers to documentation elsewhere for users to find out how to configure plots.
  • Ensure all the points in the ticket's acceptance criteria have been met.

To test this in a standalone session:

  • Ensure you are in the ibex_bluesky_core venv as per dev setup notes.
  • Ensure you have recently re-run python -m pip install -e .[dev] to pick up matplotlib and qt dependencies
  • Run python src\ibex_bluesky_core\demo_plan.py
  • A matplotlib Qt window should appear and be updated live during the plan.
  • A long running plan like bps.sleep(999) should be interruptible via ctrl-c.

To test this within the IBEX gui:

  • Rebuild your genie_python using the branch linked from Use epicscorelibs for python modules IBEX#8453
  • Run c:\instrument\apps\python3\python.exe -m pip install -e c:\instrument\dev\ibex_bluesky_core\
    • This installs ibex_bluesky_core into your genie_python environment (not a .venv)
  • Ensure IBEX is set up with blocks and DAE as per existing dev setup notes.
  • In the IBEX pydev scripting console run:
from ibex_bluesky_core.run_engine import get_run_engine
from ibex_bluesky_core.demo_plan import demo_plan
RE = get_run_engine()
RE(demo_plan())
  • A matplotlib window should appear and be updated live during the plan.
  • A long running plan like bps.sleep(999) should be interruptible via ctrl-c.

@jackbdoughty jackbdoughty self-requested a review August 28, 2024 10:52
@jackbdoughty
Copy link
Contributor

Looks good to me, plotting works as expected. One thing I have noticed though is that when you pause (Ctrl + C) a plan for the second time, in the pydev console, this causes an exception and I can't resume the plan again. Not sure if this is intentional or just on my machine? Also not sure how relevant this is to this ticket but think its worth saying.
Exception in thread Thread-6 (maybe_prompt_pause): Traceback (most recent call last): File "C:\Instrument\Apps\Python3\Lib\threading.py", line 1045, in _bootstrap_inner self.run() File "C:\Instrument\Apps\Python3\Lib\threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "C:\Instrument\Apps\Python3\Lib\site-packages\bluesky\utils\__init__.py", line 291, in maybe_prompt_pause self.RE.request_pause(False) File "C:\Instrument\Apps\Python3\Lib\site-packages\bluesky\run_engine.py", line 817, in request_pause return future.result() ^^^^^^^^^^^^^^^ File "C:\Instrument\Apps\Python3\Lib\concurrent\futures\_base.py", line 456, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "C:\Instrument\Apps\Python3\Lib\concurrent\futures\_base.py", line 401, in __get_result raise self._exception File "C:\Instrument\Apps\Python3\Lib\site-packages\bluesky\run_engine.py", line 835, in _request_pause_coro current_run.record_interruption("pause") File "C:\Instrument\Apps\Python3\Lib\site-packages\bluesky\bundlers.py", line 449, in record_interruption doc = self._interruptions_compose_event( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Instrument\Apps\Python3\Lib\site-packages\event_model\__init__.py", line 2312, in __call__ seq_num = self.event_counters[self.descriptor["name"]] ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'interruptions'

@Tom-Willemsen
Copy link
Contributor Author

@jackbdoughty can you check you have a recent GUI build? Pull main and run build.bat or update target platform in eclipse...

@jackbdoughty
Copy link
Contributor

It also might just be worth making it clearer to the user to do from ibex_bluesky_core.run_engine import get_run_engine RE = get_run_engine() to be able to call RE.resume(). As right now the message received after doing a ctrl + c is `Your RunEngine is entering a paused state. These are your options for changing
the state of the RunEngine:

RE.resume() Resume the plan.
RE.abort() Perform cleanup, then kill plan. Mark exit_stats='aborted'.
RE.stop() Perform cleanup, then kill plan. Mark exit_status='success'.
RE.halt() Emergency Stop: Do not perform cleanup --- just stop.`

@Tom-Willemsen
Copy link
Contributor Author

Tom-Willemsen commented Aug 28, 2024

Yeah that's a difference between run_demo_plan and demo_plan really.

I think the direction of travel is that IBEX will automatically create a RunEngine (by calling RE = get_run_engine()) as one of the standard GUI initialization commands - like we already have for setting matplotlib backends and importing g_p etc.

So then at the user level they would have access to the RE, and would be executing plans with something like:

RE(my_plan())

at the command-line (and not one of the "convenient" wrappers like run_demo_plan)

It'll soon be time to remove demo_plan entirely (in #15) so hopefully the confusion will go away at that point. But let's chat after lunch... it might be worth me getting rid of run_demo_plan() preemptively as part of this ticket.

@jackbdoughty jackbdoughty merged commit 7400685 into main Aug 28, 2024
9 checks passed
@jackbdoughty jackbdoughty deleted the 8_plotting_callback branch August 28, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants