diff --git a/wizard-work/spark/check.py b/wizard-work/spark/check.py deleted file mode 100644 index 1a21f63..0000000 --- a/wizard-work/spark/check.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -"""Check that word_counter.py correctly counts words.""" - -import sys -import os - -# Add the wizard-outputs directory to path -sys.path.insert(0, '/root/.hermes/wizard-outputs/spark') - -from word_counter import count_words - -# Run tests -tests = [ - ("Hello world test", 3), - ("", 0), - (" ", 0), - ("one", 1), - ("one two three four five", 5), -] - -for text, expected in tests: - result = count_words(text) - if result != expected: - print(f"FAIL: '{text}' -> {result}, expected {expected}", file=sys.stderr) - sys.exit(1) - -print("All tests passed!") -sys.exit(0) \ No newline at end of file diff --git a/wizard-work/spark/scratch_word_counter.py b/wizard-work/spark/scratch_word_counter.py deleted file mode 100644 index 2ca3fbd..0000000 --- a/wizard-work/spark/scratch_word_counter.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python3 -"""Count words in all text files in the scratch directory and output JSON report.""" -import os -import json -from pathlib import Path - -SCRATCH_DIR = "/root/.hermes/profiles/spark/cache/scratch" -OUTPUT_FILE = "/root/.hermes/wizard-outputs/spark/word_count_report.json" - -def count_words_in_file(filepath): - """Count words in a file, return 0 if unreadable.""" - try: - with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: - content = f.read() - return len(content.split()) - except Exception: - return 0 - -def main(): - results = [] - total_words = 0 - - scratch_path = Path(SCRATCH_DIR) - if scratch_path.exists(): - for filepath in sorted(scratch_path.iterdir()): - if filepath.is_file(): - word_count = count_words_in_file(filepath) - total_words += word_count - results.append({ - "file": filepath.name, - "word_count": word_count - }) - - report = { - "scratch_directory": SCRATCH_DIR, - "files_processed": len(results), - "total_words": total_words, - "files": results - } - - with open(OUTPUT_FILE, 'w') as f: - json.dump(report, f, indent=2) - - print(f"Word count report written to {OUTPUT_FILE}") - print(f"Files: {len(results)}, Total words: {total_words}") - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/wizard-work/spark/test_word_counter.py b/wizard-work/spark/test_word_counter.py deleted file mode 100644 index 73ed2a4..0000000 --- a/wizard-work/spark/test_word_counter.py +++ /dev/null @@ -1,27 +0,0 @@ -# Test verification: word_counter.py works correctly -# Run: python3 test_word_counter.py -# Exit 0 = pass - -from word_counter import count_words - -# Test cases -tests = [ - ("Hello world test", 3), - ("", 0), - (" ", 0), - ("one", 1), - ("one two three four five", 5), -] - -all_passed = True -for text, expected in tests: - result = count_words(text) - if result != expected: - print(f"FAIL: '{text}' -> {result}, expected {expected}") - all_passed = False - -if all_passed: - print("All tests passed!") - exit(0) -else: - exit(1) \ No newline at end of file diff --git a/wizard-work/spark/test_wordcount.py b/wizard-work/spark/test_wordcount.py deleted file mode 100644 index 3b138ce..0000000 --- a/wizard-work/spark/test_wordcount.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 -"""Test script to verify wordcount.py matches wc output.""" -import subprocess -import json - -# Get wordcount.py output -result = subprocess.run( - ['python3', 'wordcount.py', 'test_words.txt'], - capture_output=True, text=True -) -wc_result = json.loads(result.stdout) -wordcount_words = wc_result['words'] - -# Get wc output -wc_output = subprocess.run( - ['wc', '-w', 'test_words.txt'], - capture_output=True, text=True -) -wc_words = int(wc_output.stdout.strip().split()[0]) - -print(f"wordcount.py: {wordcount_words} words") -print(f"wc: {wc_words} words") - -if wordcount_words == wc_words: - print("PASS: Outputs match") - exit(0) -else: - print("FAIL: Outputs differ") - exit(1) \ No newline at end of file diff --git a/wizard-work/spark/verify_snippets.py b/wizard-work/spark/verify_snippets.py deleted file mode 100644 index 23d7365..0000000 --- a/wizard-work/spark/verify_snippets.py +++ /dev/null @@ -1,48 +0,0 @@ -# Spark Lane Verification Script -# Used for snippet-level micro-tasks in the spark lane - -import sys -import time -from pathlib import Path -from datetime import datetime, timezone - -def verify_word_counter(): - """Verify word_counter.py functions correctly.""" - sys.path.insert(0, '/root/troupe-standup/wizard-work/spark') - from word_counter import count_words - - tests = [ - ("Hello world test", 3), - ("", 0), - (" ", 0), - ("one", 1), - ("one two three four five", 5), - ] - - passed = 0 - for text, expected in tests: - result = count_words(text) - if result == expected: - passed += 1 - - return passed == len(tests), passed, len(tests) - -def main(): - print("=== SPARK LANE VERIFICATION ===") - print(f"Timestamp: {datetime.now(timezone.utc).isoformat()}") - print() - - # Run verification - success, passed, total = verify_word_counter() - - print(f"word_counter.py: {passed}/{total} tests passed") - - if success: - print("\nVERDICT: All snippets verified successfully") - sys.exit(0) - else: - print("\nVERDICT: Some snippets failed verification") - sys.exit(1) - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/wizard-work/spark/word-counter-README.md b/wizard-work/spark/word-counter-README.md deleted file mode 100644 index 52ac360..0000000 --- a/wizard-work/spark/word-counter-README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Word Counter - -A simple Python word counter that counts words in a text file. - -## Usage - -```bash -python3 word-counter.py -``` - -## Example - -```bash -$ python3 word-counter.py test-input.txt -7 -``` - -## Verification - -- 7 words in test-input.txt: PASS -- 0 words in test-empty.txt: PASS \ No newline at end of file