Skip to content

Commit 0d451ea

Browse files
committed
minor changes to examples, remove future.md
1 parent 4fc28dd commit 0d451ea

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

examples/final_archive_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
time.sleep(1)
131131

132132
print("\n=== FINAL SUMMARY ===")
133-
print(f"Successful fetches: {successful_count}/10 ({successful_count*10}%)")
133+
print(f"Successful fetches: {successful_count}/10 ({successful_count * 10}%)")
134134

135135
if successful_count > 0:
136136
success_results = [r for r in results if r.get("status") == "success"]
@@ -140,14 +140,14 @@
140140
)
141141

142142
print(
143-
f"Correct predictions: {matches}/{successful_count} ({matches/successful_count*100:.1f}%)"
143+
f"Correct predictions: {matches}/{successful_count} ({matches / successful_count * 100:.1f}%)"
144144
)
145145
print(f"Average content: {avg_length:.0f} chars")
146146

147147
print("\n=== DETAILED RESULTS ===")
148148
for r in success_results:
149149
symbol = "✓" if r["match"] else "○"
150-
print(f'{symbol} {r["domain"]}: {r["predicted"]} (conf: {r["confidence"]:.3f})')
150+
print(f"{symbol} {r['domain']}: {r['predicted']} (conf: {r['confidence']:.3f})")
151151

152152
print("\n=== ARCHIVE INTEGRATION STATUS ===")
153153
print("✓ Archive.org integration working!")

examples/sandbox/sandbox_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
def print_section(title):
2222
"""Print a section header."""
23-
print(f"\n{'='*60}")
23+
print(f"\n{'=' * 60}")
2424
print(f" {title}")
25-
print(f"{'='*60}")
25+
print(f"{'=' * 60}")
2626

2727

2828
def run_docker_sandbox():

examples/sandbox/secure_classify.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,22 @@ def classify_in_docker(domains, text_only=True, output_dir="output"):
6262
# Print summary
6363
print("\\n✅ Classification Results:")
6464
print("=" * 50)
65-
print(result[['domain', 'pred_label', 'pred_prob']].to_string(index=False))
65+
66+
# Determine which columns to use based on method
67+
if '{method}' == 'classify_by_text':
68+
label_col, prob_col = 'text_label', 'text_prob'
69+
elif '{method}' == 'classify_by_images':
70+
label_col, prob_col = 'image_label', 'image_prob'
71+
else: # combined classify method
72+
label_col, prob_col = 'pred_label', 'pred_prob'
73+
74+
print(result[['domain', label_col, prob_col]].to_string(index=False))
6675
print(f"\\n📄 Detailed results saved to output/results.csv")
6776
6877
# Category summary
6978
print("\\n📊 Category Summary:")
7079
print("-" * 30)
71-
category_counts = result['pred_label'].value_counts()
80+
category_counts = result[label_col].value_counts()
7281
for category, count in category_counts.items():
7382
print(f"{{category:15s}}: {{count:3d}} domains")
7483
@@ -117,6 +126,9 @@ def classify_in_docker(domains, text_only=True, output_dir="output"):
117126
"/tmp", # Temporary filesystem
118127
"--tmpfs",
119128
"/var/tmp",
129+
# Use pre-installed browsers (read-only is fine for browsers)
130+
"--tmpfs",
131+
"/app/cache:rw,uid=995,gid=995", # piedomains cache with correct playwright user permissions
120132
"-v",
121133
f"{temp_script}:/app/classify.py",
122134
"-v",
@@ -206,7 +218,7 @@ def interactive_mode():
206218
domains = []
207219
try:
208220
while True:
209-
domain = input(f"Domain {len(domains)+1}: ").strip()
221+
domain = input(f"Domain {len(domains) + 1}: ").strip()
210222
if domain.lower() in ["quit", "exit", ""]:
211223
break
212224
if domain:

examples/sandbox/test_sandbox_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
def print_section(title):
1414
"""Print a section header."""
15-
print(f"\n{'='*60}")
15+
print(f"\n{'=' * 60}")
1616
print(f" {title}")
17-
print(f"{'='*60}")
17+
print(f"{'=' * 60}")
1818

1919

2020
def check_docker():

future.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)