MCPcopy
hub / github.com/microsoft/qlib / get_project_path

Function get_project_path

qlib/__init__.py:195–230  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

193
194
195def 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
233def auto_init(**kwargs):

Callers 1

auto_initFunction · 0.85

Calls 1

existsMethod · 0.45

Tested by

no test coverage detected