diff --git a/src/pages/dashboard.py b/src/pages/dashboard.py index 7547f864f92701324df585284e47017713a4172a..7ed5fc3be96c7c715e11ba14d1da5570dc3c91ed 100644 --- a/src/pages/dashboard.py +++ b/src/pages/dashboard.py @@ -307,18 +307,23 @@ def generate_eurad_im_body(language_id=0): return [ dbc.Row([ dbc.Col(dbc.Label(guitr.date_label[language_id]), width=3), - dbc.Col(dcc.DatePickerSingle(date=dt.date(2018, 7, 22), + dbc.Col(dcc.DatePickerSingle(id="eurad_im_start_date", + date=dt.date(2018, 7, 22), display_format=guitr.date_format[language_id], first_day_of_week=guitr.first_day_of_week[language_id], min_date_allowed=dt.date(2018, 7, 22), max_date_allowed=dt.date(2018, 7, 31), initial_visible_month=dt.date(2018, 7, 1))), dbc.Col(dbc.Label(f"{guitr.forecast_length_label[language_id]}:")), - dbc.Col(dcc.Dropdown(value=guitr.forecast_length_options[language_id][0], options=guitr.forecast_length_options[language_id])) + dbc.Col(dcc.Dropdown(value=guitr.forecast_length_options[language_id][0], options=guitr.forecast_length_options[language_id], + id="eurad_im_forecast_length")) ], class_name="row mt-3"), dbc.Row([ dbc.Col(dbc.Label(guitr.region_label[language_id]), width=3), - dbc.Col(dcc.RadioItems(['NRW', 'Berlin-Brandenburg'], 'NRW')), + dbc.Col(dcc.RadioItems(options={ + 0: 'Nordrhein-Westfalen', + 1: 'Berlin-Brandenburg'}, + value=0, id="eurad_im_region_choice")), ], class_name="row mt-3"), ] @@ -620,6 +625,11 @@ def get_my_jobs_from_db(user_id=None, language_id=0): data_rows_from_db = cur.fetchall() conn.close() + # if status != 'finished': + # use /p/project/cjicg21/schroeder5/Destine_AQ/SCRIPTS/ECFLOW/query_status.bash jobnr + # to determine the actual status + # ==> there should be a refresh, whenever this tab is reloaded! + for job in data_rows_from_db: data_from_db.append({guitr.jobs_columns[language_id][0]: guitr.application_text[language_id][job[0]], guitr.jobs_columns[language_id][1]: guitr.status_text[language_id][job[1]], @@ -841,20 +851,52 @@ def eurad_im_modal(open_button, close_button): @callback( - Output("eurad_im_modal", "is_open", allow_duplicate=True), - Input("eurad_im_run", "n_clicks"), + [Output("eurad_im_modal", "is_open", allow_duplicate=True), + Output("my_jobs_tab", "children", allow_duplicate=True)], + Input("eurad_im_run", "n_clicks"), + [State("eurad_im_region_choice", "value"), + State('eurad_im_start_date', 'date'), + State('eurad_im_forecast_length', 'value'), + State("user-info", "data")], prevent_initial_call=True ) -def eurad_im_job_run(run_button): +def eurad_im_job_run(run_button, region, startdate, forecast_length, user_dict): + # add job to user's job list + user_id = json.loads(user_dict)["user_id"] + language_id = json.loads(user_dict)["language_id"] + new_job_dict = {} + jobnr = get_random_string(12) + new_job_dict['id'] = jobnr + # application is EURAD-IM -- should be taken from the controlled vocabulary! + new_job_dict['application'] = 0 + new_job_dict['region'] = region + new_job_dict['start_date'] = startdate + ' 00:00' + new_job_dict['forecast_length'] = int(forecast_length.split()[0]) + # take the coding for the status from the controlled vocabulary! + # set it to "waiting" since it will just be submitted + new_job_dict['status'] = 2 + # EURAD-IM does not have any species to be chosen + new_job_dict['species'] = None + # EURAD-IM does not have any metrics to be chosen + new_job_dict['metric'] = None + # EURAD-IM does not have any emission scenario + new_job_dict['emis_scen'] = None + create_db_job_entry(user_id, new_job_dict) + + # submit job base_url = f"{UNICORE_BASE}JURECA/rest/core" credentials = uc_credentials.UsernamePassword(UNICORE_USER, UNICORE_PASSWORD) client = uc_client.Client(credentials, base_url) - job_description = {'Executable': "/p/project/cjicg21/schroeder5/Destine_AQ/start_destine_demonstrator.sh", "Job type": "ON_LOGIN_NODE", 'Arguments':[], } + job_description = {'Executable': "/p/project/cjicg21/schroeder5/Destine_AQ/start_destine_demonstrator.sh", "Job type": "ON_LOGIN_NODE", 'Arguments':[jobnr, "0"], } job = client.new_job(job_description) - if ctx.triggered_id == "eurad_im_open": - return True - else: - return False + + # return updated values + retval = ctx.triggered_id == "eurad_im_open" + return retval,\ + [generate_jobs_table(user_id=user_id, language_id=language_id), + generate_eurad_im_output_modal(language_id=language_id), + generate_ml_fcast_output_modal(language_id=language_id), + generate_eurad_scen_output_modal(container_id="eurad_scen_output_modal_container", language_id=language_id)] @callback( diff --git a/utils/start_destine_demonstrator.sh b/utils/start_destine_demonstrator.sh new file mode 100644 index 0000000000000000000000000000000000000000..597c1b45d75f56915ef7d5a7a5a8f85f06ca8214 --- /dev/null +++ b/utils/start_destine_demonstrator.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +## TODO: "configuration.general" should be an argument to suite_config.py +## (if two persons are setting up an experiment at the same time, using a constant file may cause an hazzard) + +#get setup from script arguments +MODE=$1 +ENSEMBLE=$2 + +# set environment +source /p/project/cjicg21/schroeder5/Destine_AQ/setenv.sh + +# adapt configuration to actual setup +EXP_NAME=${MODE^^} +cd /p/project/cjicg21/schroeder5/Destine_AQ/SCRIPTS/ECFLOW +sed -i -e 's/MODE = "test3" #"destineaq"/MODE = \"'"${MODE}"'\"/' configuration.general +sed -i -e 's/EXP_NAME = "TEST3" #"DestineAQ"/EXP_NAME = \"'"${EXP_NAME}"'\"/' configuration.general +if [ "$ENSEMBLE" -ne "0" ]; then + sed -i -e 's/ensemble = false/ensemble = true/' configuration.general + sed -i -e 's/ensemble_size = 15/ensemble_size = 1/' configuration.general + sed -i -e 's/ensemble_member = \[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19\]/ensemble_member = \['"$ENSEMBLE"'\]/' configuration.general +fi +sed -i -e 's/JWTEST/'"${EXP_NAME}"'/' start_ecflow.sh +sed -i -e 's/destineaq/'"${MODE}"'/g' start_ecflow.sh +python Airshed4.py + +# run the script +./start_ecflow.sh + +# reset settings +rm configuration.general +ln -s configurations/configuration.JURECA-DC.destine.toml configuration.general +sed -i -e 's/'"${EXP_NAME}"'/JWTEST/g' start_ecflow.sh +sed -i -e 's/'"${MODE}"'/destineaq/g' start_ecflow.sh +