Fix type bug in build_trackers -- skip non-callable modules#1249
Open
Fix type bug in build_trackers -- skip non-callable modules#1249
Conversation
|
@kiukchung has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95932184. |
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
Summary: Fix Pyre type error in `build_trackers()` where `load_module()` can return a `ModuleType` that is then called as a factory function. **Problem:** - `load_module(factory_name)` returns `ModuleType | Callable | None` - When the user passes a bare module path (no `:attr` suffix), a `ModuleType` is returned, which is not callable - Calling `factory(config)` on a `ModuleType` is a runtime `TypeError` and a Pyre type error [29] **Fix:** - Add a `callable()` check after resolving the factory - Non-callable modules are skipped with a descriptive warning guiding the user to use `module.path:factory_function` syntax - Rename intermediate variable to `resolved` so Pyre can narrow the type before assigning to `factory` **Cleanup:** - Convert f-string log calls to `%s` formatting per TorchX conventions Differential Revision: D95932184
6e5a1e3 to
1ac3f31
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
Summary: Fix Pyre type error in `build_trackers()` where `load_module()` can return a `ModuleType` that is then called as a factory function. **Problem:** - `load_module(factory_name)` returns `ModuleType | Callable | None` - When the user passes a bare module path (no `:attr` suffix), a `ModuleType` is returned, which is not callable - Calling `factory(config)` on a `ModuleType` is a runtime `TypeError` and a Pyre type error [29] **Fix:** - Add a `callable()` check after resolving the factory - Non-callable modules are skipped with a descriptive warning guiding the user to use `module.path:factory_function` syntax - Rename intermediate variable to `resolved` so Pyre can narrow the type before assigning to `factory` **Cleanup:** - Convert f-string log calls to `%s` formatting per TorchX conventions Differential Revision: D95932184
1ac3f31 to
bb81f70
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
Summary: Fix Pyre type error in `build_trackers()` where `load_module()` can return a `ModuleType` that is then called as a factory function. **Problem:** - `load_module(factory_name)` returns `ModuleType | Callable | None` - When the user passes a bare module path (no `:attr` suffix), a `ModuleType` is returned, which is not callable - Calling `factory(config)` on a `ModuleType` is a runtime `TypeError` and a Pyre type error [29] **Fix:** - Add a `callable()` check after resolving the factory - Non-callable modules are skipped with a descriptive warning guiding the user to use `module.path:factory_function` syntax - Rename intermediate variable to `resolved` so Pyre can narrow the type before assigning to `factory` **Cleanup:** - Convert f-string log calls to `%s` formatting per TorchX conventions Differential Revision: D95932184
bb81f70 to
c58339b
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
Summary: Fix Pyre type error in `build_trackers()` where `load_module()` can return a `ModuleType` that is then called as a factory function. **Problem:** - `load_module(factory_name)` returns `ModuleType | Callable | None` - When the user passes a bare module path (no `:attr` suffix), a `ModuleType` is returned, which is not callable - Calling `factory(config)` on a `ModuleType` is a runtime `TypeError` and a Pyre type error [29] **Fix:** - Add a `callable()` check after resolving the factory - Non-callable modules are skipped with a descriptive warning guiding the user to use `module.path:factory_function` syntax - Rename intermediate variable to `resolved` so Pyre can narrow the type before assigning to `factory` **Cleanup:** - Convert f-string log calls to `%s` formatting per TorchX conventions Differential Revision: D95932184
8ec96f4 to
5814927
Compare
18ceab0 to
632a634
Compare
kiukchung
added a commit
that referenced
this pull request
Mar 10, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
632a634 to
87f2182
Compare
kiukchung
added a commit
that referenced
this pull request
Mar 10, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
kiukchung
added a commit
that referenced
this pull request
Mar 11, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
53b9ca2 to
b00f12a
Compare
kiukchung
added a commit
that referenced
this pull request
Mar 11, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
kiukchung
added a commit
that referenced
this pull request
Mar 11, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
b00f12a to
f62c7ce
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 11, 2026
Summary: Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
f62c7ce to
828c69a
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 11, 2026
Summary: Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
828c69a to
0779fb3
Compare
kiukchung
added a commit
that referenced
this pull request
Mar 11, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
0779fb3 to
78931b6
Compare
kiukchung
added a commit
that referenced
this pull request
Mar 11, 2026
Summary: Pull Request resolved: #1249 Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Differential Revision: D95932184
78931b6 to
b57b866
Compare
b57b866 to
c75fff3
Compare
Summary: Fix ``build_trackers()`` in ``tracker/api.py`` to skip non-callable modules returned by ``load_module()``. Previously, ``ModuleType`` objects were being passed where callables were expected, causing ``TypeError: 'module' object is not callable`` at runtime. **Root cause:** ``load_module()`` returns ``types.ModuleType`` for packages (directories with ``__init__.py``) but ``build_trackers()`` assumed all return values were factory callables. **Fix:** Added ``callable()`` guard before invoking the loaded object. Non-callable modules are silently skipped with a debug log message. **Cleanup:** Removed unused ``source_data`` variable in test MockTracker. Reviewed By: AbishekS, ajauhri Differential Revision: D95932184
c75fff3 to
1ceabaf
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fix Pyre type error in
build_trackers()whereload_module()can returna
ModuleTypethat is then called as a factory function.Problem:
load_module(factory_name)returnsModuleType | Callable | None:attrsuffix), aModuleTypeis returned, which is not callable
factory(config)on aModuleTypeis a runtimeTypeErroranda Pyre type error [29]
Fix:
callable()check after resolving the factoryto use
module.path:factory_functionsyntaxresolvedso Pyre can narrow the typebefore assigning to
factoryCleanup:
%sformatting per TorchX conventionsDifferential Revision: D95932184