Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho committed May 20, 2024
1 parent 7883bf1 commit c1df75c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdv/multi_table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def load(cls, filepath):
'machine is CPU-only. This feature is currently unsupported. We recommend'
' sampling on the same GPU-enabled machine.'
)
raise e

check_synthesizer_version(synthesizer)
check_sdv_versions_and_warn(synthesizer)
Expand Down
1 change: 1 addition & 0 deletions sdv/single_table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def load(cls, filepath):
'machine is CPU-only. This feature is currently unsupported. We recommend'
' sampling on the same GPU-enabled machine.'
)
raise e

check_synthesizer_version(synthesizer)
check_sdv_versions_and_warn(synthesizer)
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/multi_table/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,3 +1624,14 @@ def test_load_runtime_error(self, cloudpickle_mock, mock_open):
)
with pytest.raises(SamplingError, match=err_msg):
BaseMultiTableSynthesizer.load('synth.pkl')

@patch('builtins.open')
@patch('sdv.multi_table.base.cloudpickle')
def test_load_runtime_error_no_change(self, cloudpickle_mock, mock_open):
"""Test that the synthesizer's load method errors with the correct message."""
# Setup
cloudpickle_mock.load.side_effect = RuntimeError('Error')

# Run and Assert
with pytest.raises(RuntimeError, match='Error'):
BaseMultiTableSynthesizer.load('synth.pkl')
11 changes: 11 additions & 0 deletions tests/unit/single_table/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,17 @@ def test_load_runtime_error(self, cloudpickle_mock, mock_open):
with pytest.raises(SamplingError, match=err_msg):
BaseSingleTableSynthesizer.load('synth.pkl')

@patch('builtins.open')
@patch('sdv.single_table.base.cloudpickle')
def test_load_runtime_error_no_change(self, cloudpickle_mock, mock_open):
"""Test that the synthesizer's load method errors with the correct message."""
# Setup
cloudpickle_mock.load.side_effect = RuntimeError('Error')

# Run and Assert
with pytest.raises(RuntimeError, match='Error'):
BaseSingleTableSynthesizer.load('synth.pkl')

def test_add_custom_constraint_class(self):
"""Test that this method calls the ``DataProcessor``'s method."""
# Setup
Expand Down

0 comments on commit c1df75c

Please sign in to comment.