def task_id_str(task_family, params):
 param_str = json.dumps(params, separators=(',', ':'), sort_keys=True)
 param_hash = hashlib.md5(param_str.encode('utf-8')).hexdigest()
 param_summary = '_'.join((p[:TASK_ID_TRUNCATE_PARAMS] for p in (params[p] for p in sorted(params)[:TASK_ID_INCLUDE_PARAMS])))
 param_summary = TASK_ID_INVALID_CHAR_REGEX.sub('_', param_summary)
 return '{}_{}_{}'.format(task_family, param_summary, param_hash[:TASK_ID_TRUNCATE_HASH])

def task_id_str ( task_family , params ) : param_str = json . dumps ( params , separators = ( ',' , ':' ) , sort_keys = True ) param_hash = hashlib . md5 ( param_str . encode ( 'utf-8' ) ) . hexdigest ( ) param_summary = '_' . join ( ( p [ : TASK_ID_TRUNCATE_PARAMS ] for p in ( params [ p ] for p in sorted ( params ) [ : TASK_ID_INCLUDE_PARAMS ] ) ) ) param_summary = TASK_ID_INVALID_CHAR_REGEX . sub ( '_' , param_summary ) return '{}_{}_{}' . format ( task_family , param_summary , param_hash [ : TASK_ID_TRUNCATE_HASH ] )
returns a canonical string used to identify a particular task .