QuantConnect / QuantConnect/lean-cli
Improve semantics of library organization
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 326
- Forks
- 168
- Avg merge
- 3d 50m
- Merged PRs (30d)
- 3
Description
Currently, the directory Library/ is treated as a hard-coded special case by the lean project-create and lean library add commands. Given that projects list the names and paths of their library dependencies and that libraries also have config.json files, it seems that dropping the hard-coded value in favor of more explicit settings/flags would be cleaner and allow users more flexibility for code organization.
This assumes that the runtime doesn't treat Library/paths as special, which I have not checked.
Current status:
is_lean_library() checks whether the argument to library add starts with "Library/" to determine its return value, and this is what the library add command uses to determine whether to add a local library or to install from pypi/nuget.
The docs say to use project-create to create a new library. [project_create] looks at whether the path to the project contains "Library/" and if so, uses the library template and puts it in Library.py (instead of main.py with the usual algo contents)
https://github.com/QuantConnect/lean-cli/blob/master/lean/commands/create_project.py#L428-L434
https://github.com/QuantConnect/lean-cli/blob/master/lean/commands/create_project.py#L455-L457
Proposed changes:
- introduce an argument to
project-create,--libraryto indicate that the project is intended to be a library - when
"Library/"is in the path according to current logic, but--libraryis not set to true, emit warning log message is_library_project = is-library-arg OR current logic- modify
project-createso that it also setsis-libraryinconfig.jsonwhen creating a library - modify
is_lean_library()in to use the field in the config rather than the path
Optional / nice-to-have changes:
- introduce
library-createcommand, analogous toproject-create, but for creating libraries - factor out common logic between the two commands
- add a deprecation warning log message to project-create in the library-creation path
- introduce an argument to the
library addto explicitly indicate whether the library is local or to be installed from pypi/nuget
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lean/components/util/library_manager.py, especially is_lean_library(), and the project-create and library add entry points in lean/commands/create_project.py and lean/commands/library/add.py. Trace how project paths and config.json are handled before deciding how the explicit library setting should interact with the existing Library/ logic. Done means library projects can be identified from configuration and project-create supports the proposed flag without relying solely on the hard-coded path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100