<commit_before># Custom Scalars examples

The example in `custom-scalars` can be used to illustrate both the
default scalar capture mechanism and custom scalars.

    >>> cd("examples/custom-scalars")

## train.py

Default scalars captured when running `train.py` as a script:

    >>> run("guild run train.py -y", ignore="Refreshing")
    step: 1
    loss: 2.345
    accuracy: 0.123
    <BLANKLINE>
    step: 2
    loss: 1.234
    accuracy: 0.456
    <exit 0>

    >>> run("guild runs info --scalars")
    id: ...
    scalars:
      accuracy: 0.456000 (step 2)
      loss: 1.234000 (step 2)
    <exit 0>

We can use the `--test-output-scalars` option of the `run` command to
test custom output scalar patterns against sample script output.

    >>> run("echo 'foo: 1.123' | guild run train.py --test-output-scalars -")
    foo: 1.123
      '^([^ \t]+):\\s+([[0-9\\.e\\-]+)$': [('foo', '1.123')] (foo=1.123)
    <exit 0>

    >>> run("echo 'bar' | guild run train.py --test-output-scalars -")
    bar
      '^([^ \t]+):\\s+([[0-9\\.e\\-]+)$': <no matches>
    <exit 0>
<commit_msg>Fix test<commit_after># Custom Scalars examples

The example in `custom-scalars` can be used to illustrate both the
default scalar capture mechanism and custom scalars.

    >>> cd("examples/custom-scalars")

## train.py

Default scalars captured when running `train.py` as a script:

    >>> run("guild run train.py -y", ignore="Refreshing")
    step: 1
    loss: 2.345
    accuracy: 0.123
    <BLANKLINE>
    step: 2
    loss: 1.234
    accuracy: 0.456
    <exit 0>

    >>> run("guild runs info --scalars")
    id: ...
    scalars:
      accuracy: 0.456000 (step 2)
      loss: 1.234000 (step 2)
    <exit 0>

We can use the `--test-output-scalars` option of the `run` command to
test custom output scalar patterns against sample script output.

    >>> run("echo 'foo: 1.123' | guild run train.py --test-output-scalars -")
    foo: 1.123
      '^([^ \t]+):\\s+([0-9\\.e\\-]+)$': [('foo', '1.123')] (foo=1.123)
    <exit 0>

    >>> run("echo 'bar' | guild run train.py --test-output-scalars -")
    bar
      '^([^ \t]+):\\s+([0-9\\.e\\-]+)$': <no matches>
    <exit 0>

{'fraction_non_alphanumeric': 0.182830626450116, 'fraction_numerical': 0.05382830626450116, 'mean_word_length': 2.557755775577558, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 45, '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': '356660', 'n_tokens_mistral': 862, 'n_tokens_neox': 765, 'n_words': 233}