From 0c477b34900ad49ad6572cd306c0e770b8fb49e0 Mon Sep 17 00:00:00 2001 From: Ali Mohammed <ali.mohammed@unibas.ch> Date: Thu, 11 Feb 2021 13:23:46 +0000 Subject: [PATCH] Revert "Add env. variable MSTRO_SCHEMA_LIST to list user defined schemas and adding a unit test for it" This reverts commit fdbf412b8c0a31cc9ce6baa08d0cdd9249527f01 --- include/maestro/env.h | 5 -- maestro/core.c | 89 ++++++++-------------------------- tests/check_declaration_seal.c | 33 ------------- tests/test_attributes.yaml | 16 ------ 4 files changed, 20 insertions(+), 123 deletions(-) delete mode 100644 tests/test_attributes.yaml diff --git a/include/maestro/env.h b/include/maestro/env.h index a8586cb7..0d95b73a 100644 --- a/include/maestro/env.h +++ b/include/maestro/env.h @@ -96,11 +96,6 @@ */ #define MSTRO_ENV_LOG_COLOR "MSTRO_LOG_COLOR" -/**@brief lists the set of Schemata (in order from left to right) that should be loaded after the maestro-core schema is loaded. - * If set,mstro_init will merge these onto the built-ins. Default: core + ecmwf -*/ -#define MSTRO_ENV_SCHEMA_LIST "MSTRO_SCHEMA_LIST" - /**@brief enable coloring of error log messages * * If set, enable coloring of error and warning messages. May not be a good idea if logging to syslog (see @ref MSTRO_LOG_DST). diff --git a/maestro/core.c b/maestro/core.c index 85f7cbae..83c1fdfb 100644 --- a/maestro/core.c +++ b/maestro/core.c @@ -145,72 +145,6 @@ BAILOUT: /** minimum mlock() limit */ #define MSTRO_MIN_MEMLOCK (4*sizeof(g_component_descriptor)) - -mstro_status mstro_core_init__setup_schemata(void) -{ - - mstro_status status = MSTRO_OK; - - char * env_schema_list = getenv(MSTRO_ENV_SCHEMA_LIST); - - char *token; - - // parse and merge the builtin schemas first - DEBUG("Parsing Maestro core schema\n"); - status=mstro_schema_parse(MSTRO_SCHEMA_BUILTIN_YAML_CORE, - MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN, - &g_mstro_core_schema_instance); - if(status!=MSTRO_OK) { - ERR("Failed to parse built-in core schema\n"); - return status; - } - - DEBUG("Parsing ECMWF schema\n"); - mstro_schema ecmwf; - status=mstro_schema_parse(MSTRO_SCHEMA_BUILTIN_YAML_ECMWF, - MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN, - &ecmwf); - if(status!=MSTRO_OK) { - ERR("Failed to parse built-in ecmwf schema\n"); - return status; - } - status=mstro_schema_merge(g_mstro_core_schema_instance, ecmwf); - if(status!=MSTRO_OK) { - ERR("Failed to merge core and ECMWF schema\n"); - return status; - } - - // start reading user-defined schemas and merge them. - /* get the first token */ - token = strtok(env_schema_list, ":"); - - /* walk through other tokens */ - while( token != NULL ) - { - // parse a schema from the user - mstro_schema user_schema; - - DEBUG("Parsing user-defined schema\n"); - status=mstro_schema_parse_from_file(token, &user_schema); - - if(status!=MSTRO_OK) { - ERR("Failed to parse user_schema from file: %s \n", token); - return status; - } - // merge the schema - status=mstro_schema_merge(g_mstro_core_schema_instance, user_schema); - - if(status!=MSTRO_OK) { - ERR("Failed to merge core and user schema from file %s\n", token); - return status; - } - // read the next path - token = strtok(NULL, ":"); - } - - return status; -} - mstro_status mstro_core_init(const char *workflow_name, const char *component_name, @@ -263,12 +197,29 @@ mstro_core_init(const char *workflow_name, g_component_descriptor.component_name[MSTRO_WORKFLOW_NAME_MAX-1] = '\0'; strcpy(g_component_descriptor.version, mstro_version()); - - status = mstro_core_init__setup_schemata(); + status=mstro_schema_parse(MSTRO_SCHEMA_BUILTIN_YAML_CORE, + MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN, + &g_mstro_core_schema_instance); if(status!=MSTRO_OK) { + ERR("Failed to parse built-in core schema\n"); goto BAILOUT; } - + /* FIXME: this should not be here */ + DEBUG("Including ECMWF schema\n"); + mstro_schema ecmwf; + status=mstro_schema_parse(MSTRO_SCHEMA_BUILTIN_YAML_ECMWF, + MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN, + &ecmwf); + if(status!=MSTRO_OK) { + ERR("Failed to parse built-in ecmwf schema\n"); + goto BAILOUT; + } + status=mstro_schema_merge(g_mstro_core_schema_instance, ecmwf); + if(status!=MSTRO_OK) { + ERR("Failed to merge core and ECMWF schema\n"); + goto BAILOUT; + } + DEBUG("init %s/%s/% "PRIi64 " in thread %" PRIxPTR" complete\n", data->workflow_name, data->component_name, data->component_index, (intptr_t)pthread_self()); diff --git a/tests/check_declaration_seal.c b/tests/check_declaration_seal.c index d2347470..b00a215d 100644 --- a/tests/check_declaration_seal.c +++ b/tests/check_declaration_seal.c @@ -133,36 +133,3 @@ CHEAT_TEST(cdo_declaration_seal_works, ) -/* put a path to user-defined schema*/ - -CHEAT_TEST(user_defined_schemas_works, - - putenv("MSTRO_SCHEMA_LIST=test_attributes.yaml"); - - cheat_assert(MSTRO_OK == mstro_init("Tests","DECLARE",0)); - - mstro_cdo cdo; - cheat_assert(MSTRO_OK ==mstro_cdo_declare("test cdo", MSTRO_ATTR_DEFAULT, &cdo)); - cheat_assert(MSTRO_OK ==mstro_cdo_attribute_set(cdo, ".maestro.test.t_1", "test value")); - cheat_assert(MSTRO_OK ==mstro_cdo_declaration_seal(cdo)); - - cheat_assert(MSTRO_OK ==mstro_cdo_offer(cdo)); - - cheat_assert(MSTRO_OK ==mstro_cdo_withdraw(cdo)); - cheat_assert(MSTRO_OK ==mstro_cdo_dispose(cdo)); - cheat_assert(MSTRO_OK == mstro_finalize()); - - ) - -/* put a path to user-defined schema with wrong path and wrong separators*/ - -CHEAT_TEST(user_defined_schemas_doesnot_exist, - - putenv("MSTRO_SCHEMA_LIST=bechmark_attributes.yaml"); - cheat_assert(MSTRO_OK != mstro_init("Tests","DECLARE",0)); - cheat_assert(MSTRO_FAIL == mstro_finalize()); - - ) - - - diff --git a/tests/test_attributes.yaml b/tests/test_attributes.yaml deleted file mode 100644 index 68008c9a..00000000 --- a/tests/test_attributes.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# A user-defined schema. The minimum is name and version -schema-name: Test Attributes -schema-version: 0 - -schema-namespace: ".maestro.test." - -# attributes section is optional; if given it needs to have a sequence value -maestro-attributes: - -# Top-level attributes - - - key: "t_1" - type: str() - required: False - default: "" - documentation: Value length is the attribute size -- GitLab