def check_table()

in workflow1_endpointbuilder/sam-app/functions/function4_checktablestatus/index.py [0:0]


def check_table(datetime_id, bucket_name):
    dynamodb_resource = boto3.resource('dynamodb')
    table = dynamodb_resource.Table(f'DatasetCSVTable_{datetime_id}_{bucket_name}_')

    scan_kwargs = {
        'Select': 'COUNT',
        'FilterExpression': 'attribute_not_exists(#cls)',
        'ExpressionAttributeNames': {'#cls': 'class'}
    }

    done = False
    start_key = None
    rows_not_filled = 0
    while not done:
        if start_key:
            scan_kwargs['ExclusiveStartKey'] = start_key
        response = table.scan(**scan_kwargs)
        rows_not_filled += response['Count']
        start_key = response.get('LastEvaluatedKey', None)
        done = start_key is None

    if rows_not_filled == 0:
        return True
    else:
        return False