<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_scenario_data(scenario_id,**kwargs):
 """ Get all the datasets from the group with the specified name @returns a list of dictionaries """

    user_id = kwargs.get('user_id')

    scenario_data = db.DBSession.query(Dataset).filter(Dataset.id==ResourceScenario.dataset_id, ResourceScenario.scenario_id==scenario_id).options(joinedload_all('metadata')).distinct().all()

    for sd in scenario_data:
       if sd.hidden == 'Y':
           try:
                sd.check_read_permission(user_id)
           except:
               sd.value      = None
               sd.metadata = []

    db.DBSession.expunge_all()

    log.info("Retrieved %s datasets", len(scenario_data))
    return scenario_data