File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,6 @@ def main(argv: Sequence[str] | None = None) -> int:
4141 parser .print_usage ()
4242 print (f"ERROR: Failed to find plugin folder at { plugin_path !r} " )
4343 return 1
44- # TODO: Leave the warning enabled in the dev plugin wrapper
45- warnings .filterwarnings (
46- "ignore" , ".*the plugin API is not yet stable" , FutureWarning
47- )
4844 log_level = logging .DEBUG if args .debug else logging .INFO
4945 logging .basicConfig (level = log_level )
5046 if sys .platform == "win32" :
@@ -61,6 +57,9 @@ def main(argv: Sequence[str] | None = None) -> int:
6157 if not SetConsoleCtrlHandler (None , 0 ):
6258 print ("Failed to enable Ctrl-C events, termination may be abrupt" )
6359 if not args .dev :
60+ warnings .filterwarnings (
61+ "ignore" , ".*the plugin API is not yet stable" , FutureWarning
62+ )
6463 try :
6564 runner .run_plugin (plugin_path , allow_local_imports = True )
6665 except KeyboardInterrupt :
Original file line number Diff line number Diff line change 1717 _start_child_process ,
1818 _PLUGIN_STOP_TIMEOUT ,
1919)
20+ from lmstudio .plugin .runner import _PLUGIN_API_STABILITY_WARNING
21+
2022
2123_THIS_DIR = Path (__file__ ).parent .resolve ()
2224_PLUGIN_EXAMPLES_DIR = (_THIS_DIR / "../examples/plugins" ).resolve ()
@@ -110,7 +112,19 @@ def _plugin_case_id(plugin_path: Path) -> str:
110112@pytest .mark .parametrize ("plugin_path" , _get_plugin_paths (), ids = _plugin_case_id )
111113def test_plugin_execution (plugin_path : Path ) -> None :
112114 startup_lines , shutdown_lines , stderr_lines = _exec_and_interrupt (plugin_path )
115+ # Stderr should start with the API stability warning...
116+ warning_lines = [
117+ * _PLUGIN_API_STABILITY_WARNING .splitlines (keepends = True ),
118+ "\n " ,
119+ "warnings.warn(_PLUGIN_API_STABILITY_WARNING, FutureWarning)\n " ,
120+ ]
121+ for warning_line in warning_lines :
122+ stderr_line = stderr_lines .pop (0 )
123+ assert stderr_line .endswith (warning_line )
124+ # ... and then consist solely of logged information messages
113125 for log_line in stderr_lines :
114126 assert log_line .startswith ("INFO:" )
127+ # Startup should finish with the notification of how to terminate the dev plugin
115128 assert startup_lines [- 1 ].endswith ("Ctrl-C to terminate...\n " )
129+ # Shutdown should finish with a graceful shutdown notice from the plugin runner
116130 assert shutdown_lines [- 1 ] == "Plugin execution terminated by console interrupt\n "
You can’t perform that action at this time.
0 commit comments