Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Dev016 (#117)
Browse files Browse the repository at this point in the history
* check that input to step.fit_transform and step.transform is dict. Same for step outputs

* prepare for 0.1.16

* Update base.py
  • Loading branch information
Kamil A. Kaczmarek authored Nov 23, 2018
1 parent 1d60b30 commit 856b95f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = '0.1'
# The full version, including alpha/beta/rc tags
release = '0.1.15'
release = '0.1.16'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

setup(name='steppy',
packages=['steppy'],
version='0.1.15',
version='0.1.16',
description='A lightweight, open-source, Python library for fast and reproducible experimentation',
long_description=long_description,
url='https://github.com/minerva-ml/steppy',
download_url='https://github.com/minerva-ml/steppy/archive/0.1.15.tar.gz',
download_url='https://github.com/minerva-ml/steppy/archive/0.1.16.tar.gz',
author='Kamil A. Kaczmarek, Jakub Czakon',
author_email='[email protected], [email protected]',
keywords=['machine-learning', 'reproducibility', 'pipeline', 'data-science'],
Expand Down
20 changes: 20 additions & 0 deletions steppy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ def fit_transform(self, data):
Returns:
dict: Step output from the ``self.transformer.fit_transform`` method
"""
if data:
assert isinstance(data, dict), 'Step {}, "data" argument in the "fit_transform()" method must be dict, ' \
'got {} instead.'.format(self.name, type(data))
logger.info('Step {}, working in "{}" mode'.format(self.name, self._mode))

if self._mode == 'inference':
ValueError('Step {}, you are in "{}" mode, where you cannot run "fit".'
'Please change mode to "train" to enable fitting.'
Expand Down Expand Up @@ -384,7 +388,11 @@ def transform(self, data):
Returns:
dict: step output from the transformer.transform method
"""
if data:
assert isinstance(data, dict), 'Step {}, "data" argument in the "transform()" method must be dict, ' \
'got {} instead.'.format(self.name, type(data))
logger.info('Step {}, working in "{}" mode'.format(self.name, self._mode))

if self.output_is_cached:
logger.info('Step {} using cached output'.format(self.name))
step_output_data = self.output
Expand Down Expand Up @@ -556,6 +564,12 @@ def _fit_transform_operation(self, step_inputs):
raise StepError(msg) from e

logger.info('Step {}, transforming completed'.format(self.name))

assert isinstance(step_output_data, dict), 'Step {}, Transformer "{}", error. ' \
'Output from transformer must be dict, got {} instead'.format(self.name,
self.transformer.__class__.__name__,
type(step_output_data))

if self.cache_output:
logger.info('Step {}, caching output'.format(self.name))
self.output = step_output_data
Expand Down Expand Up @@ -596,6 +610,12 @@ def _transform_operation(self, step_inputs):
raise StepError(msg) from e

logger.info('Step {}, transforming completed'.format(self.name))

assert isinstance(step_output_data, dict), 'Step {}, Transformer "{}", error. ' \
'Output from transformer must be dict, got {} instead'.format(self.name,
self.transformer.__class__.__name__,
type(step_output_data))

if self.cache_output:
logger.info('Step {}, caching output'.format(self.name))
self.output = step_output_data
Expand Down

0 comments on commit 856b95f

Please sign in to comment.