| import json |
| import numpy as np |
| import random |
| import os |
| import zipfile |
|
|
| def export_json(data, filename): |
| with open(filename, 'w') as f: |
| json.dump(data, f, indent=4) |
| print(f"Data exported to {filename}") |
|
|
| def seed_everything(seed): |
| random.seed(seed) |
| np.random.seed(seed) |
| print(f"Random seeds set to {seed}") |
|
|
| def zip_project(output_name="rft_simulation_engine.zip"): |
| files_to_zip = [ |
| 'agent.py', |
| 'simulation.py', |
| 'visualization.py', |
| 'app.py', |
| 'utils.py', |
| 'requirements.txt', |
| 'README.md', |
| 'test_runner.py', |
| 'final_agent_states.json', |
| 'phi_plot.png', |
| 'tau_plot.png', |
| 'fitness_plot.png', |
| 'coherence_plot.png', |
| 'stability_plot.png' |
| ] |
|
|
| with zipfile.ZipFile(output_name, 'w') as zf: |
| for file in files_to_zip: |
| if os.path.exists(file): |
| zf.write(file) |
| print(f"Added {file} to {output_name}") |
| else: |
| print(f"Warning: {file} not found, skipping.") |
| print(f"Successfully created {output_name} containing all specified files.") |
|
|
| def zip_huggingface_repo(output_name='rft_hf_repo.zip'): |
| """Creates a zip archive containing only the core project files for Hugging Face deployment.""" |
| files_to_include = [ |
| 'agent.py', |
| 'simulation.py', |
| 'visualization.py', |
| 'app.py', |
| 'utils.py', |
| 'requirements.txt', |
| 'README.md' |
| ] |
|
|
| with zipfile.ZipFile(output_name, 'w') as zf: |
| for file in files_to_include: |
| if os.path.exists(file): |
| zf.write(file) |
| print(f"Added {file} to {output_name}") |
| else: |
| print(f"Warning: {file} not found, skipping for Hugging Face repo zip.") |
| print(f"Successfully created Hugging Face repository zip: {output_name}") |
|
|
| print("utils.py updated successfully with new zip_huggingface_repo function.") |
|
|