diff --git a/wizard-work/spark/__pycache__/word_counter.cpython-314.pyc b/wizard-work/spark/__pycache__/word_counter.cpython-314.pyc index 58aeefe..dd3abee 100644 Binary files a/wizard-work/spark/__pycache__/word_counter.cpython-314.pyc and b/wizard-work/spark/__pycache__/word_counter.cpython-314.pyc differ diff --git a/wizard-work/spark/check_spark_profile.py b/wizard-work/spark/check_spark_profile.py new file mode 100644 index 0000000..e06e8ae --- /dev/null +++ b/wizard-work/spark/check_spark_profile.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +"""Check the Hermes agent environment and spark profile status.""" + +import sys +from pathlib import Path + + +def check_hermes_spark(): + """Verify Hermes spark profile exists and has correct structure.""" + errors = [] + + # Check profile directory + profile_dir = Path("/root/.hermes/profiles/spark") + if not profile_dir.exists(): + errors.append("Profile directory missing") + else: + # Check cache/scratch exists + scratch_dir = profile_dir / "cache" / "scratch" + if not scratch_dir.exists(): + errors.append("Scratch directory missing") + + # Check key files + config_file = profile_dir / "config.yaml" + if not config_file.exists(): + errors.append("config.yaml missing") + + return errors + + +def check_wizard_outputs(): + """Verify wizard-outputs/spark directory structure.""" + errors = [] + + output_dir = Path("/root/.hermes/wizard-outputs/spark") + if not output_dir.exists(): + errors.append("wizard-outputs/spark directory missing") + return errors + + # Check for key output files + required_files = ["results.txt", "env-check.sh"] + for fname in required_files: + if not (output_dir / fname).exists(): + errors.append(f"Missing {fname}") + + return errors + + +def main(): + all_errors = [] + + all_errors.extend(check_hermes_spark()) + all_errors.extend(check_wizard_outputs()) + + if all_errors: + print("Verification FAILED:") + for err in all_errors: + print(f" - {err}") + sys.exit(1) + else: + print("All checks PASSED") + sys.exit(0) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/wizard-work/spark/checksum_verify.py b/wizard-work/spark/checksum_verify.py new file mode 100644 index 0000000..b04a5a0 --- /dev/null +++ b/wizard-work/spark/checksum_verify.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +"""Checksum verification tool - verifies SHA256 checksums of files. + +Usage: + python3 checksum_verify.py + +Format of checksum_file: + + (same as sha256sum output format) +""" + +import hashlib +import sys +from pathlib import Path + + +def compute_sha256(filepath: str) -> str: + """Compute SHA256 hash of a file.""" + sha256_hash = hashlib.sha256() + with open(filepath, "rb") as f: + for chunk in iter(lambda: f.read(8192), b""): + sha256_hash.update(chunk) + return sha256_hash.hexdigest() + + +def verify_checksums(checksum_file: str) -> bool: + """Verify all checksums in the file. Returns True if all pass.""" + all_passed = True + with open(checksum_file, "r") as f: + for line_num, line in enumerate(f, 1): + line = line.strip() + if not line: + continue + parts = line.split() + if len(parts) < 2: + print(f"Line {line_num}: Invalid format - skipping") + all_passed = False + continue + expected_hash = parts[0] + filepath = " ".join(parts[1:]) + + if not Path(filepath).exists(): + print(f"FAIL: {filepath} - file not found") + all_passed = False + continue + + actual_hash = compute_sha256(filepath) + if actual_hash == expected_hash: + print(f"OK: {filepath}") + else: + print(f"FAIL: {filepath}") + print(f" Expected: {expected_hash}") + print(f" Actual: {actual_hash}") + all_passed = False + + return all_passed + + +def main(): + if len(sys.argv) < 2: + print(__doc__) + sys.exit(1) + + checksum_file = sys.argv[1] + if verify_checksums(checksum_file): + print("\nAll checksums verified successfully!") + sys.exit(0) + else: + print("\nSome checksums failed!") + sys.exit(1) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/wizard-work/spark/checksums.sha256 b/wizard-work/spark/checksums.sha256 new file mode 100644 index 0000000..c08ff56 --- /dev/null +++ b/wizard-work/spark/checksums.sha256 @@ -0,0 +1,2 @@ +4b1881cb2680a1512aee9aee4029365525691f4de7dec2dd000e1facf2468f70 results.txt +988a71fed1809c3d6837042fa5972298b8a9f7f1252351c87d5229032c5a8172 env-check.sh \ No newline at end of file diff --git a/wizard-work/spark/imports.sha256 b/wizard-work/spark/imports.sha256 new file mode 100644 index 0000000..d39946f --- /dev/null +++ b/wizard-work/spark/imports.sha256 @@ -0,0 +1,3 @@ +4b1881cb2680a1512aee9aee4029365525691f4de7dec2dd000e1facf2468f70 checksums.sha256 +3b55ae2261a56b69a2b138e0ef93928314001869f2e0ed4886541463433b9eb7 checksum_verify.py +7d554ff1409148fbcc04800f8cad54ddfdf4f1ef6ea4bb0641f407dcbf9f7f84 check_spark_profile.py \ No newline at end of file diff --git a/wizard-work/spark/prime_checker.py b/wizard-work/spark/prime_checker.py new file mode 100644 index 0000000..669d481 --- /dev/null +++ b/wizard-work/spark/prime_checker.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Check if a number is prime.""" + +def is_prime(n: int) -> bool: + """Return True if n is a prime number, False otherwise.""" + if n < 2: + return False + if n == 2: + return True + if n % 2 == 0: + return False + for i in range(3, int(n**0.5) + 1, 2): + if n % i == 0: + return False + return True + +if __name__ == "__main__": + import sys + if len(sys.argv) != 2: + print("Usage: python prime_checker.py ") + sys.exit(1) + try: + num = int(sys.argv[1]) + result = is_prime(num) + print(f"{num} is {'prime' if result else 'not prime'}") + sys.exit(0 if result else 1) + except ValueError: + print("Please provide a valid integer") + sys.exit(1) \ No newline at end of file