Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Allow HOOK_WORKFLOW in site-config
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreso committed Jan 24, 2020
1 parent 20b2781 commit 8251ad1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
43 changes: 27 additions & 16 deletions lib/enkf/hook_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@
#include <ert/job_queue/workflow.hpp>

#include <ert/enkf/config_keys.hpp>
#include <ert/enkf/site_config.hpp>
#include <ert/enkf/hook_manager.hpp>
#include <ert/enkf/ert_workflow_list.hpp>
#include <ert/enkf/runpath_list.hpp>
#include <ert/enkf/model_config.hpp>

#define HOOK_MANAGER_NAME "HOOK MANAGER"
#define QC_WORKFLOW_NAME "QC WORKFLOW"
#define RUN_MODE_PRE_SIMULATION_NAME "PRE_SIMULATION"
#define RUN_MODE_POST_SIMULATION_NAME "POST_SIMULATION"
#define RUN_MODE_PRE_UPDATE_NAME "PRE_UPDATE"
#define RUN_MODE_POST_UPDATE_NAME "POST_UPDATE"

struct hook_manager_struct {
vector_type * hook_workflow_list; /* vector of hook_workflow_type instances */
Expand All @@ -52,18 +49,6 @@ struct hook_manager_struct {
};


hook_manager_type * hook_manager_alloc_default(ert_workflow_list_type * workflow_list) {
hook_manager_type * hook_manager = (hook_manager_type *)util_malloc( sizeof * hook_manager );
hook_manager->hook_workflow_list = vector_alloc_new();

hook_manager->workflow_list = workflow_list;

hook_manager->runpath_list = NULL;

hook_manager->input_context = hash_alloc();

return hook_manager;
}


hook_manager_type * hook_manager_alloc(
Expand Down Expand Up @@ -104,6 +89,32 @@ static void hook_manager_add_workflow( hook_manager_type * hook_manager , const
}
}

hook_manager_type * hook_manager_alloc_default(ert_workflow_list_type * workflow_list) {
hook_manager_type * hook_manager = (hook_manager_type *)util_malloc( sizeof * hook_manager );
hook_manager->workflow_list = workflow_list;

hook_manager->hook_workflow_list = vector_alloc_new();

config_parser_type * config = config_alloc();
config_content_type * site_config_content = site_config_alloc_content(config);

if (config_content_has_item( site_config_content , HOOK_WORKFLOW_KEY)) {
for (int ihook = 0; ihook < config_content_get_occurences(site_config_content , HOOK_WORKFLOW_KEY); ihook++) {
const char * workflow_name = config_content_iget( site_config_content , HOOK_WORKFLOW_KEY, ihook , 0 );
hook_run_mode_enum run_mode = hook_workflow_run_mode_from_name(config_content_iget(site_config_content , HOOK_WORKFLOW_KEY , ihook , 1));
hook_manager_add_workflow( hook_manager , workflow_name , run_mode );
}
}
config_free(config);
config_content_free(site_config_content);

hook_manager->runpath_list = NULL;

hook_manager->input_context = hash_alloc();

return hook_manager;
}

hook_manager_type * hook_manager_alloc_full(
ert_workflow_list_type * workflow_list,
const char * workflow_file,
Expand Down
14 changes: 14 additions & 0 deletions lib/enkf/site_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,20 @@ void site_config_add_config_items(config_parser_type * config, bool site_mode) {

item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false );
config_schema_item_set_argc_minmax( item , 2 , 2);

item = config_add_schema_item( config , HOOK_WORKFLOW_KEY , false );
config_schema_item_set_argc_minmax(item , 2 , 2 );
config_schema_item_iset_type( item , 0 , CONFIG_STRING );
config_schema_item_iset_type( item , 1 , CONFIG_STRING );
{
stringlist_type * argv = stringlist_alloc_new();
stringlist_append_copy(argv, RUN_MODE_PRE_SIMULATION_NAME);
stringlist_append_copy(argv, RUN_MODE_POST_SIMULATION_NAME);
stringlist_append_copy(argv, RUN_MODE_PRE_UPDATE_NAME);
stringlist_append_copy(argv, RUN_MODE_POST_UPDATE_NAME);
config_schema_item_set_indexed_selection_set(item, 1, argv);
stringlist_free( argv );
}
}

const char * site_config_get_config_file(const site_config_type * site_config) {
Expand Down
4 changes: 4 additions & 0 deletions lib/include/ert/enkf/config_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ extern "C" {
#define WORKFLOW_JOB_DIRECTORY_KEY "WORKFLOW_JOB_DIRECTORY"
#define LOAD_WORKFLOW_KEY "LOAD_WORKFLOW"
#define LOAD_WORKFLOW_JOB_KEY "LOAD_WORKFLOW_JOB"
#define RUN_MODE_PRE_SIMULATION_NAME "PRE_SIMULATION"
#define RUN_MODE_POST_SIMULATION_NAME "POST_SIMULATION"
#define RUN_MODE_PRE_UPDATE_NAME "PRE_UPDATE"
#define RUN_MODE_POST_UPDATE_NAME "POST_UPDATE"
#define STOP_LONG_RUNNING_KEY "STOP_LONG_RUNNING"
#define MAX_RUNTIME_KEY "MAX_RUNTIME"
#define TIME_MAP_KEY "TIME_MAP"
Expand Down

0 comments on commit 8251ad1

Please sign in to comment.