diff --git a/alembic/versions/cbf6bc621994_add_field_disabled_reason.py b/alembic/versions/cbf6bc621994_add_field_disabled_reason.py new file mode 100644 index 0000000..3680d7a --- /dev/null +++ b/alembic/versions/cbf6bc621994_add_field_disabled_reason.py @@ -0,0 +1,24 @@ +"""add field disabled_reason. + +Revision ID: cbf6bc621994 +Revises: afe1900d489f +Create Date: 2024-02-09 14:25:09.295418 + +""" +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "cbf6bc621994" +down_revision = "afe1900d489f" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.add_column("resources", sa.Column("disabled_reason", sa.String)) + + +def downgrade() -> None: + op.drop_column("resources", "disabled_reason") diff --git a/cads_catalogue/database.py b/cads_catalogue/database.py index 8c78082..8850708 100644 --- a/cads_catalogue/database.py +++ b/cads_catalogue/database.py @@ -181,6 +181,7 @@ class Resource(BaseModel): # internal functionality related adaptor = sa.Column(sa.String) adaptor_properties_hash = sa.Column(sa.String) + disabled_reason = sa.Column(sa.String) sources_hash = sa.Column(sa.String) related_resources_keywords: List[str] = sa.Column( dialect_postgresql.ARRAY(sa.String) diff --git a/cads_catalogue/manager.py b/cads_catalogue/manager.py index 9eb84cc..3d147e7 100644 --- a/cads_catalogue/manager.py +++ b/cads_catalogue/manager.py @@ -287,6 +287,7 @@ def load_resource_metadata_file(folder_path: str | pathlib.Path) -> dict[str, An "value": value, } metadata["description"].append(item) # type: ignore + metadata["disabled_reason"] = data.get("disabled_reason") metadata["doi"] = data.get("doi") metadata["ds_contactemail"] = data.get("ds_contactemail") metadata["ds_responsible_organisation"] = data.get("ds_responsible_organisation") diff --git a/tests/data/dumped_resources1.txt b/tests/data/dumped_resources1.txt index c5f2f5f..8c43974 100644 --- a/tests/data/dumped_resources1.txt +++ b/tests/data/dumped_resources1.txt @@ -25,6 +25,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", @@ -80,6 +81,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.68d2bb30", "ds_contactemail": "https://support.ecmwf.int", diff --git a/tests/data/dumped_resources2.txt b/tests/data/dumped_resources2.txt index eb7862e..b0cc5ef 100644 --- a/tests/data/dumped_resources2.txt +++ b/tests/data/dumped_resources2.txt @@ -25,6 +25,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", @@ -80,6 +81,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.68d2bb30", "ds_contactemail": "a_new_test@email", diff --git a/tests/data/dumped_resources3.txt b/tests/data/dumped_resources3.txt index 856f306..84cacb6 100644 --- a/tests/data/dumped_resources3.txt +++ b/tests/data/dumped_resources3.txt @@ -25,6 +25,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", diff --git a/tests/data/dumped_resources4.txt b/tests/data/dumped_resources4.txt index 91f5e3e..cbd5560 100644 --- a/tests/data/dumped_resources4.txt +++ b/tests/data/dumped_resources4.txt @@ -71,6 +71,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -965,6 +966,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -1443,6 +1445,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.20d54e34", "ds_contactemail": "https://support.ecmwf.int", @@ -1494,6 +1497,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", @@ -1549,6 +1553,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.68d2bb30", "ds_contactemail": "https://support.ecmwf.int", @@ -1600,6 +1605,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.bd0915c6", "ds_contactemail": "https://support.ecmwf.int", @@ -1651,6 +1657,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.cea58b5a", "ds_contactemail": "https://support.ecmwf.int/", diff --git a/tests/data/dumped_resources5.txt b/tests/data/dumped_resources5.txt index c9dea48..0b3afe0 100644 --- a/tests/data/dumped_resources5.txt +++ b/tests/data/dumped_resources5.txt @@ -71,6 +71,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -965,6 +966,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -1443,6 +1445,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.20d54e34", "ds_contactemail": "https://support.ecmwf.int", @@ -1494,6 +1497,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", @@ -1549,6 +1553,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.68d2bb30", "ds_contactemail": "https://support.ecmwf.int", @@ -1600,6 +1605,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.bd0915c6", "ds_contactemail": "https://support.ecmwf.int", @@ -1651,6 +1657,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.adbb2d47", "ds_contactemail": "https://support.ecmwf.int", @@ -1702,6 +1709,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.cea58b5a", "ds_contactemail": "https://support.ecmwf.int/", diff --git a/tests/data/dumped_resources6.txt b/tests/data/dumped_resources6.txt index c9dea48..0b3afe0 100644 --- a/tests/data/dumped_resources6.txt +++ b/tests/data/dumped_resources6.txt @@ -71,6 +71,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -965,6 +966,7 @@ "value": "Only one version" } ], + "disabled_reason": null, "documentation": [ { "url": "https://confluence.ecmwf.int/x/OIX4B", @@ -1443,6 +1445,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.20d54e34", "ds_contactemail": "https://support.ecmwf.int", @@ -1494,6 +1497,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", @@ -1549,6 +1553,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.68d2bb30", "ds_contactemail": "https://support.ecmwf.int", @@ -1600,6 +1605,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.bd0915c6", "ds_contactemail": "https://support.ecmwf.int", @@ -1651,6 +1657,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.adbb2d47", "ds_contactemail": "https://support.ecmwf.int", @@ -1702,6 +1709,7 @@ "citation": null, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": null, "documentation": [], "doi": "10.24381/cds.cea58b5a", "ds_contactemail": "https://support.ecmwf.int/", diff --git a/tests/test_40_manager.py b/tests/test_40_manager.py index 24a4bec..514ae87 100644 --- a/tests/test_40_manager.py +++ b/tests/test_40_manager.py @@ -1535,6 +1535,7 @@ def test_load_resource_from_folder() -> None: "citation": None, "contactemail": "https://support.ecmwf.int", "description": [], + "disabled_reason": None, "doi": "10.24381/cds.e2161bac", "ds_contactemail": "https://support.ecmwf.int", "ds_responsible_organisation": "ECMWF",