Fix false condition of TFL_REMOTE_STORAGE_ENABLED#1412
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReplaces truthy checks of Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
api/transformerlab/shared/remote_workspace.py (1)
30-33: Consider centralizing the remote-storage flag parsing.The same parsing expression appears in three places. A small helper would keep behavior/messages consistent if semantics change again.
♻️ Refactor sketch
+def _is_remote_storage_enabled() -> bool: + return os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").strip().lower() == "true" ... - tfl_remote_storage_enabled = os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true" + tfl_remote_storage_enabled = _is_remote_storage_enabled() ... - tfl_remote_storage_enabled = os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true" + tfl_remote_storage_enabled = _is_remote_storage_enabled() ... - tfl_remote_storage_enabled = os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true" + tfl_remote_storage_enabled = _is_remote_storage_enabled()Also applies to: 191-193, 348-349
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/transformerlab/shared/remote_workspace.py` around lines 30 - 33, The code repeats the same environment-flag parsing expression (os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true") in multiple places; create a small helper function (e.g., is_tfl_remote_storage_enabled or parse_tfl_remote_storage_enabled) in remote_workspace.py and replace the repeated expressions with calls to that helper wherever tfl_remote_storage_enabled is computed (including the spots around the existing tfl_remote_storage_enabled variable and the occurrences at the other indicated locations); ensure the helper centralizes the default value and normalization logic so all callers get consistent behavior and messaging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/transformerlab/shared/remote_workspace.py`:
- Around line 191-195: Update the skip log/message to accurately reflect the
boolean semantics of TFL_REMOTE_STORAGE_ENABLED: instead of saying "is not set",
change the message for the tfl_remote_storage_enabled check (the variable
tfl_remote_storage_enabled derived from os.getenv("TFL_REMOTE_STORAGE_ENABLED",
"false")) to indicate that remote storage is disabled or the env var is not set
to "true" (e.g., "TFL_REMOTE_STORAGE_ENABLED is not 'true', skipping bucket
creation" or "TFL_REMOTE_STORAGE_ENABLED is false or unset, skipping bucket
creation"); apply the same change to the other identical branch around lines
348-351 so both print statements accurately reflect the condition.
---
Nitpick comments:
In `@api/transformerlab/shared/remote_workspace.py`:
- Around line 30-33: The code repeats the same environment-flag parsing
expression (os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true")
in multiple places; create a small helper function (e.g.,
is_tfl_remote_storage_enabled or parse_tfl_remote_storage_enabled) in
remote_workspace.py and replace the repeated expressions with calls to that
helper wherever tfl_remote_storage_enabled is computed (including the spots
around the existing tfl_remote_storage_enabled variable and the occurrences at
the other indicated locations); ensure the helper centralizes the default value
and normalization logic so all callers get consistent behavior and messaging.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
api/api.pyapi/pyproject.tomlapi/transformerlab/routers/compute_provider.pyapi/transformerlab/routers/experiment/documents.pyapi/transformerlab/routers/teams.pyapi/transformerlab/shared/models/user_model.pyapi/transformerlab/shared/remote_workspace.pylab-sdk/pyproject.tomllab-sdk/src/lab/dirs.py
| # Check if TFL_REMOTE_STORAGE_ENABLED is enabled | ||
| tfl_remote_storage_enabled = os.getenv("TFL_REMOTE_STORAGE_ENABLED", "false").lower() == "true" | ||
| if not tfl_remote_storage_enabled: | ||
| print("TFL_REMOTE_STORAGE_ENABLED is not set, skipping bucket creation") | ||
| return False |
There was a problem hiding this comment.
Update skip messaging to match new boolean semantics.
The current text says the variable “is not set”, but this branch also runs when it is set to values other than "true" (for example "false"). That can mislead operators during setup/debugging.
💡 Suggested message fix
- print("TFL_REMOTE_STORAGE_ENABLED is not set, skipping bucket creation")
+ print("TFL_REMOTE_STORAGE_ENABLED is not 'true', skipping bucket creation")
...
- print("TFL_REMOTE_STORAGE_ENABLED is not set, skipping bucket creation for existing teams")
- return (0, 0, ["TFL_REMOTE_STORAGE_ENABLED is not set"])
+ print("TFL_REMOTE_STORAGE_ENABLED is not 'true', skipping bucket creation for existing teams")
+ return (0, 0, ["TFL_REMOTE_STORAGE_ENABLED must be 'true' to create buckets"])Also applies to: 348-351
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@api/transformerlab/shared/remote_workspace.py` around lines 191 - 195, Update
the skip log/message to accurately reflect the boolean semantics of
TFL_REMOTE_STORAGE_ENABLED: instead of saying "is not set", change the message
for the tfl_remote_storage_enabled check (the variable
tfl_remote_storage_enabled derived from os.getenv("TFL_REMOTE_STORAGE_ENABLED",
"false")) to indicate that remote storage is disabled or the env var is not set
to "true" (e.g., "TFL_REMOTE_STORAGE_ENABLED is not 'true', skipping bucket
creation" or "TFL_REMOTE_STORAGE_ENABLED is false or unset, skipping bucket
creation"); apply the same change to the other identical branch around lines
348-351 so both print statements accurately reflect the condition.
Paragon SummaryThis pull request review analyzed 9 files and found no issues. The review examined code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools. Paragon did not detect any problems in the current diff. Proceed with merge after your normal checks. This PR fixes a logic error in the Key changes:
Confidence score: 5/5
9 files reviewed, 0 comments Tip: |
Summary by CodeRabbit
Bug Fixes
Chores