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

template.py 1.4 KB

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
36
37
38
39
40
41
42
43
44
45
46
  1. import os
  2. from pathlib import Path
  3. package_name="DimondPricePrediction"
  4. list_of_files=[
  5. "github/workflows/.gitkeep",
  6. f"src/{package_name}/__init__.py",
  7. f"src/{package_name}/components/__init__.py",
  8. f"src/{package_name}/components/data_ingestion.py",
  9. f"src/{package_name}/components/data_transformation.py",
  10. f"src/{package_name}/components/model_trainer.py",
  11. f"src/{package_name}/pipelines/__init__.py",
  12. f"src/{package_name}/pipelines/training_pipeline.py",
  13. f"src/{package_name}/pipelines/prediction_pipeline.py",
  14. f"src/{package_name}/logger.py",
  15. f"src/{package_name}/exception.py",
  16. f"src/{package_name}/utils/__init__.py",
  17. "notebooks/research.ipynb",
  18. "notebooks/data/.gitkeep",
  19. "requirements.txt",
  20. "setup.py",
  21. "init_setup.sh",
  22. ]
  23. # here will create a directory
  24. for filepath in list_of_files:
  25. filepath=Path(filepath)
  26. filedir,filename=os.path.split(filepath)
  27. """ how exist_ok works:if "directory" already exists,
  28. os.makedirs() will not raise an error, and it will do nothing.
  29. If "my_directory" doesn't exist, it will create the directory.
  30. """
  31. if filedir != "":
  32. os.makedirs(filedir,exist_ok=True)
  33. if (not os.path.exists(filepath)) or (os.path.getsize(filepath) == 0):
  34. with open(filepath,"w") as f:
  35. pass
  36. else:
  37. print("file already exists")
  38. # here will use the file handling
Tip!

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

Comments

Loading...