Skip to content

Commit

Permalink
use pk from bcdata (requires 0.12.2), retain only harvest restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Aug 16, 2024
1 parent 3d90be8 commit a11226e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 114 deletions.
6 changes: 5 additions & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def validate_bcgw(source):
f"Validation error: {source['alias']} - Primary key - {source['primary_key']} is not present in {table}"
)

# are other required columns in field mapping present?
# required columns in field mapping present?
for column in source["field_mapper"].values():
if (
column
Expand Down Expand Up @@ -187,6 +187,10 @@ def download_source(source):
as_gdf=True,
lowercase=True,
)
# if primary key not provided in config, default to the pk noted in bcdata
# for the given tabel
if not source["primary_key"] and source["source"] in bcdata.primary_keys:
source["primary_key"] = bcdata.primary_keys[source["source"]]

# download file
elif source["source_type"] == "FILE":
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bcdata
bcdata >= 0.12.2
jsonschema
pyarrow
python-slugify
14 changes: 2 additions & 12 deletions source.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": ["string", "null"]
},
"primary_key": {
"description": "The column holding primary key for source",
"description": "The source column holding the primary key",
"type": ["string", "null"]
},
"field mapper": {
Expand All @@ -48,20 +48,10 @@
"description": "Forest harvesting restriction level associated with the designation",
"type": "integer",
"enum": [1, 2, 3, 4, 5, 6]
},
"og_restriction": {
"description": "Oil and gas restriction level associated with the designation",
"type": "integer",
"enum": [0, 1, 2, 3, 4, 5, 6]
},
"mining_restriction": {
"description": "Mining restriction level associated with the designation",
"type": "integer",
"enum": [0, 1, 2, 3, 4, 5, 6]
}
}
}
},
"required": ["alias", "description", "source_type", "source", "query", "primary_key", "field_mapper", "data"]
"required": ["alias", "description", "source_type", "source", "query", "field_mapper", "data"]
}
}
Loading

0 comments on commit a11226e

Please sign in to comment.