Skip to content

Add initial BrainAlpha CLI scaffolding#1

Open
Gucc111 wants to merge 1 commit intoexp/try_codexfrom
codex/create-python-cli-for-worldquant-brain
Open

Add initial BrainAlpha CLI scaffolding#1
Gucc111 wants to merge 1 commit intoexp/try_codexfrom
codex/create-python-cli-for-worldquant-brain

Conversation

@Gucc111
Copy link
Owner

@Gucc111 Gucc111 commented Nov 29, 2025

Summary

  • add project packaging via pyproject with typer, rich, httpx, and pyyaml
  • implement initial CLI with version and config commands backed by config manager
  • introduce logging setup, HTTP client stub, sample config, and project README

Testing

  • python -m compileall src

Codex Task


Note

Introduce project scaffolding with a Typer CLI (version, config init/show), YAML-backed config manager, rich logging, HTTP client with retries, packaging, and sample config.

  • CLI:
    • Add Typer app in src/brainalpha/cli/__init__.py with version and config subcommands.
    • Implement brainalpha config init|show in src/brainalpha/cli/config.py.
  • Configuration:
    • Add BrainAlphaConfig and ConfigManager in src/brainalpha/config/manager.py with YAML persistence to ~/.brainalpha/config.yml.
  • Infrastructure:
    • Add BrainHttpClient in src/brainalpha/infra/http.py with base URL handling and retry/backoff.
  • Logging:
    • Add configure_logging using rich.logging in src/brainalpha/logging.py.
  • Packaging:
    • Define pyproject.toml with dependencies and console script brainalpha = "brainalpha.cli:run".
    • Initialize package metadata in src/brainalpha/__init__.py.
  • Docs & Examples:
    • Add README.md and example pipeline config configs/sample.yml.
  • Repo setup:
    • Update .gitignore to exclude .brainalpha/ local data.

Written by Cursor Bugbot for commit 17aa566. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

) -> None:
"""Initialize the local configuration file with credentials and defaults."""
manager = ConfigManager()
config = BrainAlphaConfig(api_key=api_key, base_url=base_url, storage_path=storage_path)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: None value bypasses default factory, corrupts storage path

When users run brainalpha config init without specifying --storage-path, the storage_path parameter is None and gets passed explicitly to BrainAlphaConfig. The dataclass's default_factory only triggers when the argument is omitted entirely, not when None is passed. This causes to_dict() to serialize storage_path as the string "None", and when reloaded via from_dict(), it creates Path("None") - a literal path named "None" instead of the intended default storage location.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant