Skip to content

Commit

Permalink
Add add-on detection for constraints (#1412)
Browse files Browse the repository at this point in the history
* add ability to find constraint addons

* fix error message

* fix test
  • Loading branch information
frances-h authored May 9, 2023
1 parent 80d0408 commit 0f8b92d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdv/_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _find_addons(group, parent_globals, add_all=False):
try:
module = entry_point.load()
except Exception:
msg = f'Failed to load "{entry_point.name}" from "{entry_point.module}".'
msg = f'Failed to load "{entry_point.name}" from "{entry_point.module_name}".'
warnings.warn(msg)
continue

Expand Down
4 changes: 3 additions & 1 deletion sdv/constraints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""SDV Constraints module."""

from sdv._addons import _find_addons
from sdv.constraints.base import Constraint
from sdv.constraints.tabular import (
FixedCombinations, FixedIncrements, Inequality, Negative, OneHotEncoding, Positive, Range,
Expand All @@ -19,3 +19,5 @@
'OneHotEncoding',
'Unique'
]

_find_addons('sdv.constraints_modules', globals(), add_all=True)
2 changes: 1 addition & 1 deletion tests/unit/test__addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def entry_point_error():

bad_entry_point = Mock()
bad_entry_point.name = 'bad_entry_point'
bad_entry_point.module = 'bad_module'
bad_entry_point.module_name = 'bad_module'
bad_entry_point.load.side_effect = entry_point_error
entry_points_mock.return_value = [bad_entry_point]
test_dict = {}
Expand Down

0 comments on commit 0f8b92d

Please sign in to comment.