Gaston895 commited on
Commit
9eac9ed
·
verified ·
1 Parent(s): 97f1688

Upload reco.py to root directory (final structure)

Browse files
Files changed (1) hide show
  1. reco.py +159 -0
reco.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script to move model files from the 'econ' subdirectory to the root directory
4
+ for the Hugging Face repository: Gaston895/aegisconduct
5
+ """
6
+
7
+ import os
8
+ import shutil
9
+ from pathlib import Path
10
+ import sys
11
+
12
+ def move_files_to_root(repo_path="."):
13
+ """
14
+ Moves all files from the 'econ' subdirectory to the repository root.
15
+
16
+ Args:
17
+ repo_path (str): Path to the local clone of the repository.
18
+ """
19
+
20
+ # Define paths
21
+ repo_dir = Path(repo_path).resolve()
22
+ econ_dir = repo_dir / "econ"
23
+ root_dir = repo_dir
24
+
25
+ print(f"Repository root: {root_dir}")
26
+ print(f"Econ subdirectory: {econ_dir}")
27
+
28
+ # Check if 'econ' directory exists
29
+ if not econ_dir.exists() or not econ_dir.is_dir():
30
+ print(f"❌ Error: 'econ' subdirectory not found at {econ_dir}")
31
+ print("Please ensure you are in the correct directory and the 'econ' folder exists.")
32
+ return False
33
+
34
+ # List files in the 'econ' directory
35
+ files_to_move = list(econ_dir.iterdir())
36
+
37
+ if not files_to_move:
38
+ print("ℹ️ No files found in the 'econ' directory.")
39
+ return True
40
+
41
+ print(f"📁 Found {len(files_to_move)} files/directories in 'econ':")
42
+ for item in files_to_move:
43
+ print(f" - {item.name}")
44
+
45
+ # Move files
46
+ moved_count = 0
47
+ for item in files_to_move:
48
+ source_path = item
49
+ dest_path = root_dir / item.name
50
+
51
+ # Check if a file with the same name already exists in root
52
+ if dest_path.exists():
53
+ print(f"⚠️ Warning: {item.name} already exists in root. Skipping...")
54
+ continue
55
+
56
+ try:
57
+ # Move the file/directory
58
+ shutil.move(str(source_path), str(dest_path))
59
+ moved_count += 1
60
+ print(f"✅ Moved: {item.name}")
61
+ except Exception as e:
62
+ print(f"❌ Failed to move {item.name}: {e}")
63
+
64
+ # Check if 'econ' directory is now empty and remove it
65
+ try:
66
+ if not any(econ_dir.iterdir()):
67
+ econ_dir.rmdir()
68
+ print(f"🗑️ Removed empty 'econ' directory")
69
+ except Exception as e:
70
+ print(f"⚠️ Could not remove 'econ' directory: {e}")
71
+
72
+ print(f"\n🎉 Successfully moved {moved_count} out of {len(files_to_move)} items to the root directory.")
73
+
74
+ if moved_count < len(files_to_move):
75
+ print("💡 Some files may not have been moved due to conflicts. Please review manually.")
76
+
77
+ return True
78
+
79
+ def update_config_json(repo_path="."):
80
+ """
81
+ Updates the config.json file if it references the old 'econ' path.
82
+ """
83
+
84
+ config_path = Path(repo_path) / "config.json"
85
+
86
+ if config_path.exists():
87
+ try:
88
+ import json
89
+ with open(config_path, 'r', encoding='utf-8') as f:
90
+ config = json.load(f)
91
+
92
+ # Check if config needs updating
93
+ needs_update = False
94
+ # You can add specific checks here based on your config structure
95
+
96
+ if needs_update:
97
+ with open(config_path, 'w', encoding='utf-8') as f:
98
+ json.dump(config, f, indent=2)
99
+ print("✅ Updated config.json")
100
+ else:
101
+ print("ℹ️ config.json doesn't appear to need updates")
102
+
103
+ except Exception as e:
104
+ print(f"⚠️ Could not check/update config.json: {e}")
105
+
106
+ def main():
107
+ """Main function to orchestrate the file movement."""
108
+
109
+ print("=" * 60)
110
+ print("AEGISCONDUCT MODEL FILES REORGANIZATION")
111
+ print("=" * 60)
112
+ print("This script moves files from 'econ' subdirectory to repository root.")
113
+ print(f"Repository: Gaston895/aegisconduct")
114
+ print("=" * 60)
115
+
116
+ # Ask for confirmation
117
+ response = input("\n⚠️ WARNING: This will modify your local repository structure.\nDo you want to continue? (yes/no): ").strip().lower()
118
+
119
+ if response not in ['yes', 'y']:
120
+ print("Operation cancelled.")
121
+ return
122
+
123
+ # Step 1: Move files
124
+ print("\n" + "=" * 60)
125
+ print("STEP 1: Moving files from 'econ' to root directory")
126
+ print("=" * 60)
127
+
128
+ success = move_files_to_root()
129
+
130
+ if not success:
131
+ print("❌ File movement failed. Exiting.")
132
+ return
133
+
134
+ # Step 2: Update config if needed
135
+ print("\n" + "=" * 60)
136
+ print("STEP 2: Checking configuration files")
137
+ print("=" * 60)
138
+
139
+ update_config_json()
140
+
141
+ # Step 3: Instructions for next steps
142
+ print("\n" + "=" * 60)
143
+ print("NEXT STEPS")
144
+ print("=" * 60)
145
+ print("1. Review the moved files in your repository root")
146
+ print("2. Update your application code to load from root (not 'econ' subfolder)")
147
+ print("3. Test that the model loads correctly:")
148
+ print(" - From Python: model = AutoModelForCausalLM.from_pretrained('Gaston895/aegisconduct')")
149
+ print(" - No 'subfolder' or 'revision' parameter needed")
150
+ print("4. Commit and push changes to Hugging Face Hub:")
151
+ print(" git add .")
152
+ print(" git commit -m 'Move model files from econ subdir to root'")
153
+ print(" git push origin main")
154
+ print("=" * 60)
155
+
156
+ print("\n✅ Script completed successfully!")
157
+
158
+ if __name__ == "__main__":
159
+ main()