Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add configuration to disable Python factory loading #3330

Conversation

tbirdso
Copy link
Contributor

@tbirdso tbirdso commented Mar 24, 2022

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 thewtex and dzenanz 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
Copy link
Contributor Author

tbirdso commented Mar 24, 2022

/azp run ITK.macOS.Python

@thewtex
Copy link
Member

thewtex commented Mar 24, 2022

@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
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