<commit_before># Hello examples

The `hello` example provides a simple model that prints messages for
it operations.

We'll run through the various operations in this test.

    >>> cd("examples/hello")

## Models

    >>> run("guild models")
    Limiting models to the current directory (use --all to include all)
    ./hello  A "hello world" sample model
    <exit 0>

## Operations

    >>> run("guild operations")
    Limiting models to the current directory (use --all to include all)
    ./hello:default           Print a default message
    ./hello:from-file         Print a message from a file
    ./hello:from-file-output  Print output from last file-output operation
    ./hello:from-flag         Print a message
    <exit 0>

### `default`

The `default` operation simply prints a hard-coded message.

    >>> run("guild run default -y")
    Hello Guild!
    <exit 0>

### `from-flag`

The `from-flag` operation prints a message defined by a flag.

Here's the default output:

    >>> run("guild run from-flag -y")
    Hello Guild, from a flag!
    <exit 0>

And the output when we provide a value for the message flag:

    >>> run("guild run from-flag message='Howdy Guild!' -y")
    Howdy Guild!
    <exit 0>

### `from-file-output` part 1

The `from-file-output` operation requires output from the `from-file`
operation. When we try to run it without first having a completed run
for `from-file` we get an error.

    >>> run("guild run from-file-output -y")
    Resolving file-output resource
    guild: run failed because a dependency was not met: could not resolve
    'operation:from-file' in file-output resource: no suitable
    run for ./hello:from-file
    <exit 1>

### `from-file`

The `from-file` operation prints a message contained in a file. By
default it will print the contents of a default file:

    >>> run("guild run from-file -y")
    Resolving msg-file resource
    Using .../examples/hello/msg.txt for msg-file resource
    Hello Guild, from a required file!
    <exit 0>

Note that this file is specified as a required resource in the model.

We can provide an alternative.

    >>> quiet("echo 'Yo yo, what up Guild!' > $WORKSPACE/alt-msg")
    >>> run("guild run from-file file=$WORKSPACE/alt-msg -y")
    Resolving msg-file resource
    Using .../examples/hello/msg.txt for msg-file resource
    Yo yo, what up Guild!
    <exit 0>

### `from-file-output` part 2

Now that we have a successful run of `from-file` we can run
`from-from-output`:

    >>> run("guild run from-file-output -y")
    Resolving file-output resource
    Using .../runs/... for file-output resource
    Latest from-file output:
    Yo yo, what up Guild!
    <exit 0><commit_msg>Update tests per latest<commit_after># Hello examples

The `hello` example provides a simple model that prints messages for
it operations.

We'll run through the various operations in this test.

    >>> cd("examples/hello")

## Models

    >>> run("guild models")
    Limiting models to the current directory (use --all to include all)
    ./hello  A "hello world" sample model
    <exit 0>

## Operations

    >>> run("guild operations")
    Limiting models to the current directory (use --all to include all)
    ./hello:default           Print a default message
    ./hello:from-file         Print a message from a file
    ./hello:from-file-output  Print output from last file-output operation
    ./hello:from-flag         Print a message
    <exit 0>

### `default`

The `default` operation simply prints a hard-coded message.

    >>> run("guild run default -y")
    Hello Guild!
    <exit 0>

### `from-flag`

The `from-flag` operation prints a message defined by a flag.

Here's the default output:

    >>> run("guild run from-flag -y")
    Hello Guild, from a flag!
    <exit 0>

And the output when we provide a value for the message flag:

    >>> run("guild run from-flag message='Howdy Guild!' -y")
    Howdy Guild!
    <exit 0>

### `from-file`

The `from-file` operation prints a message contained in a file. By
default it will print the contents of a default file:

    >>> run("guild run from-file -y")
    Resolving msg-file resource
    Using .../examples/hello/msg.txt for msg-file resource
    Hello Guild, from a required file!
    <exit 0>

Note that this file is specified as a required resource in the model.

We can provide an alternative.

    >>> quiet("echo 'Yo yo, what up Guild!' > $WORKSPACE/alt-msg")
    >>> run("guild run from-file file=$WORKSPACE/alt-msg -y")
    Resolving msg-file resource
    Using .../examples/hello/msg.txt for msg-file resource
    Yo yo, what up Guild!
    <exit 0>

### `from-file-output`

When we run `from-file-output`, we get the latest output from
`from-file`:

    >>> run("guild run from-file-output -y")
    Resolving file-output resource
    Using .../runs/... for file-output resource
    Latest from-file output:
    Yo yo, what up Guild!
    <exit 0>

We can specify an alternative run for `from-file-output` using the
`--resource` option. This takes the form:

    --resource RESOURCE-NAME RUN-ID

The resource name associated with the `from-file` operation is named
`file-output`. So we'll specify the altnerative run this way:

    --resource file-output RUN-ID

We'll use the first run for `from-file`.

    >>> run("""
    ... run_id=`guild runs | grep from-file | tail -n1 | cut -d: -f2 | cut -b 1-8`
    ... guild run from-file-output --resource file-output $run_id -y
    ... """)
    Resolving file-output resource
    Using .../runs/... for file-output resource
    Latest from-file output:
    Hello Guild, from a required file!
    <exit 0>
{'fraction_non_alphanumeric': 0.11174377224199289, 'fraction_numerical': 0.004270462633451958, 'mean_word_length': 2.8447332421340628, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 89, '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': '6871905', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1645, 'n_words': 699}