-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindgen): environment_dispatch supports the function_factory
- Loading branch information
Showing
14 changed files
with
164 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[build-system] | ||
requires = ["hatchling", "hatch-vcs"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "test-accelerator" | ||
license = "Apache-2.0" | ||
version = "0.0.1" | ||
|
||
requires-python = ">=3.7" | ||
dependencies = [ | ||
"itkwasm >= 1.0b82", | ||
] | ||
|
||
[tool.hatch.envs.default] | ||
dependencies = [ | ||
"pytest", | ||
] | ||
|
||
[tool.hatch.envs.default.scripts] | ||
test = "pytest" | ||
|
||
[project.entry-points."itkwasm_example_package.example_function"] | ||
"test_accelerator-faster.priority.10" = "test_accelerator.faster_mod:faster" | ||
"test_accelerator-fastest.priority.15" = "test_accelerator.fastest_mod:fastest" | ||
"test_accelerator-slower.priority.-1" = "test_accelerator.slower_mod:slower" |
3 changes: 3 additions & 0 deletions
3
src/python/itkwasm/test/test-accelerator/test_accelerator/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .faster_mod import faster | ||
from .fastest_mod import fastest | ||
from .slower_mod import slower |
2 changes: 2 additions & 0 deletions
2
src/python/itkwasm/test/test-accelerator/test_accelerator/faster_mod.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def faster(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
src/python/itkwasm/test/test-accelerator/test_accelerator/fastest_mod.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def fastest(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
src/python/itkwasm/test/test-accelerator/test_accelerator/slower_mod.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def slower(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
|
||
def test_function_factory(): | ||
test_accelerator = pytest.importorskip("test_accelerator") | ||
|
||
from itkwasm import function_factory | ||
interface_package = "itkwasm_example_package" | ||
func_name = "example_function" | ||
registered = function_factory.lookup(interface_package, func_name) | ||
|
||
from test_accelerator import slower, faster, fastest | ||
|
||
highest = function_factory.highest_priority(interface_package, func_name) | ||
assert highest == fastest | ||
|
||
function_factory.set_priority(faster, 30) | ||
highest = function_factory.highest_priority(interface_package, func_name) | ||
assert highest == faster | ||
|
||
assert function_factory.get_priority(slower) == -1 | ||
|
||
function_factory.disable(interface_package, func_name) | ||
highest = function_factory.highest_priority(interface_package, func_name) | ||
assert highest == None | ||
|
||
def test_environment_dispatch(): | ||
test_accelerator = pytest.importorskip("test_accelerator") | ||
|
||
from itkwasm import function_factory, environment_dispatch | ||
interface_package = "itkwasm_example_package" | ||
func_name = "example_function" | ||
|
||
from test_accelerator import fastest | ||
function_factory.register(interface_package, func_name, fastest, 1) | ||
|
||
func = environment_dispatch(interface_package, func_name) | ||
from test_accelerator import fastest | ||
assert func == fastest |