Skip to content

Commit

Permalink
feat(Python): Add JsPackageConfig
Browse files Browse the repository at this point in the history
For use in Python bindings.
  • Loading branch information
thewtex committed Apr 17, 2023
1 parent 02d8bbe commit 1220389
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/python/itkwasm/itkwasm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""itkwasm: Python interface to itk-wasm WebAssembly modules."""

__version__ = "1.0b93"
__version__ = "1.0b94"

from .interface_types import InterfaceTypes
from .image import Image, ImageType
Expand All @@ -18,6 +18,7 @@
from .int_types import IntTypes
from .pixel_types import PixelTypes
from .environment_dispatch import environment_dispatch, function_factory
from .js_package_config import JsPackageConfig

__all__ = [
"InterfaceTypes",
Expand All @@ -41,4 +42,5 @@
"PixelTypes",
"environment_dispatch",
"function_factory",
"JsPackageConfig",
]
8 changes: 8 additions & 0 deletions packages/core/python/itkwasm/itkwasm/js_package_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses import dataclass
from typing import Optional

@dataclass
class JsPackageConfig:
module_url: str
pipelines_base_url: Optional[str] = None
pipeline_worker_url: Optional[str] = None
16 changes: 16 additions & 0 deletions packages/core/python/itkwasm/test/test_js_package_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

def test_itkwasm_js_package_config():
from itkwasm import JsPackageConfig
module_url = 'https://cdn.jsdelivr.net/npm/@itk-wasm/[email protected]/dist/bundles/compress-stringify.js'
pipelines_base_url = 'https://cdn.jsdelivr.net/npm/@itk-wasm/[email protected]/dist/pipelines'
pipeline_worker_url = 'https://cdn.jsdelivr.net/npm/@itk-wasm/[email protected]/dist/web-workers/pipeline.worker.js'

config = JsPackageConfig(module_url, pipelines_base_url, pipeline_worker_url)
assert config.module_url == module_url
assert config.pipelines_base_url == pipelines_base_url
assert config.pipeline_worker_url == pipeline_worker_url

config = JsPackageConfig(module_url)
assert config.module_url == module_url
assert config.pipelines_base_url is None
assert config.pipeline_worker_url is None

0 comments on commit 1220389

Please sign in to comment.