Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new string column disabled_reason #109

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions alembic/versions/cbf6bc621994_add_field_disabled_reason.py
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions cads_catalogue/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cads_catalogue/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions tests/data/dumped_resources1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/data/dumped_resources2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tests/data/dumped_resources3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions tests/data/dumped_resources4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -965,6 +966,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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/",
Expand Down
8 changes: 8 additions & 0 deletions tests/data/dumped_resources5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -965,6 +966,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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/",
Expand Down
8 changes: 8 additions & 0 deletions tests/data/dumped_resources6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -965,6 +966,7 @@
"value": "Only one version"
}
],
"disabled_reason": null,
"documentation": [
{
"url": "https://confluence.ecmwf.int/x/OIX4B",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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/",
Expand Down
1 change: 1 addition & 0 deletions tests/test_40_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading