# HG changeset patch # User Henry S. Thompson # Date 1590926804 0 # Node ID cfaf5223b071abb3c4216e44c97d59d1ea0be506 # Parent 5fdca5baa4e9906796988d9969ab8aee375a1a59 trying to get my own mapper working diff -r 5fdca5baa4e9 -r cfaf5223b071 master/src/wecu/run_sac.sh --- a/master/src/wecu/run_sac.sh Thu May 28 12:55:03 2020 +0000 +++ b/master/src/wecu/run_sac.sh Sun May 31 12:06:44 2020 +0000 @@ -1,5 +1,5 @@ #!/bin/bash -# Usage: run_sac.sh numcores hostsFilename workDir map resType patType patterns +# Usage: run_sac.sh numcores hostsFilename workDir mapper (-f filter) resType patType patterns cores=$1 hosts=$2 wd=$3 @@ -8,24 +8,40 @@ shift shift shift +if [ "$1" = "-f" ] +then + shift + filter="$1" + shift +else + filter=\"\" +fi + rm -f allout # Get quoting right... worker () { + set -e + set -o pipefail f=$1 shift - mapper=$1 + j=$1 + shift + mapper="$1" + shift + filter="$1" shift shift # we don't need/want the resType either - hostname 1>&2 + echo $(date) $(hostname) start $f >>${j}_log export PYTHONIOENCODING=utf-8 - curl -s -N https://commoncrawl.s3.amazonaws.com/$f | \ - unpigz -dp 1 -c | tee >(wc -l 1>&2) | ./$mapper "$@" 2>&1 + { curl -s -N https://commoncrawl.s3.amazonaws.com/$f | \ + unpigz -dp 1 -c | $filter ./$mapper "$@" ; } 2>>${j}_log + echo $(date) $(hostname) finished $f >>${j}_log } export -f worker -parallel -v \ +parallel \ --sshloginfile $hosts \ --retries 3 \ --transferfile $(which $mapper|sed 's/\(^.*\/\)/\1.\//') \ @@ -34,5 +50,5 @@ --workdir $wd \ -a input_paths \ --env worker \ - worker '{}' "$mapper" "$@" | tee -a allout | grep -v 'Authorized uses only' | \ + worker '{}' '{#}' "$mapper" "$filter" "$@" 2>errs | grep -v 'Authorized uses only' | tee >(wc -l 1>&2) |\ sac_reducer.py "$@" diff -r 5fdca5baa4e9 -r cfaf5223b071 master/src/wecu/sac_mapper.py --- a/master/src/wecu/sac_mapper.py Thu May 28 12:55:03 2020 +0000 +++ b/master/src/wecu/sac_mapper.py Sun May 31 12:06:44 2020 +0000 @@ -3,8 +3,6 @@ import sys import re -print('args',sys.argv) - is_regex = sys.argv[1] == 'true' search_terms = sys.argv[2:] search_terms_counters = dict() diff -r 5fdca5baa4e9 -r cfaf5223b071 master/src/wecu/sac_reducer.py --- a/master/src/wecu/sac_reducer.py Thu May 28 12:55:03 2020 +0000 +++ b/master/src/wecu/sac_reducer.py Sun May 31 12:06:44 2020 +0000 @@ -1,8 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/python3 import sys from collections import defaultdict +print('reducing',sys.argv,file=sys.stderr) + if sys.argv[1] == 'by-file': # Show results by file for line in sys.stdin: @@ -17,9 +19,11 @@ k = line[0] v = line[1] except: + print('bogus',line,file=sys.stderr) continue counters[k] += int(v) - for k in counters: - print("{}\t{}".format(k, counters[k])) + print('nc',len(counters),file=sys.stderr) + for k,v in counters.items(): + print("{}\t{}".format(k, v)) diff -r 5fdca5baa4e9 -r cfaf5223b071 master/src/wecu/sac_schemes.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master/src/wecu/sac_schemes.py Sun May 31 12:06:44 2020 +0000 @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +'''Assumes export PYTHONIOENCODING=utf-8 has been done if necessary''' + +import sys, json, regex +from collections.abc import Iterable + +META_PATH=['Envelope', 'Payload-Metadata', 'HTTP-Response-Metadata'] + +PATHS={'hdr':['Headers'], + 'head':['HTML-Metadata','Head'], + 'body':['HTML-Metadata','Links']} + +SCHEME=regex.compile('(