Skip to content

ENH: Add configuration to disable Python factory loading#3330

Merged
tbirdso merged 1 commit into
InsightSoftwareConsortium:masterfrom
tbirdso:configure-default-factory-reg
Mar 24, 2022
Merged

ENH: Add configuration to disable Python factory loading#3330
tbirdso merged 1 commit into
InsightSoftwareConsortium:masterfrom
tbirdso:configure-default-factory-reg

Conversation

@tbirdso

@tbirdso tbirdso commented Mar 24, 2022

Copy link
Copy Markdown
Contributor

Allow user to disable default loading of object factory override methods in Python. This is primarily intended to assist in debug investigations where factory overrides are suspected of interfering with expected behavior.

Behavior can be configured in two lines:

import itkConfig
itkConfig.DefaultFactoryLoading = False

With default factory loading disabled a developer is responsible for manually supplying any implementations of abstract classes that previously relied on factory instantiation. For example, itk.ImageFileReader relies on factory overrides of ImageIO to read files based on their extension, so with no factories registered the developer must supply a suitable ImageIO object, i.e. :

image = itk.imread('path/to/image.mha', imageio=itk.MetaImageIO.New())

The PythonNoDefaultFactories test is added to cover the scenario where DefaultFactoryLoading is set to False. DefaultFactoryLoading is True by default and factory loading is covered by other tests.

PR Checklist

  • Added test (or behavior not changed)

Refer to the ITK Software Guide for
further development details if necessary.

Allow user to disable default loading of object factory override methods
in Python. This is primarily intended to assist in debug investigations
where factory overrides are suspected of interfering with expected behavior.
@tbirdso
tbirdso requested review from dzenanz and thewtex March 24, 2022 01:08
@github-actions github-actions Bot added area:Python wrapping Python bindings for a class type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Mar 24, 2022
@tbirdso

tbirdso commented Mar 24, 2022

Copy link
Copy Markdown
Contributor Author

/azp run ITK.macOS.Python

@thewtex

thewtex commented Mar 24, 2022

Copy link
Copy Markdown
Member

@jcfr this, along with #3331 will allow running your test pipeline in Slicer without loading HDF5 IO

@tbirdso
tbirdso merged commit 2ab4be1 into InsightSoftwareConsortium:master Mar 24, 2022
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…ure-default-factory-reg

ENH: Add configuration to disable Python factory loading
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
…ure-default-factory-reg

ENH: Add configuration to disable Python factory loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants