From 24e71ddf928ff3a479959230f85c2839ebf11980 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 16 Jun 2026 15:45:37 +0100 Subject: [PATCH 1/4] better docstrings for waitfor methods spotted these in the training session --- src/genie_python/genie.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/genie_python/genie.py b/src/genie_python/genie.py index 0b22df9..a1bad50 100644 --- a/src/genie_python/genie.py +++ b/src/genie_python/genie.py @@ -524,18 +524,30 @@ def waitfor_block( lowlimit: waits for the block to be >= this value (numeric only) highlimit: waits for the block to be <= this value (numeric only) maxwait: wait no longer that the specified number of seconds - early_exit: stop waiting if the exception evaluates to True + early_exit: A callable function, continously called, which will stop waiting if it returns True quiet (bool, optional): suppress normal output messages to the console Examples: >>> waitfor_block("myblock", value=123) + + wait for a block's value to be 123 + >>> waitfor_block("myblock", value=True, maxwait=15) + + wait for a block's value to be True, for up to 15 seconds, otherwise continue + >>> waitfor_block("myblock", lowlimit=100, highlimit=110) >>> waitfor_block("myblock", highlimit=1.0, maxwait=60) + + Wait for a block's value to fall between the specified limits + >>> waitfor_block( ... "myblock", value=123, early_exit=lambda: cget("myblock_limit_reached")["value"] != 0 ... ) + + Wait until either the value is either 123 (explicitly) or if the value of "myblock_limit_reached" is not 0 + """ if _genie_api.waitfor is None: # pyright: ignore # pyright doesn't recognise that waitfor can be None @@ -575,10 +587,18 @@ def waitfor_time( quiet (bool, optional): suppress normal output messages to the console Examples: - + >>> waitfor_time(seconds=10) + + Waits for 10 seconds + >>> waitfor_time(hours=1, minutes=30, seconds=15) + + Waits for 1 hour, 30 minutes and 15 seconds + >>> waitfor_time(time="1:30:15") + + Waits until 1:30:15 """ if all(t is None for t in (seconds, minutes, hours, time)): raise TypeError( @@ -610,6 +630,7 @@ def waitfor_frames(frames: int | None = None, quiet: bool = False) -> None: Example: >>> waitfor_frames(4000) + waits for 4000 frames """ if frames is None: raise TypeError( From a44b9fa0954f63a551eb7d2ff11ba8f1eb79d793 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 16 Jun 2026 15:50:15 +0100 Subject: [PATCH 2/4] ruff --- src/genie_python/genie.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/genie_python/genie.py b/src/genie_python/genie.py index a1bad50..d55d5be 100644 --- a/src/genie_python/genie.py +++ b/src/genie_python/genie.py @@ -524,30 +524,31 @@ def waitfor_block( lowlimit: waits for the block to be >= this value (numeric only) highlimit: waits for the block to be <= this value (numeric only) maxwait: wait no longer that the specified number of seconds - early_exit: A callable function, continously called, which will stop waiting if it returns True + early_exit: A continuously called function which will interrupt waiting if it returns True quiet (bool, optional): suppress normal output messages to the console Examples: >>> waitfor_block("myblock", value=123) - + wait for a block's value to be 123 - + >>> waitfor_block("myblock", value=True, maxwait=15) wait for a block's value to be True, for up to 15 seconds, otherwise continue - + >>> waitfor_block("myblock", lowlimit=100, highlimit=110) >>> waitfor_block("myblock", highlimit=1.0, maxwait=60) Wait for a block's value to fall between the specified limits - + >>> waitfor_block( ... "myblock", value=123, early_exit=lambda: cget("myblock_limit_reached")["value"] != 0 ... ) - Wait until either the value is either 123 (explicitly) or if the value of "myblock_limit_reached" is not 0 - + Wait until either the value is either 123 (explicitly) + or if the value of "myblock_limit_reached" is not 0 + """ if _genie_api.waitfor is None: # pyright: ignore # pyright doesn't recognise that waitfor can be None @@ -587,17 +588,17 @@ def waitfor_time( quiet (bool, optional): suppress normal output messages to the console Examples: - + >>> waitfor_time(seconds=10) - + Waits for 10 seconds - + >>> waitfor_time(hours=1, minutes=30, seconds=15) - + Waits for 1 hour, 30 minutes and 15 seconds - + >>> waitfor_time(time="1:30:15") - + Waits until 1:30:15 """ if all(t is None for t in (seconds, minutes, hours, time)): @@ -819,7 +820,7 @@ def waitfor_move(*blocks: str, **kwargs: int | None) -> None: @log_command_and_handle_exception def get_pv( name: str, to_string: bool = False, is_local: bool = False, use_numpy: bool = False -) -> Any: +) -> PVValue: """ Get the value for the specified PV. From 000a512dee90753fa8c18447ffe6763af138909e Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 16 Jun 2026 15:53:42 +0100 Subject: [PATCH 3/4] revert type hint addition --- src/genie_python/genie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/genie_python/genie.py b/src/genie_python/genie.py index d55d5be..5ad9b12 100644 --- a/src/genie_python/genie.py +++ b/src/genie_python/genie.py @@ -820,7 +820,7 @@ def waitfor_move(*blocks: str, **kwargs: int | None) -> None: @log_command_and_handle_exception def get_pv( name: str, to_string: bool = False, is_local: bool = False, use_numpy: bool = False -) -> PVValue: +) -> Any: # noqa: ANN401 """ Get the value for the specified PV. From de730a231dffab4b536f8724bbfd9e8dbc39aa49 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 16 Jun 2026 17:23:12 +0100 Subject: [PATCH 4/4] Update src/genie_python/genie.py Co-authored-by: Tom Willemsen --- src/genie_python/genie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/genie_python/genie.py b/src/genie_python/genie.py index 5ad9b12..851ce74 100644 --- a/src/genie_python/genie.py +++ b/src/genie_python/genie.py @@ -599,7 +599,7 @@ def waitfor_time( >>> waitfor_time(time="1:30:15") - Waits until 1:30:15 + Waits for 1 hour, 30 minutes and 15 seconds """ if all(t is None for t in (seconds, minutes, hours, time)): raise TypeError(