-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_subdirs.py
56 lines (51 loc) · 2.24 KB
/
create_subdirs.py
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
47
48
49
50
51
52
53
54
55
56
import os
# Define the subdirectory structure and respective files within ai_model_integration
subdirectory_structure = {
"notebooks": [
"data_analysis.ipynb",
"model_training.ipynb",
"model_evaluation.ipynb"
],
"models": [
"trained_model.pkl"
],
"data": [
"sample_dataset.csv",
"processed_data.csv"
],
"scripts": [
"preprocess_data.py",
"train_model.py",
"evaluate_model.py"
],
"README.md": None, # Single file at the root
}
# Base directory (assumed to already exist)
base_dir = "ai_model_integration"
# Function to create subdirectories and files
def create_project_structure(base_dir, structure):
for key, value in structure.items():
if isinstance(value, list): # Subdirectory with files
dir_path = os.path.join(base_dir, key)
os.makedirs(dir_path, exist_ok=True)
for file in value:
file_path = os.path.join(dir_path, file)
if not os.path.exists(file_path):
with open(file_path, "w") as f:
# Placeholder content for various file types
if file.endswith(".ipynb"):
f.write('{\n "cells": [],\n "metadata": {},\n "nbformat": 4,\n "nbformat_minor": 5\n}')
elif file.endswith(".py"):
f.write("# Placeholder for script: " + file)
elif file.endswith(".csv"):
f.write("column1,column2,column3\nvalue1,value2,value3\n")
elif file.endswith(".pkl"):
pass # Leave .pkl empty
elif value is None: # Single file at the root
file_path = os.path.join(base_dir, key)
if not os.path.exists(file_path):
with open(file_path, "w") as f:
f.write("# AI Model Integration Project\n\nThis project contains the necessary files and structure for AI model integration.")
# Run the function to create the subdirectories and files within the existing base directory
create_project_structure(base_dir, subdirectory_structure)
print(f"Subdirectories and files created within '{base_dir}' successfully.")