<commit_before>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if [ "$#" -ne 1 ] || { [ "$1" != "jgi" ] && [ "$1" != "egsb" ]; }; then
    >&2 echo "Usage $0: search_directory"
    >&2 echo "    where search_directory is one of 'jgi' or 'egsb'"
    exit 128
fi

function finish {
  module unload parallel
}
trap finish EXIT

module load parallel

base_dir="/global/cfs/cdirs/metatlas/raw_data/$1"

log="/global/cfs/cdirs/m2650/file_converter_logs/${1}.log"

converter='/global/common/software/m2650/metatlas-repo/utils/raw_to_h5.sh'

find "$base_dir" -mindepth 2 -maxdepth 2 -type f \
     \( -name '*.raw' -o -name '*.h5' -o -name '*.failed' \) | \
  sed 's%.h5$%.raw%' | \
  sort | \
  uniq -u | \
  sed "s%^%${converter} %" | \
  parallel  >> "$log" 2>&1<commit_msg>feat(convert): do not convert if .failed exists<commit_after>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

if [ "$#" -ne 1 ] || { [ "$1" != "jgi" ] && [ "$1" != "egsb" ]; }; then
    >&2 echo "Usage $0: search_directory"
    >&2 echo "    where search_directory is one of 'jgi' or 'egsb'"
    exit 128
fi

function finish {
  module unload parallel
}
trap finish EXIT

module load parallel

base_dir="/global/cfs/cdirs/metatlas/raw_data/$1"

log="/global/cfs/cdirs/m2650/file_converter_logs/${1}.log"

converter='/global/common/software/m2650/metatlas-repo/utils/raw_to_h5.sh'

find "$base_dir" -mindepth 2 -maxdepth 2 -type f \
     \( -name '*.raw' -o -name '*.h5' -o -name '*.failed' \) | \
  sed 's%.h5$%.raw%' | \
  sed 's%.failed$%.raw%' | \
  sort | \
  uniq -u | \
  sed "s%^%${converter} %" | \
  parallel  >> "$log" 2>&1
{'fraction_non_alphanumeric': 0.21118793211816467, 'fraction_numerical': 0.03268384663733501, 'mean_word_length': 2.989974937343358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1514139', 'n_tokens_mistral': 699, 'n_tokens_neox': 670, 'n_words': 149}