Skip to content

Commit

Permalink
style(Pipelines): Use dash delimited names for name and positional args
Browse files Browse the repository at this point in the history
For consistency with long name options.
  • Loading branch information
thewtex committed Aug 31, 2022
1 parent 24bbeb7 commit df5aa7f
Show file tree
Hide file tree
Showing 80 changed files with 276 additions and 258 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/javascript-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Test building a pipeline
run: |
cd test/pipelines/MedianFilterPipeline
cd test/pipelines/median-filter-pipeline
node ../../../src/itk-wasm-cli.js build -i itkwasm/emscripten:latest .
rm -rf web-build
Expand Down
22 changes: 11 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ examples/UMD/package-lock.json
examples/Webpack/package-lock.json
examples/Webpack/cypress/videos/

test/MedianFilterPipeline/itk-wasm
test/pipelines/MedianFilterPipeline/web-build
test/pipelines/MedianFilterPipeline/wasi-build
src/docker/itk-wasm/MedianFilterPipelineCopy/
test/median-filter-pipeline/itk-wasm
test/pipelines/median-filter-pipeline/web-build
test/pipelines/median-filter-pipeline/wasi-build
src/docker/itk-wasm/median-filter-pipelineCopy/

src/docker/itk-wasm/ITKWebAssemblyInterfaceModuleCopy/
test/StdoutStderrPipeline/itk-wasm
test/pipelines/StdoutStderrPipeline/web-build/
test/pipelines/InputOutputFilesPipeline/web-build/
test/pipelines/MeshReadWritePipeline/web-build/
test/pipelines/StdoutStderrPipeline/wasi-build/
test/pipelines/InputOutputFilesPipeline/wasi-build/
test/pipelines/MeshReadWritePipeline/wasi-build/
test/stdout-stderr-pipeline/itk-wasm
test/pipelines/stdout-stderr-pipeline/web-build/
test/pipelines/input-output-files-pipeline/web-build/
test/pipelines/mesh-read-write-pipeline/web-build/
test/pipelines/stdout-stderr-pipeline/wasi-build/
test/pipelines/input-output-files-pipeline/wasi-build/
test/pipelines/mesh-read-write-pipeline/wasi-build/

cypress/screenshots/
cypress/videos/
2 changes: 1 addition & 1 deletion cypress/e2e/core/web_worker_pool.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('WebWorkerPool', () => {

const taskArgsArray = []
for (let index = 0; index < maxTotalSplits; index++) {
const pipelinePath = 'MedianFilterTest'
const pipelinePath = 'median-filter-test'
const args = ['--memory-io', '0', '0', '--radius', '4', '-m', '' + maxTotalSplits, '-s', '' + index]
const desiredOutputs = [
{ type: itk.InterfaceTypes.Image }
Expand Down
2 changes: 1 addition & 1 deletion doc/content/docs/interface_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following [`itk::wasm::Pipeline`](https://github.com/InsightSoftwareConsorti

int main(argc, char * argv[])
{
itk::wasm::Pipeline pipeline("TestPipeline", "A test ITK WASM Pipeline", argc, argv);
itk::wasm::Pipeline pipeline("test-pipeline", "A test ITK WASM Pipeline", argc, argv);

itk::wasm::InputTextStream inputTextStream;
pipeline.add_option("InputText", inputTextStream, "The input text")->required()->type_name("INPUT_TEXT");
Expand Down
6 changes: 3 additions & 3 deletions include/itkSupportInputImageTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ class PipelineFunctor
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();
```
[...]
```
int
main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("Test supporting multiple input image types", argc, argv);
itk::wasm::Pipeline pipeline("support-multiple", "Test supporting multiple input image types", argc, argv);
// Supports the pixels types uint8_t, float
// Supports the image dimensions 2, 3
return itk::wasm::SupportInputImageTypes<PipelineFunctor,
uint8_t,
float>
::Dimensions<2U,3U>("InputImage", pipeline);
::Dimensions<2U,3U>("input-image", pipeline);
}
```
*
Expand Down
6 changes: 3 additions & 3 deletions include/itkSupportInputImageTypesNoVectorImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ class PipelineFunctor
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();
```
[...]
```
int
main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("Test supporting multiple input image types", argc, argv);
itk::wasm::Pipeline pipeline("support-multiple", "Test supporting multiple input image types", argc, argv);
// Supports the pixels types uint8_t, float
// Supports the image dimensions 2, 3
return itk::wasm::SupportInputImageTypesNoVectorImage<PipelineFunctor,
uint8_t,
float>
::Dimensions<2U,3U>("InputImage", pipeline);
::Dimensions<2U,3U>("input-image", pipeline);
}
```
*
Expand Down
6 changes: 3 additions & 3 deletions include/itkSupportInputMeshTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ class PipelineFunctor
using InputMeshType = itk::wasm::InputMesh<MeshType>;
InputMeshType inputMesh;
pipeline.add_option("InputMesh", inputMesh, "The input mesh")->required();
pipeline.add_option("input-mesh", inputMesh, "The input mesh")->required();
```
[...]
```
int
main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("Test supporting multiple input mesh types", argc, argv);
itk::wasm::Pipeline pipeline("support-multiple", "Test supporting multiple input mesh types", argc, argv);
// Supports the pixels types uint8_t, float
// Supports the mesh dimensions 2, 3
return itk::wasm::SupportInputMeshTypes<PipelineFunctor,
uint8_t,
float>
::Dimensions<2U,3U>("InputMesh", pipeline);
::Dimensions<2U,3U>("input-mesh", pipeline);
}
```
* It is assumed that the cell and point data will have the same pixel type.
Expand Down
4 changes: 2 additions & 2 deletions include/itkSupportInputPolyDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class PipelineFunctor
int
main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("TestPipeline", "Test supporting multiple input polydata types", argc, argv);
itk::wasm::Pipeline pipeline("support-multiple", "Test supporting multiple input polydata types", argc, argv);
// Supports the pixels types uint8_t, float
return itk::wasm::SupportInputPolyDataTypes<PipelineFunctor>
::PixelTypes<uint8_t, float>("InputPolyData", pipeline);
::PixelTypes<uint8_t, float>("input-polydata", pipeline);
}
```
* It is assumed that the cell and point data will have the same pixel type.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"test": "npm run test:lint && npm run test:node && npm run test:browser && npm run test:chrome && npm run test:firefox",
"test:lint": "ts-standard --fix \"src/**/*.ts\" && standard --fix \"test/**/*.js\"",
"test:node": "ava test/node/core/*.js test/node/io/image/*.js test/node/io/mesh/*.js test/node/pipeline/*.js",
"test:cliRun": "node src/itk-wasm-cli.js -b wasi-build -s ./test/pipelines/StdoutStderrPipeline run -r wasmtime StdoutStderrTest.wasi.wasm",
"test:cliTest": "node src/itk-wasm-cli.js -b wasi-build -s ./test/pipelines/StdoutStderrPipeline test",
"test:cliRun": "node src/itk-wasm-cli.js -b wasi-build -s ./test/pipelines/stdout-stderr-pipeline run -r wasmtime stdout-stderr-test.wasi.wasm",
"test:cliTest": "node src/itk-wasm-cli.js -b wasi-build -s ./test/pipelines/stdout-stderr-pipeline test",
"test:browser": "karma start ./karma.conf.cjs",
"test:browser:debug": "karma start ./karma.conf.cjs --no-single-run",
"test:browser:debug:cypress": "start-server-and-test start http-get://localhost:8083 cypress:open",
Expand Down
12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ if(EMSCRIPTEN)
set(esm_link_flags " -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0")
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/io/internal/pipelines/common/CompressStringify/BuildZstd.cmake)
add_subdirectory(io/internal/pipelines/common/CompressStringify)
add_subdirectory(io/internal/pipelines/image/ConvertImage)
add_subdirectory(io/internal/pipelines/image/ReadDICOM)
add_subdirectory(io/internal/pipelines/mesh/ConvertMesh)
add_subdirectory(io/internal/pipelines/mesh/MeshToPolyData)
include(${CMAKE_CURRENT_SOURCE_DIR}/io/internal/pipelines/common/compress-stringify/BuildZstd.cmake)
add_subdirectory(io/internal/pipelines/common/compress-stringify)
add_subdirectory(io/internal/pipelines/image/convert-image)
add_subdirectory(io/internal/pipelines/image/read-dicom)
add_subdirectory(io/internal/pipelines/mesh/convert-mesh)
add_subdirectory(io/internal/pipelines/mesh/mesh-to-polydata)

endif() # BUILD_ITK_WASM_IO_MODULES
8 changes: 4 additions & 4 deletions src/build-emscripten.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ if (options.copyBuildArtifacts) {
} // options.copySources

const testPipelines = [
path.join('test', 'pipelines', 'StdoutStderrPipeline'),
path.join('test', 'pipelines', 'MedianFilterPipeline'),
path.join('test', 'pipelines', 'InputOutputFilesPipeline'),
path.join('test', 'pipelines', 'MeshReadWritePipeline'),
path.join('test', 'pipelines', 'stdout-stderr-pipeline'),
path.join('test', 'pipelines', 'median-filter-pipeline'),
path.join('test', 'pipelines', 'input-output-files-pipeline'),
path.join('test', 'pipelines', 'mesh-read-write-pipeline'),
]

if (options.buildTestPipelines) {
Expand Down
8 changes: 4 additions & 4 deletions src/build-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ if (options.copyBuildArtifacts) {
} // options.copySources

const testPipelines = [
path.join('test', 'pipelines', 'StdoutStderrPipeline'),
path.join('test', 'pipelines', 'MedianFilterPipeline'),
path.join('test', 'pipelines', 'InputOutputFilesPipeline'),
path.join('test', 'pipelines', 'MeshReadWritePipeline'),
path.join('test', 'pipelines', 'stdout-stderr-pipeline'),
path.join('test', 'pipelines', 'median-filter-pipeline'),
path.join('test', 'pipelines', 'input-output-files-pipeline'),
path.join('test', 'pipelines', 'mesh-read-write-pipeline'),
]

if (options.buildTestPipelines) {
Expand Down
8 changes: 7 additions & 1 deletion src/core/internal/loadEmscriptenModuleWebWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import axios from 'axios'

import ITKWASMEmscriptenModule from '../ITKWASMEmscriptenModule.js'

function camelCase(kebobCase: string) {
return kebobCase.replace(/-([a-z])/g, (kk) => {
return kk[1].toUpperCase();
});
}

// Load the Emscripten module in the browser in a WebWorker.
//
// baseUrl is usually taken from '../itkConfig.js', but a different value
Expand Down Expand Up @@ -29,7 +35,7 @@ async function loadEmscriptenModuleWebWorker(moduleRelativePathOrURL: string | U
const wasmBinary = response.data
const modulePath = `${modulePrefix}.umd.js`
importScripts(modulePath)
const moduleBaseName: string = modulePrefix.replace(/.*\//, '')
const moduleBaseName: string = camelCase(modulePrefix.replace(/.*\//, ''))
// @ts-ignore: error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'WorkerGlobalScope & typeof globalThis'.
const wrapperModule = self[moduleBaseName] as (moduleParams: object) => object
const emscriptenModule = wrapperModule({ wasmBinary }) as ITKWASMEmscriptenModule
Expand Down
2 changes: 1 addition & 1 deletion src/docker/itk-wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN cd / && \
COPY web-build /usr/local/bin/

# Trigger Emscripten to cache builds of required system libraries
ADD MedianFilterPipelineCopy /MedianFilterPipelineCopy
ADD median-filter-pipelineCopy /median-filter-pipelineCopy
ADD populate-cache.sh /usr/local/bin/populate-cache.sh
RUN /usr/local/bin/populate-cache.sh && rm /usr/local/bin/populate-cache.sh

Expand Down
14 changes: 13 additions & 1 deletion src/docker/itk-wasm/ITKWebAssemblyInterface.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT 17)

if(NOT _ITKWebAssemblyInterface_INCLUDED)

function(kebab_to_camel kebab camel)
set(result "${kebab}")
while(result MATCHES "-([a-z])")
string(REGEX MATCH "-([a-z])" post_dash "${result}")
string(SUBSTRING "${post_dash}" 1 1 post_dash)
string(TOUPPER "${post_dash}" post_dash_upper)
string(REGEX REPLACE "(-${post_dash})" "${post_dash_upper}" result "${result}")
endwhile()
set(${camel} "${result}" PARENT_SCOPE)
endfunction()

set(_target_link_libraries target_link_libraries)
function(target_link_libraries target)
_target_link_libraries(${target} ${ARGN})
Expand Down Expand Up @@ -34,8 +45,9 @@ function(add_executable target)
set(umd_target ${wasm_target}.umd)
_add_executable(${umd_target} ${ARGN})

kebab_to_camel(${target} targetCamel)
get_property(_link_flags TARGET ${target} PROPERTY LINK_FLAGS)
set(common_link_flags " -s FORCE_FILESYSTEM=1 -s EXPORTED_RUNTIME_METHODS='[\"callMain\",\"cwrap\",\"ccall\",\"writeArrayToMemory\",\"writeAsciiToMemory\",\"AsciiToString\"]' -flto -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -lnodefs.js -s WASM_ASYNC_COMPILATION=1 -s EXPORT_NAME=${target} -s MODULARIZE=1 -s EXIT_RUNTIME=0 -s INVOKE_RUN=0 --pre-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPipelinePre.js --post-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPost.js -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORTED_FUNCTIONS='[\"_main\"]' ${_link_flags}")
set(common_link_flags " -s FORCE_FILESYSTEM=1 -s EXPORTED_RUNTIME_METHODS='[\"callMain\",\"cwrap\",\"ccall\",\"writeArrayToMemory\",\"writeAsciiToMemory\",\"AsciiToString\"]' -flto -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -lnodefs.js -s WASM_ASYNC_COMPILATION=1 -s EXPORT_NAME=${targetCamel} -s MODULARIZE=1 -s EXIT_RUNTIME=0 -s INVOKE_RUN=0 --pre-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPipelinePre.js --post-js /ITKWebAssemblyInterface/src/emscripten-module/itkJSPost.js -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORTED_FUNCTIONS='[\"_main\"]' ${_link_flags}")
set_property(TARGET ${wasm_target} PROPERTY LINK_FLAGS "${common_link_flags} -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0")
set_property(TARGET ${umd_target} PROPERTY LINK_FLAGS "${common_link_flags}")

Expand Down
6 changes: 3 additions & 3 deletions src/docker/itk-wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ mkdir -p ITKWebAssemblyInterfaceModuleCopy
rsync -a ../../../{include,CMakeLists.txt,itk-module.cmake} ./ITKWebAssemblyInterfaceModuleCopy/
rsync -a ../../../src/{*.cxx,CMakeLists.txt} ./ITKWebAssemblyInterfaceModuleCopy/src/
rsync -a ../../../src/emscripten-module ./ITKWebAssemblyInterfaceModuleCopy/src/
mkdir -p MedianFilterPipelineCopy
rsync -a ../../../test/pipelines/MedianFilterPipeline/{CMakeLists.txt,MedianFilterTest.cxx} ./MedianFilterPipelineCopy
mkdir -p median-filter-pipelineCopy
rsync -a ../../../test/pipelines/median-filter-pipeline/{CMakeLists.txt,median-filter-test.cxx} ./median-filter-pipelineCopy

TAG=$(date '+%Y%m%d')-$(git rev-parse --short HEAD)
VCS_REF=$(git rev-parse --short HEAD)
Expand Down Expand Up @@ -121,4 +121,4 @@ if $debug; then
fi


rm -rf ITKWebAssemblyInterfaceModuleCopy MedianFilterPipelineCopy
rm -rf ITKWebAssemblyInterfaceModuleCopy median-filter-pipelineCopy
4 changes: 2 additions & 2 deletions src/docker/itk-wasm/populate-cache.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [ $BASE_IMAGE = "itkwasm/emscripten-base" ]; then
cd /MedianFilterPipelineCopy
cd /median-filter-pipelineCopy

/usr/local/bin/web-build web-build -DCMAKE_EXE_LINKER_FLAGS='-flto=thin -s DISABLE_EXCEPTION_CATCHING=0'
rm -rf ./web-build
Expand All @@ -11,6 +11,6 @@ if [ $BASE_IMAGE = "itkwasm/emscripten-base" ]; then

/usr/local/bin/web-build web-build -DCMAKE_EXE_LINKER_FLAGS='-fno-lto -s DISABLE_EXCEPTION_CATCHING=1'

rm -rf /MedianFilterPipelineCopy
rm -rf /median-filter-pipelineCopy
chmod -R 777 /emsdk/upstream/emscripten/cache
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(CompressStringify)
project(compress-stringify)

set(CMAKE_CXX_STANDARD 17)

Expand All @@ -20,16 +20,16 @@ FetchContent_MakeAvailable(cpp_base64)

find_package(ITK REQUIRED COMPONENTS WebAssemblyInterface)

add_executable(CompressStringify CompressStringify.cxx)
target_include_directories(CompressStringify PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${zstd_lib_INCLUDE_DIR})
target_link_libraries(CompressStringify PUBLIC libzstd_static cpp-base64 ${ITK_LIBRARIES})
add_executable(compress-stringify compress-stringify.cxx)
target_include_directories(compress-stringify PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${zstd_lib_INCLUDE_DIR})
target_link_libraries(compress-stringify PUBLIC libzstd_static cpp-base64 ${ITK_LIBRARIES})

add_executable(ParseStringDecompress ParseStringDecompress.cxx)
target_include_directories(ParseStringDecompress PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${zstd_lib_INCLUDE_DIR})
target_link_libraries(ParseStringDecompress PUBLIC libzstd_static cpp-base64 ${ITK_LIBRARIES})
add_executable(parse-string-decompress parse-string-decompress.cxx)
target_include_directories(parse-string-decompress PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${zstd_lib_INCLUDE_DIR})
target_link_libraries(parse-string-decompress PUBLIC libzstd_static cpp-base64 ${ITK_LIBRARIES})

if (DEFINED WebAssemblyInterface_SOURCE_DIR AND EMSCRIPTEN)
foreach(target CompressStringify CompressStringify.umd ParseStringDecompress ParseStringDecompress.umd)
foreach(target compress-stringify compress-stringify.umd parse-string-decompress parse-string-decompress.umd)
itk_module_target_label(${target})
itk_module_target_export(${target})
itk_module_target_install(${target})
Expand All @@ -40,7 +40,7 @@ if (DEFINED WebAssemblyInterface_SOURCE_DIR AND EMSCRIPTEN)
endforeach()
endif()
if (DEFINED WebAssemblyInterface_SOURCE_DIR AND WASI)
foreach(target CompressStringify ParseStringDecompress)
foreach(target compress-stringify parse-string-decompress)
itk_module_target_label(${target})
itk_module_target_export(${target})
itk_module_target_install(${target})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
int compress(itk::wasm::Pipeline & pipeline, itk::wasm::InputBinaryStream & inputBinaryStream, int compressionLevel)
{
itk::wasm::OutputBinaryStream outputBinaryStream;
pipeline.add_option("Output", outputBinaryStream, "Output compressed binary");
pipeline.add_option("output", outputBinaryStream, "Output compressed binary")->type_name("OUTPUT_BINARY_STREAM");

ITK_WASM_PARSE(pipeline);

Expand All @@ -58,7 +58,7 @@ int compress(itk::wasm::Pipeline & pipeline, itk::wasm::InputBinaryStream & inpu
int compressStringify(itk::wasm::Pipeline & pipeline, itk::wasm::InputBinaryStream & inputBinaryStream, int compressionLevel, const std::string & dataURLPrefix)
{
itk::wasm::OutputTextStream outputTextStream;
pipeline.add_option("Output", outputTextStream, "Output dataURL+base64 compressed binary");
pipeline.add_option("output", outputTextStream, "Output dataURL+base64 compressed binary")->type_name("OUTPUT_TEXT_STREAM");

ITK_WASM_PARSE(pipeline);

Expand Down Expand Up @@ -86,10 +86,10 @@ int compressStringify(itk::wasm::Pipeline & pipeline, itk::wasm::InputBinaryStre

int main(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("CompressStringify", "Given a binary, compress optionally base64 encode", argc, argv);
itk::wasm::Pipeline pipeline("compress-stringify", "Given a binary, compress optionally base64 encode", argc, argv);

itk::wasm::InputBinaryStream inputBinaryStream;
pipeline.add_option("InputBinary", inputBinaryStream, "Input binary");
pipeline.add_option("input", inputBinaryStream, "Input binary")->type_name("INPUT_BINARY_STREAM");

bool stringify = false;
pipeline.add_flag("-s,--stringify", stringify, "Stringify the output");
Expand Down
Loading

0 comments on commit df5aa7f

Please sign in to comment.