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

Commit 856b95f

Browse files
author
Kamil A. Kaczmarek
authored
Dev016 (#117)
* check that input to step.fit_transform and step.transform is dict. Same for step outputs * prepare for 0.1.16 * Update base.py
1 parent 1d60b30 commit 856b95f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = '0.1'
2828
# The full version, including alpha/beta/rc tags
29-
release = '0.1.15'
29+
release = '0.1.16'
3030

3131

3232
# -- General configuration ---------------------------------------------------

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
setup(name='steppy',
1515
packages=['steppy'],
16-
version='0.1.15',
16+
version='0.1.16',
1717
description='A lightweight, open-source, Python library for fast and reproducible experimentation',
1818
long_description=long_description,
1919
url='https://github.com/minerva-ml/steppy',
20-
download_url='https://github.com/minerva-ml/steppy/archive/0.1.15.tar.gz',
20+
download_url='https://github.com/minerva-ml/steppy/archive/0.1.16.tar.gz',
2121
author='Kamil A. Kaczmarek, Jakub Czakon',
2222
author_email='kamil.kaczmarek@neptune.ml, jakub.czakon@neptune.ml',
2323
keywords=['machine-learning', 'reproducibility', 'pipeline', 'data-science'],

steppy/base.py

+20
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ def fit_transform(self, data):
329329
Returns:
330330
dict: Step output from the ``self.transformer.fit_transform`` method
331331
"""
332+
if data:
333+
assert isinstance(data, dict), 'Step {}, "data" argument in the "fit_transform()" method must be dict, ' \
334+
'got {} instead.'.format(self.name, type(data))
332335
logger.info('Step {}, working in "{}" mode'.format(self.name, self._mode))
336+
333337
if self._mode == 'inference':
334338
ValueError('Step {}, you are in "{}" mode, where you cannot run "fit".'
335339
'Please change mode to "train" to enable fitting.'
@@ -384,7 +388,11 @@ def transform(self, data):
384388
Returns:
385389
dict: step output from the transformer.transform method
386390
"""
391+
if data:
392+
assert isinstance(data, dict), 'Step {}, "data" argument in the "transform()" method must be dict, ' \
393+
'got {} instead.'.format(self.name, type(data))
387394
logger.info('Step {}, working in "{}" mode'.format(self.name, self._mode))
395+
388396
if self.output_is_cached:
389397
logger.info('Step {} using cached output'.format(self.name))
390398
step_output_data = self.output
@@ -556,6 +564,12 @@ def _fit_transform_operation(self, step_inputs):
556564
raise StepError(msg) from e
557565

558566
logger.info('Step {}, transforming completed'.format(self.name))
567+
568+
assert isinstance(step_output_data, dict), 'Step {}, Transformer "{}", error. ' \
569+
'Output from transformer must be dict, got {} instead'.format(self.name,
570+
self.transformer.__class__.__name__,
571+
type(step_output_data))
572+
559573
if self.cache_output:
560574
logger.info('Step {}, caching output'.format(self.name))
561575
self.output = step_output_data
@@ -596,6 +610,12 @@ def _transform_operation(self, step_inputs):
596610
raise StepError(msg) from e
597611

598612
logger.info('Step {}, transforming completed'.format(self.name))
613+
614+
assert isinstance(step_output_data, dict), 'Step {}, Transformer "{}", error. ' \
615+
'Output from transformer must be dict, got {} instead'.format(self.name,
616+
self.transformer.__class__.__name__,
617+
type(step_output_data))
618+
599619
if self.cache_output:
600620
logger.info('Step {}, caching output'.format(self.name))
601621
self.output = step_output_data

0 commit comments

Comments
 (0)