|
| 1 | +import argparse |
| 2 | +import sys |
| 3 | +import os |
| 4 | + |
| 5 | +# Ensure the src directory is in the Python path |
| 6 | +sys.path.append(os.path.join(os.path.dirname(__file__), 'src')) |
| 7 | + |
| 8 | + |
| 9 | +try: |
| 10 | + from data.clean import run_cleaning_and_split |
| 11 | +except ImportError as e: |
| 12 | + print(f"Error importing modules: {e}") |
| 13 | + print("Please ensure your scripts are correctly placed in the 'src' directory and paths are correct.") |
| 14 | + sys.exit(1) |
| 15 | + |
| 16 | +def main(): |
| 17 | + parser = argparse.ArgumentParser(description="SentiSynth Project Main Entry Point") |
| 18 | + subparsers = parser.add_subparsers(dest='command', help='Available commands') |
| 19 | + |
| 20 | + # --- Clean and Split Command --- |
| 21 | + parser_process = subparsers.add_parser('process_data', help='Clean raw data and create final train/val/sanity splits') |
| 22 | + parser_process.add_argument('--raw-path', default='./data/raw', help='Path to the raw dataset directory') |
| 23 | + parser_process.add_argument('--output-path', default='./data/sst2_dd', help='Path to save the final DatasetDict') |
| 24 | + parser_process.set_defaults(func=lambda args: run_cleaning_and_split(args.raw_path, args.output_path)) |
| 25 | + |
| 26 | + # --- Add other commands here as subparsers --- |
| 27 | + # Example: Download command |
| 28 | + # parser_download = subparsers.add_parser('download', help='Download the raw dataset') |
| 29 | + # parser_download.add_argument('--save-path', default='./data/raw', help='Path to save the raw dataset') |
| 30 | + # parser_download.set_defaults(func=lambda args: run_download(args.save_path)) # Assuming you create run_download |
| 31 | + |
| 32 | + # Example: Train command |
| 33 | + # parser_train = subparsers.add_parser('train', help='Train a model') |
| 34 | + # parser_train.add_argument('--config', required=True, help='Path to the training configuration file') |
| 35 | + # ... other training args ... |
| 36 | + # parser_train.set_defaults(func=lambda args: run_training(args)) # Assuming you create run_training |
| 37 | + |
| 38 | + # Parse arguments |
| 39 | + args = parser.parse_args() |
| 40 | + |
| 41 | + # Execute the function associated with the chosen command |
| 42 | + if hasattr(args, 'func'): |
| 43 | + args.func(args) |
| 44 | + else: |
| 45 | + # If no command is given, print help |
| 46 | + parser.print_help() |
| 47 | + |
| 48 | +if __name__ == "__main__": |
| 49 | + main() |
0 commit comments