feat(components): add Bilig WorkPaper formula readback#13309
feat(components): add Bilig WorkPaper formula readback#13309gregkonush wants to merge 6 commits into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughA new ChangesBilig Component Integration
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 7 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 1
🧹 Nitpick comments (1)
src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py (1)
37-127: ⚡ Quick winAdd negative-path tests for input/API failure handling.
Current coverage is success-only. Please add at least one validation-failure case and one unverified-response case so error handling remains regression-safe.
Example additions
+import pytest + @@ def test_component_returns_compact_formula_readback_proof(monkeypatch): @@ assert component.status == result.data + + +def test_call_bilig_forecast_rejects_non_http_base_url(): + with pytest.raises(ValueError, match="base_url must start with http:// or https://"): + call_bilig_forecast( + base_url="ftp://bilig.example", + sheet_name="Inputs", + address="B3", + value=0.4, + timeout=7, + ) + + +def test_component_returns_error_when_response_is_unverified(monkeypatch): + def fake_client(*, timeout, headers): + return FakeClient( + captured={}, + timeout=timeout, + headers=headers, + response=FakeResponse({"verified": False}), + ) + + monkeypatch.setattr("lfx.components.bilig.workpaper_formula_readback.httpx.Client", fake_client) + component = BiligWorkPaperFormulaReadbackComponent() + component.base_url = "https://bilig.example" + component.sheet_name = "Inputs" + component.address = "B3" + component.value = 0.4 + component.timeout = 7 + + result = component.verify_formula_readback() + assert "error" in result.data + assert isinstance(component.status, str)As per coding guidelines: "Consider including edge cases and error conditions for comprehensive test coverage" and "Verify tests cover both positive and negative scenarios where appropriate".
🤖 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 `@src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py` around lines 37 - 127, Add negative-path tests: create one test that simulates validation failure by calling call_bilig_forecast or BiligWorkPaperFormulaReadbackComponent with invalid inputs (e.g., missing/empty sheet_name or malformed address) and assert the function/component raises the expected ValidationError or returns an error status; and create another test that uses FakeClient/FakeResponse to return {"verified": False, ...} from call_bilig_forecast (or from the component via verify_formula_readback) and assert the component returns/raises the unverified-path behavior your code implements (e.g., result["verified"] is False or component.status shows an error). Locate helpers around call_bilig_forecast and BiligWorkPaperFormulaReadbackComponent.verify_formula_readback to patch httpx.Client and reuse FakeClient/FakeResponse to craft the failing responses.
🤖 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 `@src/lfx/src/lfx/components/bilig/workpaper_formula_readback.py`:
- Around line 111-113: The error currently raises ValueError with the entire
upstream payload (parsed) which can leak sensitive data; change the raise to
include only safe, minimal info (e.g., verification status and a non-sensitive
identifier) instead of the full payload: replace msg = f"Unverified WorkPaper
response: {parsed}" and raise ValueError(msg) with something like raising
ValueError(f"Unverified WorkPaper response (verified={parsed.get('verified')})
for workpaper_id={parsed.get('workpaper_id') or parsed.get('id') or 'unknown'}")
or a similar safe summary, ensuring you reference the same parsed variable and
use the existing raise ValueError call.
---
Nitpick comments:
In `@src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py`:
- Around line 37-127: Add negative-path tests: create one test that simulates
validation failure by calling call_bilig_forecast or
BiligWorkPaperFormulaReadbackComponent with invalid inputs (e.g., missing/empty
sheet_name or malformed address) and assert the function/component raises the
expected ValidationError or returns an error status; and create another test
that uses FakeClient/FakeResponse to return {"verified": False, ...} from
call_bilig_forecast (or from the component via verify_formula_readback) and
assert the component returns/raises the unverified-path behavior your code
implements (e.g., result["verified"] is False or component.status shows an
error). Locate helpers around call_bilig_forecast and
BiligWorkPaperFormulaReadbackComponent.verify_formula_readback to patch
httpx.Client and reuse FakeClient/FakeResponse to craft the failing responses.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8e0d3101-7d58-41be-8194-7d30d63f8fae
📒 Files selected for processing (5)
src/lfx/src/lfx/components/__init__.pysrc/lfx/src/lfx/components/bilig/__init__.pysrc/lfx/src/lfx/components/bilig/workpaper_formula_readback.pysrc/lfx/tests/unit/components/bilig/__init__.pysrc/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.py
|
CI note: the current red frontend check did not reach the Bilig component code. The failed shard died during The branch already includes the CodeRabbit safety fix and negative-path tests for unverified upstream responses. Local targeted validation from the PR branch is green: Result: ruff check passed, ruff format check passed, and the Bilig unit test file passed with |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
CI triage: the current red checks look unrelated to this PR code. Both failed jobs died during The coverage merge failure follows from that shard not producing its blob report. I tried to rerun only the failed jobs, but GitHub requires repository admin rights for that action. Could a maintainer rerun the failed jobs when convenient? |
Adds a new
BiligWorkPaperFormulaReadbackComponentunderlfx.components.bilig.The component gives Langflow builders one focused canvas node for spreadsheet-backed formula verification: write an input cell through a configured Bilig WorkPaper API, recalculate formulas, and return compact JSON proof that the computed output changed and persisted. It defaults to the hosted Bilig demo endpoint and keeps
base_urlconfigurable for self-hosted/private WorkPaper deployments.Implementation details:
src/lfx/src/lfx/components/biligsheet_name,address, andvaluebase_urlandtimeoutsettingshttpxrequest path with explicit JSON proof validationValidation:
uv run --no-project --with ruff ruff check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/biliguv run --no-project --with ruff ruff format --check src/lfx/src/lfx/components/bilig src/lfx/tests/unit/components/biligPYTHONPATH=src/lfx/src uv run --no-project --with pytest --with pydantic --with langchain-core --with nanoid --with loguru --with pandas --with structlog --with platformdirs --with fastapi --with filelock --with aiofiles --with pillow --with docstring-parser --with cachetools --with emoji --with httpx python -m pytest src/lfx/tests/unit/components/bilig/test_workpaper_formula_readback.pyAlso verified the hosted Bilig endpoint returns
verified=true,after.expectedArr=96000, andrestoredMatchesAfter=true.