<commit_before>#!/usr/bin/env python3
"""
PURPOSE: Automate building, installing, and publishing our modules.
This is like a little clone of "lerna" for our purposes.

NOTES:
 - We cannot run "npm ci" in parallel across modules, since we're using workspaces,
   and doing several npm ci at once totally breaks npm.  Of course, it also makes
   it difficult to understand error messages too.
 - Similar for "npm run build" in parallel -- it subtly breaks.

"""

import argparse, json, os, shutil, subprocess, sys, time


def newest_file(path):
    # See https://gist.github.com/brwyatt/c21a888d79927cb476a4.
    return os.popen(
        f'cd "{path}"&& find . -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d" " -f2'
    ).read().strip()


def needs_build(package):
    # We only need to do a build if the newest file in the tree is not
    # in the dist directory.
    path = os.path.join(os.path.dirname(__file__), package)
    newest = newest_file(path)
    return not newest.startswith('./dist/') and not newest.startswith(
        './.next/')


def handle_path(s, path=None, verbose=True):
    desc = s
    if path is not None:
        os.chdir(path)<commit_msg>disable build optimization; it's obviously way too naive.<commit_after>#!/usr/bin/env python3
"""
PURPOSE: Automate building, installing, and publishing our modules.
This is like a little clone of "lerna" for our purposes.

NOTES:
 - We cannot run "npm ci" in parallel across modules, since we're using workspaces,
   and doing several npm ci at once totally breaks npm.  Of course, it also makes
   it difficult to understand error messages too.
 - Similar for "npm run build" in parallel -- it subtly breaks.

"""

import argparse, json, os, shutil, subprocess, sys, time


def newest_file(path):
    # See https://gist.github.com/brwyatt/c21a888d79927cb476a4.
    return os.popen(
        f'cd "{path}"&& find . -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d" " -f2'
    ).read().strip()


def needs_build(package):
    return True
    # Code below was hopelessly naive, e.g, a failed build would not get retried.
    # We only need to do a build if the newest file in the tree is not
    # in the dist directory.
    path = os.path.join(os.path.dirname(__file__), package)
    newest = newest_file(path)
    return not newest.startswith('./dist/') and not newest.startswith(
        './.next/')


def handle_path(s, path=None, verbose=True):
    desc = s
    if path is not None:
        os.chdir(path)
{'fraction_non_alphanumeric': 0.11387329591018444, 'fraction_numerical': 0.0136327185244587, 'mean_word_length': 3.110378912685338, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1828565', 'n_tokens_mistral': 837, 'n_tokens_neox': 789, 'n_words': 311}