import hashlib import json def check_required_params(flow, context): """Check for required params Args: flow (Flow): flow object context (dict): dictionary """ if hasattr(flow, 'required_params') and hasattr(flow, 'available_params'): context_dict = json.loads(context) required_params = sorted(flow.required_params) available_required_params = sorted([ k for k, v in context_dict.items() if k in required_params ]) return available_required_params == required_params return True def _hashFor(data): """Generate random unique key from the data Args: data (str): data to be hashed Returns: str: hashed data """ hashId = hashlib.md5() hashId.update(repr(data).encode('utf-8')) return hashId.hexdigest()