Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

config.py 995 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  1. from functools import lru_cache
  2. from pathlib import Path
  3. from pydantic import BaseSettings, DirectoryPath
  4. class AppSettings(BaseSettings):
  5. base_dir: DirectoryPath = Path(__file__).parent.parent
  6. data_dir: Path = base_dir.joinpath("data")
  7. artifact_dir: Path = base_dir.joinpath("artifacts")
  8. metrics_dir: Path = base_dir.joinpath("metrics")
  9. def update_base(self, new_base_pth: DirectoryPath) -> None:
  10. """
  11. Update base_dir and the fields that depend on it (data_dir, artifact_dir, metrics_dir)
  12. Args:
  13. new_base_pth: The new base directory path.
  14. Returns: None
  15. """
  16. self.base_dir = new_base_pth
  17. self.data_dir = self.base_dir.joinpath("data")
  18. self.artifact_dir = self.base_dir.joinpath("artifacts")
  19. self.metrics_dir = self.base_dir.joinpath("metrics")
  20. class Config:
  21. validate_assignment = True
  22. @lru_cache(maxsize=1)
  23. def get_app_settings() -> AppSettings:
  24. return AppSettings()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...