Fix/3788 always register profile workspace cli#3856
Open
ugbotueferhire wants to merge 2 commits intodlt-hub:develfrom
Open
Fix/3788 always register profile workspace cli#3856ugbotueferhire wants to merge 2 commits intodlt-hub:develfrom
ugbotueferhire wants to merge 2 commits intodlt-hub:develfrom
Conversation
When workspace context is not active, dlt profile and dlt workspace were completely absent from the CLI because the plugin hooks returned None. This adds placeholder command classes that print actionable setup instructions instead of silently vanishing.
Author
|
Hi @anuunchin , whenever you have a moment, could you please take a look at this PR for a review? Let me know if you need any changes. Thanks! |
Author
|
Hey @anuunchin, following up on this PR. Pretty low-risk change, would appreciate a review when you have bandwidth or if you could assign someone to this, thanks :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Fix] – Always register
dlt profileanddlt workspaceCLI commandsCloses #3788
Description
Context:
The
dlt profileanddlt workspaceCLI commands were completely invisible when no.dlt/.workspacemarker file existed. The plugin hooksplug_cli_profile()andplug_cli_workspace()indlt._workspace.cli._pluginsreturnedNonewhenis_workspace_active()wasFalse. Since pluggy silently filtersNonefrom hook results, argparse never learned these commands existed — they were absent fromdlt --helpand returned"invalid choice"when invoked directly. This broke discoverability for users, AI agents, and documentation references todlt profile <name> pin.Approach:
Added lightweight placeholder command classes that are registered unconditionally, following the same graceful-degradation pattern used by
DeployCommand.execute()(which prints guidance whenpipdeptree/cron_descriptorare missing rather than hiding the command):_ProfilePlaceholderadded todlt/_workspace/cli/commands.py— stands in forProfileCommandwhen workspace context is inactive. Accepts any arguments vianargs="*"and prints actionable setup instructions on execute._WorkspacePlaceholderadded todlt/_workspace/cli/commands.py— identical pattern forWorkspaceCommand.plug_cli_profile()indlt/_workspace/cli/_plugins.py— returns_ProfilePlaceholderinstead ofNonewhen workspace is inactive.plug_cli_workspace()indlt/_workspace/cli/_plugins.py— returns_WorkspacePlaceholderinstead ofNonewhen workspace is inactive.No changes to the
SupportsCliCommandprotocol, the argparse wiring in_dlt.py, or any other command. When.dlt/.workspaceexists, the real commands are returned exactly as before.Impact:
dlt profileanddlt workspaceare now always visible indlt --helpand print clear setup instructions when invoked outside a workspace context, instead of silently vanishing.dlt profile <name> pinnow get an actionable error with exact remediation steps (mkdir -p .dlt && touch .dlt/.workspace) instead of a cryptic argparse rejection.ProfileCommandandWorkspaceCommandare still returned by the plugin hooks. The placeholder classes are only used in the fallback path.Visual Proof
Tests
Manual verification performed:
dlt --helplists bothprofileandworkspacewithout.dlt/.workspace✅dlt profile listprints setup instructions and exits non-zero ✅dlt workspace infoprints setup instructions and exits non-zero ✅.dlt/.workspacepresent, realProfileCommand/WorkspaceCommandexecute normally ✅