diff --git a/hxlm/core/model/hdp.py b/hxlm/core/model/hdp.py index b2e5c5e..6c8ec6b 100644 --- a/hxlm/core/model/hdp.py +++ b/hxlm/core/model/hdp.py @@ -231,14 +231,31 @@ def export_json_processing_specs(self, options=None) -> str: if 'hrecipe' in hsilo: for hrecipeitem in hsilo['hrecipe']: recipeitem = {} - if 'iri_example' in hrecipeitem: - # Note: here is an list, but we're taking the first now - recipeitem['input'] = \ - hrecipeitem['iri_example'][0]['iri'] - if 'sheet_index' in hrecipeitem['iri_example'][0]: + # Code pré v0.7.4 + # if 'iri_example' in hrecipeitem: + # # Note: here is an list, but we're taking the first + # recipeitem['input'] = \ + # hrecipeitem['iri_example'][0]['iri'] + # if 'sheet_index' in hrecipeitem['iri_example'][0]: + # recipeitem['sheet_index'] = \ + # hrecipeitem['iri_example'][0]['sheet_index'] + # recipeitem['recipe'] = hrecipeitem['recipe'] + + recipeitem['recipe'] = hrecipeitem['_recipe'] + + # print('eita123', hrecipeitem['exemplum']) + # print('eita123', hrecipeitem['exemplum'][0]) + + # TODO: this have the [0] hardoded. Should be generalized + if 'exemplum' in hrecipeitem and 'fontem' in hrecipeitem['exemplum'][0]: # noqa + # print('oioioi', hrecipeitem['exemplum']) + if 'iri' in hrecipeitem['exemplum'][0]['fontem']: + recipeitem['input'] = hrecipeitem['exemplum'][0]['fontem']['iri'] # noqa + if 'sheet_index' in hrecipeitem['exemplum'][0]: recipeitem['sheet_index'] = \ hrecipeitem['iri_example'][0]['sheet_index'] - recipeitem['recipe'] = hrecipeitem['recipe'] + # recipeitem['recipe'] = hrecipeitem['recipe'] + result.append(recipeitem) # If the result already is exact one item, return just one diff --git a/hxlm/core/schema/hdp.json-schema.json b/hxlm/core/schema/hdp.json-schema.json index a8fa301..bc62fed 100644 --- a/hxlm/core/schema/hdp.json-schema.json +++ b/hxlm/core/schema/hdp.json-schema.json @@ -131,7 +131,7 @@ "type": "object", "required": [ "id", - "recipe" + "_recipe" ] }, "minItems": 1 diff --git a/tests/hrecipe/hello-world.hrecipe.hdp.yml b/tests/hrecipe/hello-world.hrecipe.hdp.yml index 3e9f138..634d488 100644 --- a/tests/hrecipe/hello-world.hrecipe.hdp.yml +++ b/tests/hrecipe/hello-world.hrecipe.hdp.yml @@ -4,9 +4,10 @@ --- - hsilo: nomen: hello-world.hrecipe.hdp.yml + linguam: mul # https://iso639-3.sil.org/code/mul hrecipe: - id: example-processing-with-a-JSON-spec - recipe: + _recipe: - filter: count patterns: "adm1+name,adm1+code" aggregators: @@ -14,6 +15,28 @@ - filter: clean_data number: "population" number_format: .0f - iri_example: - - iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview - sheet_index: 1 \ No newline at end of file + # iri_example: + # - iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview + # sheet_index: 1 + exemplum: + + # Example one + - fontem: + iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview + _sheet_index: 1 + + # Example two includes both an inline data + - fontem: + # Note: fontem.datum not implemented + datum: + - ['header 1', 'header 2', 'header 3'] + - ['#item +id', '#item +name', '#item +value'] + - ['ACME1', 'ACME Inc.', '123'] + - ['XPTO1', 'XPTO org', '456'] + objectivum: + # Note: fontem.objectivum not implemented + datum: + - ['header 1', 'header 2', 'header 3'] + - ['#item +id', '#item +name', '#item +value'] + - ['ACME1', 'ACME Inc.', '123'] + - ['XPTO1', 'XPTO org', '456'] diff --git a/tests/hrecipe/yemen-01.hrecipe.hdp.yml b/tests/hrecipe/yemen-01.hrecipe.hdp.yml index ae4135c..c998216 100644 --- a/tests/hrecipe/yemen-01.hrecipe.hdp.yml +++ b/tests/hrecipe/yemen-01.hrecipe.hdp.yml @@ -6,7 +6,7 @@ nomen: yemen-01.hrecipe.hdp.yml hrecipe: - id: example-processing-with-a-JSON-spec - recipe: + _recipe: - filter: count patterns: "adm1+name,adm1+code" aggregators: @@ -14,6 +14,7 @@ - filter: clean_data number: "population" number_format: .0f - iri_example: - - iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview - sheet_index: 1 + exemplum: + - fontem: + iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview + _sheet_index: 1 diff --git a/tests/hxl-processing-specs/hxl-processing-specs-test-01.hdp.yml b/tests/hxl-processing-specs/hxl-processing-specs-test-01.hdp.yml index f7d1451..f2ec76c 100644 --- a/tests/hxl-processing-specs/hxl-processing-specs-test-01.hdp.yml +++ b/tests/hxl-processing-specs/hxl-processing-specs-test-01.hdp.yml @@ -21,23 +21,21 @@ - hsilo: "test1" hrecipe: - id: recipe1 - iri_example: - - iri: https://docs.google.com/spreadsheets/d/12k4BWqq5c3mV9ihQscPIwtuDa_QRB-iFohO7dXSSptI/edit#gid=0 - recipe: + _recipe: - filter: with_columns includes: "#vocab+id+v_iso6393_3letter,#vocab+code+v_6391,#vocab+name" - filter: without_rows queries: "#vocab+code+v_6391=" + exemplum: + - fontem: + iri: https://docs.google.com/spreadsheets/d/12k4BWqq5c3mV9ihQscPIwtuDa_QRB-iFohO7dXSSptI/edit#gid=0 - hsilo: nomen: "test1" descriptionem: from https://docs.google.com/presentation/d/17vXOnq2atIDnrODGLs36P1EaUvT-vXPjsc2I1q1Qc50/ hrecipe: - id: example-processing-with-a-JSON-spec - iri_example: - - iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview - sheet_index: 1 - recipe: + _recipe: - filter: count patterns: "adm1+name,adm1+code" aggregators: @@ -45,3 +43,8 @@ - filter: clean_data number: "population" number_format: .0f + exemplum: + - fontem: + iri: https://data.humdata.org/dataset/yemen-humanitarian-needs-overview + _sheet_index: 1 +