diff --git a/jupyter/protoyping.ipynb b/jupyter/protoyping.ipynb index 81f5894..8fff933 100644 --- a/jupyter/protoyping.ipynb +++ b/jupyter/protoyping.ipynb @@ -17,18 +17,20 @@ "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" + "ename": "ValueError", + "evalue": "Schema 'project' property 'consent_codes' with type 'array' must include an 'items' property. Please add an 'items' property to the 'properties' section.", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m lipid_schema = g.utils.load_yaml(\u001b[33m\"\u001b[39m\u001b[33m/Users/harrijh/projects/gen3schemadev/src/gen3schemadev/schema/schema_templates/project.yaml\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 2\u001b[39m rule_val = g.validators.rule_validator.RuleValidator(lipid_schema)\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[43mrule_val\u001b[49m\u001b[43m.\u001b[49m\u001b[43mtype_array_needs_items\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mFile \u001b[39m\u001b[32m~/projects/gen3schemadev/src/gen3schemadev/validators/rule_validator.py:226\u001b[39m, in \u001b[36mRuleValidator.type_array_needs_items\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 224\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(value, \u001b[38;5;28mdict\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m value.get(\u001b[33m\"\u001b[39m\u001b[33mtype\u001b[39m\u001b[33m\"\u001b[39m) == \u001b[33m\"\u001b[39m\u001b[33marray\u001b[39m\u001b[33m\"\u001b[39m:\n\u001b[32m 225\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m value:\n\u001b[32m--> \u001b[39m\u001b[32m226\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 227\u001b[39m \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mSchema \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m.schema.get(\u001b[33m'\u001b[39m\u001b[33mid\u001b[39m\u001b[33m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[33m property \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mkey\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[33m with type \u001b[39m\u001b[33m'\u001b[39m\u001b[33marray\u001b[39m\u001b[33m'\u001b[39m\u001b[33m must include an \u001b[39m\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m\u001b[33m property. \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 228\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mPlease add an \u001b[39m\u001b[33m'\u001b[39m\u001b[33mitems\u001b[39m\u001b[33m'\u001b[39m\u001b[33m property to the \u001b[39m\u001b[33m'\u001b[39m\u001b[33mproperties\u001b[39m\u001b[33m'\u001b[39m\u001b[33m section.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 229\u001b[39m )\n\u001b[32m 230\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m\n", + "\u001b[31mValueError\u001b[39m: Schema 'project' property 'consent_codes' with type 'array' must include an 'items' property. Please add an 'items' property to the 'properties' section." + ] } ], "source": [ - "lipid_schema = g.utils.load_yaml(\"../output/lipidomics_file.yaml\")\n", + "lipid_schema = g.utils.load_yaml(\"/Users/harrijh/projects/gen3schemadev/src/gen3schemadev/schema/schema_templates/project.yaml\")\n", "rule_val = g.validators.rule_validator.RuleValidator(lipid_schema)\n", "rule_val.type_array_needs_items()" ] diff --git a/pyproject.toml b/pyproject.toml index 57e32bd..d62f201 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "Gen3SchemaDev" -version = "2.3.1" +version = "2.3.2" description = "Tool for data modelling in Gen3" authors = [ {name = "JoshuaHarris391",email = "harjo391@gmail.com"} diff --git a/src/gen3schemadev/cli.py b/src/gen3schemadev/cli.py index 4d49edb..fc5fb98 100644 --- a/src/gen3schemadev/cli.py +++ b/src/gen3schemadev/cli.py @@ -205,9 +205,10 @@ def main(): # Exclusion list exclude_schema_list = [ - 'project', '_definitions', '_settings', - '_terms', 'core_metadata_collection', - 'program' + '_definitions', + '_settings', + '_terms', + 'core_metadata_collection', ] if args.no_exclude: print(f"Validation now includes: {exclude_schema_list}") diff --git a/src/gen3schemadev/schema/schema_templates/project.yaml b/src/gen3schemadev/schema/schema_templates/project.yaml index f373ed8..66209ee 100644 --- a/src/gen3schemadev/schema/schema_templates/project.yaml +++ b/src/gen3schemadev/schema/schema_templates/project.yaml @@ -126,6 +126,34 @@ properties: \ and/or material might be removed, stored or used. \\n\n Based on the\ \ Data Use Ontology : see http://www.obofoundry.org/ontology/duo.html" type: array + items: + type: string + enum: + - General Research Use + - Health or Biomedical Research + - Disease Specific Research + - not for profit, non commercial user only + - ethics approval required + - user specific restriction + enumDef: + - enumeration: General Research Use + source: duo + term_id: DUO:0000042 + - enumeration: Health or Biomedical Research + source: duo + term_id: DUO:0000006 + - enumeration: Disease Specific Research + source: duo + term_id: DUO:0000007 + - enumeration: not for profit, non commercial user only + source: duo + term_id: DUO:0000018 + - enumeration: ethics approval required + source: duo + term_id: DUO:0000021 + - enumeration: user specific restriction + source: duo + term_id: DUO:0000026 data_access_url: description: A URL link that takes you to a page that explains how to gain access to the project