Skip to content

Fix type bug in build_trackers -- skip non-callable modules#1249

Open
kiukchung wants to merge 1 commit intomainfrom
export-D95932184
Open

Fix type bug in build_trackers -- skip non-callable modules#1249
kiukchung wants to merge 1 commit intomainfrom
export-D95932184

Conversation

@kiukchung
Copy link
Copy Markdown
Contributor

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 10, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Mar 10, 2026

@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
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
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
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
@meta-codesync meta-codesync bot force-pushed the export-D95932184 branch 4 times, most recently from 8ec96f4 to 5814927 Compare March 10, 2026 23:49
@kiukchung kiukchung force-pushed the export-D95932184 branch 2 times, most recently from 18ceab0 to 632a634 Compare March 10, 2026 23:53
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 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
@kiukchung kiukchung force-pushed the export-D95932184 branch 2 times, most recently from 53b9ca2 to b00f12a Compare March 11, 2026 00:11
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
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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant