Skip to content

MAINT: Resolve high-priority CLI bugs (Version, Stderr, and Upload Type) #28#35

Open
AviJxn wants to merge 2 commits intoaces:mainfrom
AviJxn:fix/version-and-stderr-redirection
Open

MAINT: Resolve high-priority CLI bugs (Version, Stderr, and Upload Type) #28#35
AviJxn wants to merge 2 commits intoaces:mainfrom
AviJxn:fix/version-and-stderr-redirection

Conversation

@AviJxn
Copy link
Copy Markdown

@AviJxn AviJxn commented Mar 7, 2026

This Pull Request addresses several High Priority requirements identified in #28 to bring the CBRAIN CLI closer to a production-ready 0.9/1.0 release. The focus of these changes is to stabilize the command execution flow, ensure standard stream compliance (POSIX), and resolve attribute errors in file management.

Key Improvements

Feature Issue Addressed Action Taken
Version Command #28 (Core) Decoupled version from session validation.
Stream Compliance #28 (UX) Redirected all help/usage messages to sys.stderr.
File Upload #28 (Bug) Implemented SingleFile as the default --file-type.
Network Latency #28 (Perf) Eliminated redundant is_authenticated() network calls.

1. Unauthenticated Version Access

  • Problem: Users could not check the CLI version without an active session, causing unnecessary friction.
  • Solution: Reordered the execution logic in main.py to handle the version command immediately after argument parsing.

2. Standard Error (stderr) Redirection

  • Problem: Incomplete or erroneous commands printed usage text to stdout, polluting data pipes.
  • Solution: Updated parser.print_help() calls to utilize file=sys.stderr, ensuring stdout remains reserved for successful data payloads.

3. File Upload Attribute Stability

  • Problem: Omission of the --file-type flag caused an AttributeError within the Namespace object.
  • Solution: Explicitly defined --file-type in the parser with a default value of "SingleFile", preventing crashes and simplifying the user experience.

4. Optimized Request Logic

  • Problem: Every authenticated command hit the server twice (Global check + Handler execution).
  • Solution: Removed the redundant global authentication check. Handler functions now manage their own connection state, reducing server load and response latency.

Verify Test Cases

  1. Unauthenticated Version:
    • python -m cbrain_cli.main version -> PASS (Returns version info without login).
  2. Output Piped Redirection:
    • python -m cbrain_cli.main file > out.txt -> PASS (Usage text sent to terminal; out.txt is empty).
  3. Implicit Upload Type:
    • python -m cbrain_cli.main file upload --data-provider 15 --group-id 3 README.md -> PASS (No AttributeError; initiates upload process).

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.

1 participant