Conversation
- Introduced `pulsing inspect` command for lightweight observation of actor systems via HTTP, replacing the deprecated `pulsing actor list`. - Added subcommands for inspecting cluster status, actor distribution, metrics, and real-time state changes. - Updated documentation to reflect new command structure and usage examples. - Created demo scripts and README files to facilitate user understanding and showcase inspect capabilities. - Removed legacy actor list command and refactored related tests to align with the new inspect functionality.
…nctionality - Updated the `pulsing actor` command to require full class paths for actor types, improving clarity and flexibility in actor instantiation. - Introduced a generic actor loader to dynamically load and instantiate actor classes based on user-defined parameters. - Enhanced documentation and examples for starting actors, including support for multiple workers and detailed constructor parameter handling. - Removed deprecated subcommands and streamlined the CLI interface for better usability. - Updated tests to ensure coverage for new functionality and error handling in the actor command.
| """Generic Actor loader - dynamically load and instantiate Actor classes""" | ||
|
|
||
| import importlib | ||
| import json |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
In general, unused-import problems are fixed by deleting the import statement (or by updating the code to actually use the imported symbol if it was omitted accidentally). To avoid changing functionality, we should only remove imports that are truly unused in the shown code.
Here, json is imported on line 4 but never referenced. The best fix is to remove just that line from python/pulsing/cli/actor_loader.py, leaving all other imports and code unchanged. No new methods, imports, or definitions are needed.
| @@ -1,7 +1,6 @@ | ||
| """Generic Actor loader - dynamically load and instantiate Actor classes""" | ||
|
|
||
| import importlib | ||
| import json | ||
| from typing import Any | ||
|
|
||
| from pulsing.actor import Actor |
|
|
||
| import importlib | ||
| import json | ||
| from typing import Any |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix an unused import, you remove the specific imported name (or the entire import statement) so that only actually used symbols are imported. This reduces unnecessary dependencies and makes the code clearer.
In this file, Any from typing is not used anywhere, so the best fix is to delete the line from typing import Any altogether. No other code changes are needed. Specifically, in python/pulsing/cli/actor_loader.py, remove line 5 that imports Any. No new methods, imports, or definitions are required.
| @@ -2,7 +2,6 @@ | ||
|
|
||
| import importlib | ||
| import json | ||
| from typing import Any | ||
|
|
||
| from pulsing.actor import Actor | ||
|
|
| def inspect_actors( | ||
| seeds: list[str] | None = None, | ||
| endpoint: str | None = None, | ||
| timeout: float = 10.0, | ||
| best_effort: bool = False, | ||
| top: int | None = None, | ||
| filter: str | None = None, | ||
| all_actors: bool = False, | ||
| json_output: bool = False, | ||
| detailed: bool = False, | ||
| ): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
Copilot Autofix
AI about 1 month ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| from pulsing.actor import init, remote, get_system | ||
| from pulsing.cli.actor_list import list_actors_impl | ||
| import json | ||
| from pulsing.actor import init, remote, get_system, list_actors |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the problem, remove the unused symbol list_actors from the import statement so that only actually used names are imported. This eliminates an unnecessary dependency and aligns the imports with the code’s behavior.
Concretely, in tests/python/test_actor_list.py at the top of the file, update the line from pulsing.actor import init, remote, get_system, list_actors to remove list_actors, leaving only init, remote, and get_system. No other code changes, new methods, or imports are required.
| @@ -3,7 +3,7 @@ | ||
| import asyncio | ||
| import pytest | ||
| import json | ||
| from pulsing.actor import init, remote, get_system, list_actors | ||
| from pulsing.actor import init, remote, get_system | ||
| from pulsing.cli.inspect import _print_actors_table | ||
| import io | ||
| import sys |
| "actor_id": str(inst.get("actor_id", "")), | ||
| } | ||
| actors_data.append(actor_data) | ||
| except Exception: |
Check notice
Code scanning / CodeQL
Empty except Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
In general, an empty except should be replaced by handling the exception in a meaningful way: at minimum logging or re-raising, or catching a more specific exception type. In this test, we likely want the loop over actors to continue even if querying instances for one actor fails, but we should not silently drop the error. The least invasive fix is to log the exception to standard error (or use pytest’s fail if we want the test to error) while still skipping that actor, and to add a brief comment documenting why we do not re-raise.
The best fix here without changing existing functionality is: keep the broad except Exception but add a short comment explaining that individual actor instance queries are best-effort, and log the exception using Python’s standard logging module. This preserves the current behavior of not breaking the test due to one failure, but removes the “does nothing but pass” issue and makes debugging easier. Concretely, in tests/python/test_actor_list.py, around lines 75–76 we replace:
except Exception:
passwith something like:
except Exception as exc:
# Best-effort collection: log and skip actors whose instances cannot be listed
import logging
logging.getLogger(__name__).warning(
"Failed to get named instances for actor %r: %s", name, exc
)This introduces a dependency on the standard library logging module only within this small block (allowed per the instructions) and keeps the rest of the function unchanged.
| @@ -72,8 +72,12 @@ | ||
| "actor_id": str(inst.get("actor_id", "")), | ||
| } | ||
| actors_data.append(actor_data) | ||
| except Exception: | ||
| pass | ||
| except Exception as exc: | ||
| # Best-effort collection: log and skip actors whose instances cannot be listed | ||
| import logging | ||
| logging.getLogger(__name__).warning( | ||
| "Failed to get named instances for actor %r: %s", name, exc | ||
| ) | ||
|
|
||
| _print_actors_table(actors_data) | ||
| output = buffer.getvalue() |
| """ | ||
|
|
||
| import pytest | ||
| from unittest.mock import patch, MagicMock, AsyncMock |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the problem, remove the unused imports so that only necessary dependencies remain. This avoids unnecessary coupling to unittest.mock and eliminates the static analysis warnings without affecting behavior.
Concretely, in tests/python/test_cli_actor.py, delete the line from unittest.mock import patch, MagicMock, AsyncMock. None of these names are used in the file, so no further code changes are required. The remaining imports (pytest and actor_cli) are sufficient for the tests as written.
| @@ -5,7 +5,6 @@ | ||
| """ | ||
|
|
||
| import pytest | ||
| from unittest.mock import patch, MagicMock, AsyncMock | ||
|
|
||
| from pulsing.cli.__main__ import actor as actor_cli | ||
|
|
| """ | ||
|
|
||
| import io | ||
| import json |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix an unused import, you simply remove the import statement for the unused module, ensuring that no code in the file actually depends on it.
In this case, the best fix is to delete the import json line near the top of tests/python/test_cli_inspect.py. No other code changes are needed, because no references to json appear in the shown code, and CodeQL confirms it is unused across the file. Concretely, remove line 8 (import json) and leave the remaining imports (io, sys, patch, MagicMock, pytest, and the pulsing.cli imports) unchanged.
| @@ -5,7 +5,6 @@ | ||
| """ | ||
|
|
||
| import io | ||
| import json | ||
| import sys | ||
| from unittest.mock import patch, MagicMock | ||
|
|
| import io | ||
| import json | ||
| import sys | ||
| from unittest.mock import patch, MagicMock |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix the problem, we should remove the unused imported symbol while preserving the used one. In general, unused imports are resolved by deleting them or narrowing the import to only the names that are actually used in the file.
The best minimal fix here is to edit tests/python/test_cli_inspect.py at the top of the file and change the line from unittest.mock import patch, MagicMock to import only patch. No other code changes are necessary since MagicMock is not used anywhere in the shown tests. This preserves existing test behavior and functionality while eliminating the unused import.
Concretely:
- In
tests/python/test_cli_inspect.py, on line 10, replacefrom unittest.mock import patch, MagicMockwithfrom unittest.mock import patch. - No new methods, imports, or definitions are needed.
| @@ -7,7 +7,7 @@ | ||
| import io | ||
| import json | ||
| import sys | ||
| from unittest.mock import patch, MagicMock | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
| import sys | ||
| from unittest.mock import patch, MagicMock | ||
|
|
||
| import pytest |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix an unused import, remove the import statement for the module that is not referenced anywhere in the file. This eliminates an unnecessary dependency and slightly simplifies the module.
In this specific case, the best fix is to delete the import pytest line (line 12) from tests/python/test_cli_inspect.py, leaving all other imports and code unchanged. This does not alter any existing functionality, because the test code that is shown does not use pytest directly; it relies on unittest.mock, io, json, and sys only.
Only a single edit is needed: remove the import pytest line from the imports section at the top of tests/python/test_cli_inspect.py.
| @@ -9,8 +9,6 @@ | ||
| import sys | ||
| from unittest.mock import patch, MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from pulsing.cli.__main__ import inspect as inspect_cli | ||
| from pulsing.cli.inspect import ( | ||
| inspect_cluster, |
| _print_actors_table, | ||
| http_get_sync, | ||
| ) | ||
| import pytest |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To fix an unused import, the general solution is to remove the import statement if the imported name is not used anywhere in the file. This both cleans up the code and removes an unnecessary dependency.
In this specific case, in tests/python/test_rest_api.py, line 7 (import pytest) can be deleted because the test code only uses the capsys fixture injected by pytest and never refers to the pytest module itself. Removing this line will not affect how the tests run, since pytest will still provide capsys automatically. No other changes are needed: no new methods, imports, or definitions are required.
| @@ -4,7 +4,6 @@ | ||
| This file is kept for backward compatibility testing of _print_actors_table. | ||
| """ | ||
|
|
||
| import pytest | ||
| from pulsing.cli.inspect import _print_actors_table | ||
|
|
||
|
|
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Overview:
Details:
Where should the reviewer start?
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)