Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_jsons():
"""Validate MLBlocks primitive jsons"""
primitives = (f for f in os.listdir(MLBLOCKS_PRIMITIVES) if f.endswith('.json'))
for primitive_filename in primitives:
try:
primitive_path = os.path.join(MLBLOCKS_PRIMITIVES, primitive_filename)
with open(primitive_path, 'r') as f:
primitive = json.load(f)
primitive_name = primitive['name']
fixed_hyperparameters = primitive.get('hyperparameters', dict()).get('fixed', dict())
init_hyperparameters = dict()
for name, hyperparameter in fixed_hyperparameters.items():
if 'default' not in hyperparameter:
type_ = hyperparameter.get('type')
init_hyperparameters[name] = HYPERPARAMETER_DEFAULTS.get(type_)
block_name = primitive_name + '#1'
def test_jsons():
"""Validate MLBlocks primitive jsons"""
primitives = (f for f in os.listdir(MLBLOCKS_PRIMITIVES) if f.endswith('.json'))
for primitive_filename in primitives:
try:
primitive_path = os.path.join(MLBLOCKS_PRIMITIVES, primitive_filename)
with open(primitive_path, 'r') as f:
primitive = json.load(f)
primitive_name = primitive['name']
fixed_hyperparameters = primitive.get('hyperparameters', dict()).get('fixed', dict())
init_hyperparameters = dict()
for name, hyperparameter in fixed_hyperparameters.items():
if 'default' not in hyperparameter:
type_ = hyperparameter.get('type')
init_hyperparameters[name] = HYPERPARAMETER_DEFAULTS.get(type_)
block_name = primitive_name + '#1'
mlpipeline = MLPipeline(
primitives=[primitive_name],
init_params={block_name: init_hyperparameters}