If users are building a project follow the following pattern. - Qlib is a sub folder in project path - There is a file named `config.yaml` in qlib. For example: If your project file system structure follows such a pattern / - config.
(config_name="config.yaml", cur_path: Union[Path, str, None] = None)
| 193 | |
| 194 | |
| 195 | def get_project_path(config_name="config.yaml", cur_path: Union[Path, str, None] = None) -> Path: |
| 196 | """ |
| 197 | If users are building a project follow the following pattern. |
| 198 | - Qlib is a sub folder in project path |
| 199 | - There is a file named `config.yaml` in qlib. |
| 200 | |
| 201 | For example: |
| 202 | If your project file system structure follows such a pattern |
| 203 | |
| 204 | <project_path>/ |
| 205 | - config.yaml |
| 206 | - ...some folders... |
| 207 | - qlib/ |
| 208 | |
| 209 | This folder will return <project_path> |
| 210 | |
| 211 | NOTE: link is not supported here. |
| 212 | |
| 213 | |
| 214 | This method is often used when |
| 215 | - user want to use a relative config path instead of hard-coding qlib config path in code |
| 216 | |
| 217 | Raises |
| 218 | ------ |
| 219 | FileNotFoundError: |
| 220 | If project path is not found |
| 221 | """ |
| 222 | if cur_path is None: |
| 223 | cur_path = Path(__file__).absolute().resolve() |
| 224 | cur_path = Path(cur_path) |
| 225 | while True: |
| 226 | if (cur_path / config_name).exists(): |
| 227 | return cur_path |
| 228 | if cur_path == cur_path.parent: |
| 229 | raise FileNotFoundError("We can't find the project path") |
| 230 | cur_path = cur_path.parent |
| 231 | |
| 232 | |
| 233 | def auto_init(**kwargs): |