Skip to content

Comments

Feature/pulsing inspect#43

Merged
reiase merged 2 commits intomainfrom
feature/pulsing_inspect
Jan 18, 2026
Merged

Feature/pulsing inspect#43
reiase merged 2 commits intomainfrom
feature/pulsing_inspect

Conversation

@reiase
Copy link
Contributor

@reiase reiase commented Jan 18, 2026

Overview:

Details:

Where should the reviewer start?

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

- 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

Import of 'json' is not used.

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.

Suggested changeset 1
python/pulsing/cli/actor_loader.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/python/pulsing/cli/actor_loader.py b/python/pulsing/cli/actor_loader.py
--- a/python/pulsing/cli/actor_loader.py
+++ b/python/pulsing/cli/actor_loader.py
@@ -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
EOF
@@ -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
Copilot is powered by AI and may make mistakes. Always verify output.

import importlib
import json
from typing import Any

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Any' is not used.

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.

Suggested changeset 1
python/pulsing/cli/actor_loader.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/python/pulsing/cli/actor_loader.py b/python/pulsing/cli/actor_loader.py
--- a/python/pulsing/cli/actor_loader.py
+++ b/python/pulsing/cli/actor_loader.py
@@ -2,7 +2,6 @@
 
 import importlib
 import json
-from typing import Any
 
 from pulsing.actor import Actor
 
EOF
@@ -2,7 +2,6 @@

import importlib
import json
from typing import Any

from pulsing.actor import Actor

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +144 to +154
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

Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.

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

Import of 'list_actors' is not used.

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.

Suggested changeset 1
tests/python/test_actor_list.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_actor_list.py b/tests/python/test_actor_list.py
--- a/tests/python/test_actor_list.py
+++ b/tests/python/test_actor_list.py
@@ -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
EOF
@@ -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
Copilot is powered by AI and may make mistakes. Always verify output.
"actor_id": str(inst.get("actor_id", "")),
}
actors_data.append(actor_data)
except Exception:

Check notice

Code scanning / CodeQL

Empty except Note test

'except' clause does nothing but pass and there is no explanatory comment.

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:
                    pass

with 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.

Suggested changeset 1
tests/python/test_actor_list.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_actor_list.py b/tests/python/test_actor_list.py
--- a/tests/python/test_actor_list.py
+++ b/tests/python/test_actor_list.py
@@ -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()
EOF
@@ -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()
Copilot is powered by AI and may make mistakes. Always verify output.
"""

import pytest
from unittest.mock import patch, MagicMock, AsyncMock

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'patch' is not used.
Import of 'MagicMock' is not used.
Import of 'AsyncMock' is not used.

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.

Suggested changeset 1
tests/python/test_cli_actor.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_cli_actor.py b/tests/python/test_cli_actor.py
--- a/tests/python/test_cli_actor.py
+++ b/tests/python/test_cli_actor.py
@@ -5,7 +5,6 @@
 """
 
 import pytest
-from unittest.mock import patch, MagicMock, AsyncMock
 
 from pulsing.cli.__main__ import actor as actor_cli
 
EOF
@@ -5,7 +5,6 @@
"""

import pytest
from unittest.mock import patch, MagicMock, AsyncMock

from pulsing.cli.__main__ import actor as actor_cli

Copilot is powered by AI and may make mistakes. Always verify output.
"""

import io
import json

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'json' is not used.

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.

Suggested changeset 1
tests/python/test_cli_inspect.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_cli_inspect.py b/tests/python/test_cli_inspect.py
--- a/tests/python/test_cli_inspect.py
+++ b/tests/python/test_cli_inspect.py
@@ -5,7 +5,6 @@
 """
 
 import io
-import json
 import sys
 from unittest.mock import patch, MagicMock
 
EOF
@@ -5,7 +5,6 @@
"""

import io
import json
import sys
from unittest.mock import patch, MagicMock

Copilot is powered by AI and may make mistakes. Always verify output.
import io
import json
import sys
from unittest.mock import patch, MagicMock

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'MagicMock' is not used.

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, replace from unittest.mock import patch, MagicMock with from unittest.mock import patch.
  • No new methods, imports, or definitions are needed.
Suggested changeset 1
tests/python/test_cli_inspect.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_cli_inspect.py b/tests/python/test_cli_inspect.py
--- a/tests/python/test_cli_inspect.py
+++ b/tests/python/test_cli_inspect.py
@@ -7,7 +7,7 @@
 import io
 import json
 import sys
-from unittest.mock import patch, MagicMock
+from unittest.mock import patch
 
 import pytest
 
EOF
@@ -7,7 +7,7 @@
import io
import json
import sys
from unittest.mock import patch, MagicMock
from unittest.mock import patch

import pytest

Copilot is powered by AI and may make mistakes. Always verify output.
import sys
from unittest.mock import patch, MagicMock

import pytest

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'pytest' is not used.

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.

Suggested changeset 1
tests/python/test_cli_inspect.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_cli_inspect.py b/tests/python/test_cli_inspect.py
--- a/tests/python/test_cli_inspect.py
+++ b/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,
EOF
@@ -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,
Copilot is powered by AI and may make mistakes. Always verify output.
_print_actors_table,
http_get_sync,
)
import pytest

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'pytest' is not used.

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.

Suggested changeset 1
tests/python/test_rest_api.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/python/test_rest_api.py b/tests/python/test_rest_api.py
--- a/tests/python/test_rest_api.py
+++ b/tests/python/test_rest_api.py
@@ -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
 
 
EOF
@@ -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


Copilot is powered by AI and may make mistakes. Always verify output.
@reiase reiase merged commit a9584e4 into main Jan 18, 2026
13 checks passed
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 46.59574% with 251 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
python/pulsing/cli/inspect.py 52.97% 166 Missing ⚠️
python/pulsing/cli/actors.py 2.98% 65 Missing ⚠️
python/pulsing/cli/actor_loader.py 23.80% 16 Missing ⚠️
python/pulsing/cli/__main__.py 85.71% 4 Missing ⚠️
Files with missing lines Coverage Δ
python/pulsing/__init__.py 100.00% <100.00%> (ø)
python/pulsing/cli/__main__.py 76.59% <85.71%> (+76.59%) ⬆️
python/pulsing/cli/actor_loader.py 23.80% <23.80%> (ø)
python/pulsing/cli/actors.py 4.22% <2.98%> (+4.22%) ⬆️
python/pulsing/cli/inspect.py 52.94% <52.97%> (+52.94%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants