Skip to content

Commit

Permalink
Fixed hdx field validation for model
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Dec 28, 2023
1 parent eb89ecd commit 6c101c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,7 @@ def resource_to_hdx(self, uploaded_resources, dataset_config, category):
else None,
},
)
logging.info("Initiating HDX Upload")
uploader.init_dataset()
non_hdx_resources = []
for resource in uploaded_resources:
Expand Down
7 changes: 4 additions & 3 deletions src/validation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,14 @@ def set_geometry_or_iso3(cls, value, values):
dataset = values.get("dataset")
if values.get("hdx_upload"):
for category in values.get("categories"):
if category.hdx is None:
category_name, category_data = list(category.items())[0]
if category_data.hdx is None:
raise ValueError(f"HDX is missing for category {category}")

if dataset is None and values.get("hdx_upload"):
raise ValueError("Dataset config should be supplied for custom polygon")
if values.get("hdx_upload"):
for item in dataset.keys():
if dataset.get(item) is None:
for item in dataset:
if item is None:
raise ValueError(f"Missing, Dataset config : {item}")
return value

0 comments on commit 6c101c1

Please sign in to comment.