Skip to content

Commit

Permalink
Merge pull request #972 from thewtex/bindgen-pipeline-worker
Browse files Browse the repository at this point in the history
refactor(bindgen): update to bundler-generated web workers
  • Loading branch information
thewtex authored Nov 9, 2023
2 parents 94fffd7 + 00e8a51 commit e8ac26b
Show file tree
Hide file tree
Showing 575 changed files with 30,309 additions and 1,831 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ test/pipelines/bindgen-interface-types-pipeline/wasi-build/
test/pipelines/bindgen-interface-types-pipeline/python-web-demo/

packages/image-io/test/
packages/image-io/typescript/demo-app-rollup/
packages/image-io/python/itkwasm-image-io-wasi/itkwasm_image_io_wasi/wasm_modules/

cypress/screenshots/
cypress/videos/
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
"build:webpack": "webpack --mode production --progress --color && webpack --mode development --progress --color",
"build:emscripten": "node ./src/build-emscripten.js",
"build:emscripten:compress-stringify": "node ./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build build ",
"build:bindgen:typescript:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build bindgen --package-version 0.6.1 --package-name @itk-wasm/compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b wasi-build bindgen --interface python --package-name itkwasm-compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --package-version 0.6.1 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python-web-demo:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build bindgen --interface python-web-demo --package-name itkwasm-compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --package-version 0.6.1 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:typescript:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build bindgen --package-version 2.0.1 --package-name @itk-wasm/compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b wasi-build bindgen --interface python --package-name itkwasm-compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --package-version 2.0.1 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python-web-demo:compress-stringify": "./src/itk-wasm-cli.js -s packages/compress-stringify -b emscripten-build bindgen --interface python-web-demo --package-name itkwasm-compress-stringify --package-description \"Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.\" --package-version 2.0.1 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:emscripten:dicom": "node ./src/itk-wasm-cli.js -s packages/dicom -b emscripten-build build",
"build:bindgen:typescript:dicom": "./src/itk-wasm-cli.js -s packages/dicom -b emscripten-build bindgen --package-version 3.3.0 --package-name @itk-wasm/dicom --package-description \"Read files and images related to DICOM file format.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:dicom": "./src/itk-wasm-cli.js -s packages/dicom -b wasi-build bindgen --package-version 3.3.0 --interface python --package-name itkwasm-dicom --package-description \"Read files and images related to DICOM file format.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:typescript:dicom": "./src/itk-wasm-cli.js -s packages/dicom -b emscripten-build bindgen --package-version 5.0.0 --package-name @itk-wasm/dicom --package-description \"Read files and images related to DICOM file format.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:dicom": "./src/itk-wasm-cli.js -s packages/dicom -b wasi-build bindgen --package-version 5.0.0 --interface python --package-name itkwasm-dicom --package-description \"Read files and images related to DICOM file format.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:emscripten:compare-images": "node ./src/itk-wasm-cli.js -s packages/compare-images -b emscripten-build build",
"build:bindgen:typescript:compare-images": "./src/itk-wasm-cli.js -s packages/compare-images -b emscripten-build bindgen --package-version 1.0.1 --package-name @itk-wasm/compare-images --package-description \"Compare images with a tolerance for regression testing.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:compare-images": "./src/itk-wasm-cli.js -s packages/compare-images -b wasi-build bindgen --package-version 1.0.1 --interface python --package-name itkwasm-compare-images --package-description \"Compare images with a tolerance for regression testing.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:typescript:compare-images": "./src/itk-wasm-cli.js -s packages/compare-images -b emscripten-build bindgen --package-version 4.0.0 --package-name @itk-wasm/compare-images --package-description \"Compare images with a tolerance for regression testing.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:compare-images": "./src/itk-wasm-cli.js -s packages/compare-images -b wasi-build bindgen --package-version 4.0.0 --interface python --package-name itkwasm-compare-images --package-description \"Compare images with a tolerance for regression testing.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:emscripten:image-io": "node ./src/itk-wasm-cli.js -s packages/image-io -b emscripten-build build",
"build:bindgen:typescript:image-io": "./src/itk-wasm-cli.js -s packages/image-io -b emscripten-build bindgen --package-version 0.1.0 --package-name @itk-wasm/image-io --package-description \"Input and output for scientific and medical image file formats.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:image-io": "./src/itk-wasm-cli.js -s packages/image-io -b wasi-build bindgen --interface python --package-name itkwasm-image-io --package-description \"Input and output for scientific and medical image file formats.\" --package-version 0.1.0 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:typescript:image-io": "./src/itk-wasm-cli.js -s packages/image-io -b emscripten-build bindgen --package-version 0.5.0 --package-name @itk-wasm/image-io --package-description \"Input and output for scientific and medical image file formats.\" --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:bindgen:python:image-io": "./src/itk-wasm-cli.js -s packages/image-io -b wasi-build bindgen --interface python --package-name itkwasm-image-io --package-description \"Input and output for scientific and medical image file formats.\" --package-version 0.5.0 --repository 'https://github.com/InsightSoftwareConsortium/itk-wasm'",
"build:emscripten:packages": "npm run build:emscripten:compress-stringify && npm run build:bindgen:typescript:compress-stringify && npm run build:emscripten:dicom && npm run build:bindgen:typescript:dicom && npm run build:emscripten:compare-images && npm run build:bindgen:typescript:compare-images && npm run build:emscripten:image-io && npm run build:bindgen:typescript:image-io",
"build:wasi": "node ./src/build-wasi.js && npm run build:wasi:packages",
"build:wasi:compress-stringify": "node ./src/itk-wasm-cli.js -i itkwasm/wasi:latest -s packages/compress-stringify -b wasi-build build",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.1"
__version__ = "4.0.0"

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
keywords = [
"itkwasm",
Expand All @@ -31,7 +32,7 @@ keywords = [

requires-python = ">=3.8"
dependencies = [
"itkwasm >= 1.0.b131",
"itkwasm >= 1.0.b145",
]

[tool.hatch.version]
Expand All @@ -42,7 +43,7 @@ dependencies = [
"pytest",
"pytest-pyodide",
"itk-webassemblyinterface >= 1.0.b127",
"itkwasm >= 1.0.b131",
"itkwasm >= 1.0.b145",
]

[project.urls]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def input_data():
]
data = {}
for f in test_files:
path = str(input_base_path / f) + '.pickle'
with open(path, 'rb') as fp:
data[str(f.name)] = pickle.load(fp)
with open(input_base_path / f, 'rb') as fp:
data[str(f.name)] = fp.read()
return data
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@
@run_in_pyodide(packages=['micropip', 'numpy'])
async def test_compare_double_images_async(selenium, package_wheel, input_data):
import micropip
await micropip.install(package_wheel, 'numpy', 'itkwasm')
await micropip.install(package_wheel)
await micropip.install('itkwasm-image-io-emscripten')
def write_input_data_to_fs(input_data, filename):
with open(filename, 'wb') as fp:
fp.write(input_data[filename])

from itkwasm_compare_images_emscripten import compare_double_images_async
import numpy as np
from itkwasm import Image
from itkwasm.pyodide import to_js as itkwasm_to_js
from itkwasm_compare_images_emscripten import compare_double_images_async
from itkwasm_image_io_emscripten import imread_async

test_image_file = 'cake_easy.iwi.cbor'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.iwi.cbor'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_double_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -37,18 +44,25 @@ async def test_compare_double_images_async(selenium, package_wheel, input_data):
@run_in_pyodide(packages=['micropip', 'numpy'])
async def test_compare_images_async(selenium, package_wheel, input_data):
import micropip
await micropip.install(package_wheel, 'numpy', 'itkwasm')
await micropip.install(package_wheel)
await micropip.install('itkwasm-image-io-emscripten')
def write_input_data_to_fs(input_data, filename):
with open(filename, 'wb') as fp:
fp.write(input_data[filename])

from itkwasm_compare_images_emscripten import compare_images_async
from itkwasm_image_io_emscripten import imread_async
import numpy as np
from itkwasm import Image
from itkwasm.pyodide import to_js as itkwasm_to_js

test_image_file = 'cake_easy.iwi.cbor'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.iwi.cbor'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -63,10 +77,12 @@ async def test_compare_images_async(selenium, package_wheel, input_data):
assert difference_image_rendering.imageType.componentType == 'uint8'

test_image_file = 'cake_easy.png'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.png'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -81,19 +97,21 @@ async def test_compare_images_async(selenium, package_wheel, input_data):
assert difference_image_rendering.imageType.componentType == 'uint8'

test_image_file = 'apple.jpg'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'orange.jpg'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

assert metrics['almostEqual'] == False
assert metrics['numberOfPixelsWithDifferences'] == 26477
assert metrics['minimumDifference'] == 0.002273026683894841
assert metrics['maximumDifference'] == 312.2511648746159
assert metrics['totalDifference'] == 3121656.100202402
assert metrics['meanDifference'] == 117.90067228924735
assert metrics['totalDifference'] == 3121703.1639738297
assert metrics['meanDifference'] == 117.90244982338746

assert difference_image.imageType.componentType == 'float64'
assert difference_image_rendering.imageType.componentType == 'uint8'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.1"
__version__ = "4.0.0"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.1"
__version__ = "4.0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def input_data():
]
data = {}
for f in test_files:
path = str(input_base_path / f) + '.pickle'
with open(path, 'rb') as fp:
data[str(f.name)] = pickle.load(fp)
with open(input_base_path / f, 'rb') as fp:
data[str(f.name)] = fp.read()
return data
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@
@run_in_pyodide(packages=['micropip', 'numpy'])
async def test_compare_double_images_async(selenium, package_wheel, input_data):
import micropip
await micropip.install(package_wheel, 'numpy', 'itkwasm')
await micropip.install(package_wheel)
await micropip.install('itkwasm-image-io-emscripten')
def write_input_data_to_fs(input_data, filename):
with open(filename, 'wb') as fp:
fp.write(input_data[filename])

from itkwasm_compare_images import compare_double_images_async
import numpy as np
from itkwasm import Image
from itkwasm.pyodide import to_js as itkwasm_to_js
from itkwasm_image_io_emscripten import imread_async

test_image_file = 'cake_easy.iwi.cbor'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.iwi.cbor'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_double_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -37,18 +44,25 @@ async def test_compare_double_images_async(selenium, package_wheel, input_data):
@run_in_pyodide(packages=['micropip', 'numpy'])
async def test_compare_images_async(selenium, package_wheel, input_data):
import micropip
await micropip.install(package_wheel, 'numpy', 'itkwasm')
await micropip.install(package_wheel)
await micropip.install('itkwasm-image-io-emscripten')
def write_input_data_to_fs(input_data, filename):
with open(filename, 'wb') as fp:
fp.write(input_data[filename])

from itkwasm_compare_images import compare_images_async
import numpy as np
from itkwasm import Image
from itkwasm.pyodide import to_js as itkwasm_to_js
from itkwasm_image_io_emscripten import imread_async

test_image_file = 'cake_easy.iwi.cbor'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.iwi.cbor'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -63,10 +77,12 @@ async def test_compare_images_async(selenium, package_wheel, input_data):
assert difference_image_rendering.imageType.componentType == 'uint8'

test_image_file = 'cake_easy.png'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'cake_hard.png'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

Expand All @@ -81,19 +97,21 @@ async def test_compare_images_async(selenium, package_wheel, input_data):
assert difference_image_rendering.imageType.componentType == 'uint8'

test_image_file = 'apple.jpg'
test_image = Image(**input_data[test_image_file])
write_input_data_to_fs(input_data, test_image_file)
test_image = await imread_async(test_image_file)

baseline_image_file = 'orange.jpg'
baseline_image = Image(**input_data[baseline_image_file])
write_input_data_to_fs(input_data, baseline_image_file)
baseline_image = await imread_async(baseline_image_file)

metrics, difference_image, difference_image_rendering = await compare_images_async(test_image, baseline_images=[baseline_image])

assert metrics['almostEqual'] == False
assert metrics['numberOfPixelsWithDifferences'] == 26477
assert metrics['minimumDifference'] == 0.002273026683894841
assert metrics['maximumDifference'] == 312.2511648746159
assert metrics['totalDifference'] == 3121656.100202402
assert metrics['meanDifference'] == 117.90067228924735
assert metrics['totalDifference'] == 3121703.1639738297
assert metrics['meanDifference'] == 117.90244982338746

assert difference_image.imageType.componentType == 'float64'
assert difference_image_rendering.imageType.componentType == 'uint8'
Loading

0 comments on commit e8ac26b

Please sign in to comment.