feat(cache): add read-only cache inspection command (sebs resources inspect) - #310
feat(cache): add read-only cache inspection command (sebs resources inspect)#310sanskar-singh-2403 wants to merge 1 commit into
Conversation
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesCache inspection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant resources_inspect
participant Cache
participant CachedJSON
Operator->>resources_inspect: invoke resources inspect
resources_inspect->>Cache: load cached benchmarks and resources
Cache->>CachedJSON: read config.json and cloud cache files
CachedJSON-->>Cache: return cached metadata
Cache-->>resources_inspect: return inspection results
resources_inspect-->>Operator: render JSON or Rich tables
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sebs/cache.py`:
- Around line 1004-1006: Update add_code_package and update_code_package to
validate Docker availability for container packages at method entry, before
creating cache directories or copying/deleting code. Replace the Docker-client
assert with a RuntimeError, and move cache_dir creation until after this
validation so failures cannot leave partial cache entries.
In `@sebs/cli.py`:
- Around line 927-929: Update the emptiness check in the allocated-resource loop
to also consider the `allocated_ports` field, so entries containing only ports
are retained; continue skipping entries only when resources, storage buckets,
and allocated ports are all absent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d5e5aa5c-5045-432a-95fa-71c5e9e61254
📒 Files selected for processing (3)
sebs/cache.pysebs/cli.pytests/test_cache_inspect.py
e242c16 to
74db93e
Compare
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
sebs/cache.py (1)
525-635: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsolidate the hardcoded cloud list into
SUPPORTED_CLOUDS.
SUPPORTED_CLOUDSduplicates the["azure", "aws", "gcp", "openwhisk", "local"]literal already used inload_config(line 267) andshutdown(line 315). Now there are three copies of the same list; a future change (adding/removing a supported cloud) risks silently missing one of them.♻️ Proposed consolidation
def load_config(self) -> None: with self._lock: - for cloud in ["azure", "aws", "gcp", "openwhisk", "local"]: + for cloud in self.SUPPORTED_CLOUDS: cloud_config_file = os.path.join(self.cache_dir, "{}.json".format(cloud))def shutdown(self) -> None: if self.config_updated: with self._lock: - for cloud in ["azure", "aws", "gcp", "openwhisk", "local"]: + for cloud in self.SUPPORTED_CLOUDS: if cloud in self.cached_config:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sebs/cache.py` around lines 525 - 635, Reuse the class-level SUPPORTED_CLOUDS constant in load_config and shutdown instead of their duplicated hardcoded cloud lists. Update those cloud-iteration or validation paths to reference SUPPORTED_CLOUDS so future supported-cloud changes apply consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@sebs/cache.py`:
- Around line 525-635: Reuse the class-level SUPPORTED_CLOUDS constant in
load_config and shutdown instead of their duplicated hardcoded cloud lists.
Update those cloud-iteration or validation paths to reference SUPPORTED_CLOUDS
so future supported-cloud changes apply consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a55b6c63-32e0-4295-9b2d-a578aa8109b3
📒 Files selected for processing (3)
sebs/cache.pysebs/cli.pytests/test_cache_inspect.py
Add `sebs resources inspect` to visualize the on-disk cache without
contacting any cloud provider or requiring a Docker daemon.
- Extend sebs.cache.Cache with two read-only helpers:
- get_deployed_benchmarks(): flattens per-benchmark config.json files
into rows of (benchmark, platform, language, packaging, functions,
triggers, storage, nosql).
- get_allocated_resources(): reads the per-cloud files (aws.json,
local.json, ...) for resources_id, region, storage buckets, and
locally allocated ports.
- Make Cache docker_client optional so read-only consumers can open a
cache without a running Docker daemon; guard the container-caching
paths with an assertion.
- Add the `resources inspect` CLI command with a rich table view and a
--json output mode, plus an optional --deployment platform filter.
- Add offline unit tests that build a synthetic cache directory.
Addresses spcl#306.
74db93e to
fb17cbc
Compare
|
@CodeRabbit review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
sebs/cache.py (2)
528-636: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify redundant key-check before dict access.
Ruff (RUF019) flags the
"containers" in lang_cfg and lang_cfg["containers"]/"code_package" in lang_cfg and lang_cfg["code_package"]patterns at lines 608 and 610 —dict.get(...)already returns a falsy default, so the membership check is redundant.♻️ Suggested tweak
- if "containers" in lang_cfg and lang_cfg["containers"]: + if lang_cfg.get("containers"): packaging = "container" - elif "code_package" in lang_cfg and lang_cfg["code_package"]: + elif lang_cfg.get("code_package"): packaging = "code_package"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sebs/cache.py` around lines 528 - 636, Update packaging detection in get_deployed_benchmarks to use lang_cfg.get("containers") and lang_cfg.get("code_package") directly as truthiness checks, removing the redundant membership tests while preserving the existing container, code_package, and unknown precedence.Source: Linters/SAST tools
161-163: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueClass-level mutable list attribute.
Ruff flags
SUPPORTED_CLOUDSas a mutable default at class scope (RUF012). It's only iterated today, but annotating asClassVar(or using aTuple) makes the immutability intent explicit and future-proofs against accidental in-place mutation.♻️ Suggested tweak
- # Cloud platforms that own a per-cloud cache file (`<cloud>.json`). - SUPPORTED_CLOUDS: List[str] = ["azure", "aws", "gcp", "openwhisk", "local"] + # Cloud platforms that own a per-cloud cache file (`<cloud>.json`). + SUPPORTED_CLOUDS: ClassVar[Tuple[str, ...]] = ("azure", "aws", "gcp", "openwhisk", "local")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sebs/cache.py` around lines 161 - 163, Update the SUPPORTED_CLOUDS class attribute to declare class-level ownership and prevent mutable-default linting, using ClassVar with an immutable tuple or another immutable representation. Preserve the existing cloud values and iteration behavior.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@sebs/cache.py`:
- Around line 528-636: Update packaging detection in get_deployed_benchmarks to
use lang_cfg.get("containers") and lang_cfg.get("code_package") directly as
truthiness checks, removing the redundant membership tests while preserving the
existing container, code_package, and unknown precedence.
- Around line 161-163: Update the SUPPORTED_CLOUDS class attribute to declare
class-level ownership and prevent mutable-default linting, using ClassVar with
an immutable tuple or another immutable representation. Preserve the existing
cloud values and iteration behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 83639dca-bfae-41e3-906d-26624b4eb8ad
📒 Files selected for processing (3)
sebs/cache.pysebs/cli.pytests/test_cache_inspect.py
|
@mcopik this pr is ready to be reviewed, let me know your thoughts, Thanks! |
Summary
Adds
sebs resources inspect, a read-only command that visualizes theon-disk cache without contacting any cloud provider or requiring a Docker
daemon. Addresses #306.
Per the discussion on the issue, this extends the existing
sebs.cache.CacheAPI rather than introducing a separate inspection layer,and lives as a subcommand under the existing
resourcescommand group.What it shows
(container vs code_package), number of functions, and trigger types.
resources_id, region, storagebucket count, and locally allocated ports.
Changes
sebs.cache.Cachewith two read-only helpers:get_deployed_benchmarks(): flattens the per-benchmarkconfig.jsonfiles into rows of (benchmark, platform, language, packaging,
functions, triggers, storage, nosql).
get_allocated_resources(): reads the per-cloud files (aws.json,local.json, ...) forresources_id, region, storage buckets, andlocally allocated ports.
Cachedocker_clientoptional so read-only consumers can open acache without a running Docker daemon; guard the container-caching paths
with an assertion.
resources inspectCLI command with a rich table view and a--jsonoutput mode, plus an optional--deploymentplatform filter.Usage
Test plan
--deploymentfilter against a real cacheAddresses #306.