Skip to content

Commit

Permalink
docs(hello-pipeline,inputs-outputs): Update for pipeline name, type_name
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Aug 31, 2022
1 parent c6182e5 commit 7c64db4
Show file tree
Hide file tree
Showing 81 changed files with 13,730 additions and 67 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/examples.yml
Expand Up @@ -4,11 +4,11 @@ on: [push,pull_request]

jobs:
test-node-example:
name: Node.js
name: node-js
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./examples/Node.js
working-directory: ./examples/node-js

steps:
- uses: actions/checkout@v2
Expand All @@ -26,12 +26,12 @@ jobs:
npm run test
build-hello-world-example:
name: Hello World Build
name: hello-world build
runs-on: ubuntu-20.04

defaults:
run:
working-directory: ./examples/HelloWorld
working-directory: ./examples/hello-world

steps:
- uses: actions/checkout@v2
Expand All @@ -54,8 +54,8 @@ jobs:
name: hello-world-build
if-no-files-found: error
path: |
examples/HelloWorld/web-build
examples/HelloWorld/wasi-build
examples/hello-world/web-build
examples/hello-world/wasi-build
test-hello-world-example:
Expand All @@ -66,7 +66,7 @@ jobs:

defaults:
run:
working-directory: ./examples/HelloWorld
working-directory: ./examples/hello-world

steps:
- uses: actions/checkout@v2
Expand All @@ -75,22 +75,22 @@ jobs:
uses: actions/download-artifact@v2
with:
name: hello-world-build
path: examples/HelloWorld
path: examples/hello-world

- name: Test
uses: cypress-io/github-action@v2
with:
working-directory: ./examples/HelloWorld
working-directory: ./examples/hello-world
browser: chrome
start: npm start

build-test-hello-pipeline-example:
name: Hello Pipeline Build Test
name: hello-pipeline build test
runs-on: ubuntu-20.04

defaults:
run:
working-directory: ./examples/HelloPipeline
working-directory: ./examples/hello-pipeline

steps:
- uses: actions/checkout@v3
Expand All @@ -114,12 +114,12 @@ jobs:
npm run test:help
build-test-inputs-outputs-example:
name: Inputs Outputs
name: inputs-outputs
runs-on: ubuntu-20.04

defaults:
run:
working-directory: ./examples/InputsOutputs
working-directory: ./examples/inputs-outputs

steps:
- uses: actions/checkout@v3
Expand All @@ -141,7 +141,7 @@ jobs:
npm run test
test-umd-example:
name: UMD
name: umd
runs-on: ubuntu-20.04

steps:
Expand All @@ -150,12 +150,12 @@ jobs:
- name: Test
uses: cypress-io/github-action@v4
with:
working-directory: ./examples/UMD
working-directory: ./examples/umd
browser: chrome
start: npm start

test-webpack-example:
name: Webpack
name: webpack
runs-on: ubuntu-20.04

steps:
Expand All @@ -164,19 +164,19 @@ jobs:
- name: Test Webpack Example on Chrome
uses: cypress-io/github-action@v4
with:
working-directory: ./examples/Vite
working-directory: ./examples/webpack
browser: chrome
start: npm start

- name: Test Webpack Example on Firefox
uses: cypress-io/github-action@v4
with:
working-directory: ./examples/Vite
working-directory: ./examples/webpack
browser: firefox
start: npm start

test-vite-example:
name: Vite
name: vite
runs-on: ubuntu-20.04

steps:
Expand All @@ -185,23 +185,23 @@ jobs:
- name: Test Vite Example on Chrome
uses: cypress-io/github-action@v4
with:
working-directory: ./examples/Vite
working-directory: ./examples/vite
browser: chrome
start: npm start

- name: Test Vite Example on Firefox
uses: cypress-io/github-action@v4
with:
working-directory: ./examples/Vite
working-directory: ./examples/vite
browser: firefox
start: npm start

test-debugging-example:
name: Debugging
name: debugging
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./examples/Debugging
working-directory: ./examples/debugging

steps:
- uses: actions/checkout@v2
Expand Down
26 changes: 13 additions & 13 deletions doc/content/examples/hello_pipeline.md
Expand Up @@ -12,11 +12,11 @@ Make sure to complete the [Hello World!](./hello_world.html) example before you
First, let's create a new directory to house our project.

```sh
mkdir HelloPipeline
cd HelloPipeline
mkdir hello-pipeline
cd hello-pipeline
```

Let's write some code! Populate *HelloPipeline.cxx* first with the headers we need:
Let's write some code! Populate *hello-pipeline.cxx* first with the headers we need:

```c++
#include "itkPipeline.h"
Expand All @@ -34,7 +34,7 @@ Next, create a standard `main` C command line interface function and an `itk::wa
```c++
int main(int argc, char * argv[]) {
// Create the pipeline for parsing arguments. Provide a description.
itk::wasm::Pipeline pipeline("A hello world itk::wasm::Pipeline", argc, argv);
itk::wasm::Pipeline pipeline("hello-pipeline", "A hello world itk::wasm::Pipeline", argc, argv);

return EXIT_SUCCESS;
}
Expand All @@ -50,7 +50,7 @@ The `itk::wasm::Pipeline` extends the most-excellent [CLI11 modern C++ command l
Add a standard CLI11 flag to the pipeline:
```c++
itk::wasm::Pipeline pipeline("A hello world itk::wasm::Pipeline", argc, argv);
itk::wasm::Pipeline pipeline("hello-pipeline", "A hello world itk::wasm::Pipeline", argc, argv);
bool quiet = false;
Expand All @@ -70,15 +70,15 @@ Add an input image argument to the pipeline:
// Add a input image argument.
using InputImageType = itk::wasm::InputImage<ImageType>;
InputImageType inputImage;
pipeline.add_option("InputImage", inputImage, "The input image")->required();
pipeline.add_option("input-image", inputImage, "The input image")->required()->type_name("INPUT_IMAGE");
```
The `inputImage` variable is populated from the filesystem if built as a native executable or a WASI binary run from the command line. When running in the browser or in a wrapped language, `inputImage` is read from WebAssembly memory without file IO.
Parse the command line arguments with the `ITK_WASM_PARSE` macro:
```c++
pipeline.add_option("InputImage", inputImage, "The input image")->required();
pipeline.add_option("InputImage", inputImage, "The input image")->required()->type_name("INPUT_IMAGE");
ITK_WASM_PARSE(pipeline);
Expand All @@ -103,7 +103,7 @@ Next, provide a [CMake](https://cmake.org/) build configuration at *CMakeLists.t
```cmake
cmake_minimum_required(VERSION 3.16)
project(HelloPipeline)
project(hello-pipeline)
# Use C++17 or newer with itk-wasm
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -130,8 +130,8 @@ find_package(ITK REQUIRED
)
include(${ITK_USE_FILE})
add_executable(HelloPipeline HelloPipeline.cxx)
target_link_libraries(HelloPipeline PUBLIC ${ITK_LIBRARIES})
add_executable(hello-pipeline hello-pipeline.cxx)
target_link_libraries(hello-pipeline PUBLIC ${ITK_LIBRARIES})
```

## Create WebAssembly binary
Expand All @@ -147,7 +147,7 @@ npx itk-wasm -i itkwasm/wasi build
Check the generated help output:

```sh
npx itk-wasm run HelloPipeline.wasi.wasm -- -- --help
npx itk-wasm run hello-pipeline.wasi.wasm -- -- --help
```

![Hello pipeline help](./hello_pipeline.png)
Expand All @@ -157,7 +157,7 @@ The two `--`'s are to separate arguments for the WASM module from arguments to t
Try running on an [example image](https://data.kitware.com/api/v1/file/63041ac8f64de9b9501e5a22/download).

```
> npx itk-wasm run HelloPipeline.wasi.wasm -- -- cthead1.png
> npx itk-wasm run hello-pipeline.wasi.wasm -- -- cthead1.png
Hello pipeline world!
Expand Down Expand Up @@ -225,7 +225,7 @@ Input image: Image (0x2b910)
And with the `--quiet` flag:

```
> npx itk-wasm run HelloPipeline.wasi.wasm -- -- --quiet cthead1.png
> npx itk-wasm run hello-pipeline.wasi.wasm -- -- --quiet cthead1.png
Hello pipeline world!
```
Expand Down
28 changes: 14 additions & 14 deletions doc/content/examples/inputs_outputs.md
Expand Up @@ -12,11 +12,11 @@ Make sure to complete the [Hello Pipeline!](./hello_pipeline.html) example befor
First, let's create a new directory to house our project.

```sh
mkdir InputsOutputs
cd InputsOutputs
mkdir inputs-outputs
cd inputs-outputs
```

Let's write some code! Populate *InputsOutputs.cxx* with the headers we need:
Let's write some code! Populate *inputs-outputs.cxx* with the headers we need:

```c++
#include "itkPipeline.h"
Expand All @@ -36,15 +36,15 @@ Next, create a standard `main` C command line interface function and an `itk::wa
```c++
int main(int argc, char * argv[]) {
// Create the pipeline for parsing arguments. Provide a description.
itk::wasm::Pipeline pipeline("Smooth an image with a median filter", argc, argv);
itk::wasm::Pipeline pipeline("median-filter", "Smooth an image with a median filter", argc, argv);

return EXIT_SUCCESS;
}
```
Add options to the pipeline that define our inputs, outputs, and processing parameters.
```c++
itk::wasm::Pipeline pipeline("Smooth an image with a median filter", argc, argv);
itk::wasm::Pipeline pipeline("median-filter", "Smooth an image with a median filter", argc, argv);
constexpr unsigned int Dimension = 2;
Expand All @@ -59,12 +59,12 @@ Add options to the pipeline that define our inputs, outputs, and processing para
// Add a input image argument.
using InputImageType = itk::wasm::InputImage<ImageType>;
InputImageType inputImage;
pipeline.add_option("InputImage", inputImage, "The input image")->required();
pipeline.add_option("input-image", inputImage, "The input image")->required()->type_name("INPUT_IMAGE");
// Add an output image argument.
using OutputImageType = itk::wasm::OutputImage<ImageType>;
OutputImageType outputImage;
pipeline.add_option("OutputImage", outputImage, "The output image")->required();
pipeline.add_option("output-image", outputImage, "The output image")->required()->type_name("OUTPUT_IMAGE");
```

The `inputImage` variable is populated from the filesystem if built as a native executable or a WASI binary run from the command line. When running in the browser or in a wrapped language, `inputImage` is read from WebAssembly memory without file IO.
Expand All @@ -74,15 +74,15 @@ When the program completes, `outputImage` is written to the filesystem if built
Parse the command line arguments with the `ITK_WASM_PARSE` macro:

```c++
pipeline.add_option("OutputImage", outputImage, "The output image")->required();
pipeline.add_option("output-image", outputImage, "The output image")->required()->type_name("OUTPUT_IMAGE");


ITK_WASM_PARSE(pipeline);
```
The `-h` and `--help` flags are automatically generated from pipeline arguments to print usage information.
![InputsOutputs help](./inputs_outputs_help.png)
![inputs-outputs help](./inputs_outputs_help.png)
Finally, process our data:
```c++
Expand All @@ -105,7 +105,7 @@ Next, provide a [CMake](https://cmake.org/) build configuration at *CMakeLists.t

```cmake
cmake_minimum_required(VERSION 3.16)
project(InputsOutputs)
project(inputs-outputs)
# Use C++17 or newer with itk-wasm
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -133,8 +133,8 @@ find_package(ITK REQUIRED
)
include(${ITK_USE_FILE})
add_executable(InputsOutputs InputsOutputs.cxx)
target_link_libraries(InputsOutputs PUBLIC ${ITK_LIBRARIES})
add_executable(inputs-outputs inputs-outputs.cxx)
target_link_libraries(inputs-outputs PUBLIC ${ITK_LIBRARIES})
```

## Create WebAssembly binary
Expand All @@ -150,7 +150,7 @@ Try running on an [example image](https://data.kitware.com/api/v1/file/63041ac8f
## Run WebAssembly binary

```sh
npx itk-wasm -b wasi-build run InputsOutputs.wasi.wasm -- -- --radius 2 cthead1.png smoothed.png
npx itk-wasm -b wasi-build run inputs-outputs.wasi.wasm -- -- --radius 2 cthead1.png smoothed.png
```

The input image:
Expand Down Expand Up @@ -220,7 +220,7 @@ Run the pipeline.

```javascript
// Path to the Emscripten WebAssembly module without extensions
const pipelinePath = path.resolve('web-build', 'InputsOutputs')
const pipelinePath = path.resolve('web-build', 'inputs-outputs')
const { stdout, stderr, outputs } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs)
```

Expand Down
Empty file removed examples/Webpack/.gitignore
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(HelloPipeline)
project(hello-pipeline)

# Use C++17 or newer with itk-wasm
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -26,5 +26,5 @@ find_package(ITK REQUIRED
)
include(${ITK_USE_FILE})

add_executable(HelloPipeline HelloPipeline.cxx)
target_link_libraries(HelloPipeline PUBLIC ${ITK_LIBRARIES})
add_executable(hello-pipeline hello-pipeline.cxx)
target_link_libraries(hello-pipeline PUBLIC ${ITK_LIBRARIES})
File renamed without changes

0 comments on commit 7c64db4

Please sign in to comment.