Skip to content

Commit

Permalink
Merge pull request #123 from NASA-IMPACT/develop
Browse files Browse the repository at this point in the history
Release v0.6.0
  • Loading branch information
leothomas authored May 6, 2021
2 parents 7e13c0f + 4d31783 commit 0acd3ae
Show file tree
Hide file tree
Showing 32 changed files with 196 additions and 86 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Dockerfiles/ecs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ COPY README.md /app/README.md
COPY covid_api/ /app/covid_api/
COPY setup.py /app/setup.py

RUN pip install -e /app/. --no-cache-dir
RUN pip install -e /app/. boto3 --no-cache-dir

CMD ["/start-reload.sh"]
12 changes: 10 additions & 2 deletions Dockerfiles/lambda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ COPY covid_api/ /app/covid_api/
COPY setup.py /app/setup.py

RUN pip install --upgrade pip
RUN pip install . "mangum>=0.9.0" -t /var/task --no-binary numpy, pydantic
RUN pip install . "mangum==0.9.2" -t /var/task --no-binary numpy, pydantic

# Reduce package size and remove useless files
RUN cd /var/task && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[2-3][0-9]//'); cp $f $n; done;
RUN cd /var/task && find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN cd /var/task && find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
RUN find /var/task -type d -a -name 'tests' -print0 | xargs -0 rm -rf
RUN rm -rdf /var/task/numpy/doc/
RUN echo "Remove lambda python packages"
RUN rm -rdf /var/task/numpy/doc/
RUN rm -rdf /var/task/stack
RUN rm -rdf /var/task/boto3*
RUN rm -rdf /var/task/botocore*
RUN rm -rdf /var/task/docutils*
RUN rm -rdf /var/task/dateutil*
RUN rm -rdf /var/task/jmespath*
RUN rm -rdf /var/task/s3transfer*


COPY lambda/handler.py /var/task/handler.py

45 changes: 0 additions & 45 deletions cdk.context.json

This file was deleted.

1 change: 0 additions & 1 deletion covid_api/api/api_v1/endpoints/detections.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def get_detection(ml_type: MLTypes, site: SiteNames, date: str):
""" Handle /detections requests."""

try:

return json.loads(
s3_get(
bucket=config.INDICATOR_BUCKET,
Expand Down
4 changes: 2 additions & 2 deletions covid_api/db/static/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def get(self, spotlight_id: str, api_url: str) -> Datasets:

def get_all(self, api_url: str) -> Datasets:
"""Fetch all Datasets. Overload domain with S3 scanned domain"""
# print(self._load_domain_metadata())
datasets = self._process(
datasets_domains_metadata=self._load_domain_metadata()["_all"],
api_url=api_url,
Expand Down Expand Up @@ -154,6 +153,7 @@ def _process(
(list) : datasets metadata objects (to be serialized as a pydantic Datasets
model)
"""

output_datasets = {
k: v
for k, v in self._data().items()
Expand All @@ -163,7 +163,7 @@ def _process(
for k, dataset in output_datasets.items():

# overload domain with domain returned from s3 file
dataset.domain = datasets_domains_metadata[k]["domain"]
dataset.domain = datasets_domains_metadata.get(k, {}).get("domain", [])

# format url to contain the correct API host and
# spotlight id (if a spotlight was requested)
Expand Down
3 changes: 3 additions & 0 deletions covid_api/db/static/datasets/agriculture.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
},
"exclusive_with": [
"no2",
"no2-diff",
"co2",
"co2-diff",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/co2-diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"no2",
"no2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/co2.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
"agriculture",
"no2",
"co2-diff",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/detections-contrail.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-vehicles"
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/detections-plane.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-contrail",
"detections-vehicles"
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/detections-ship.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-plane",
"detections-contrail",
"detections-vehicles"
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/detections-vehicles.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail"
Expand Down
50 changes: 50 additions & 0 deletions covid_api/db/static/datasets/fb-population-density.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"id": "fb-population-density",
"name": "Facebook Population Density",
"type": "raster",
"time_unit": "day",
"source": {
"type": "raster",
"tiles": [
"{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/dataforgood-fb-population-density/cog.tif&rescale=0,69&resampling_method=nearest&color_map=ylorrd"
]
},
"paint": {
"raster-opacity": 0.9
},
"exclusive_with": [
"agriculture",
"no2",
"co2-diff",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-vehicles"
],
"enabled": true,
"swatch": {
"color": "#C0C0C0",
"name": "Grey"
},
"legend": {
"type": "gradient",
"min": "less",
"max": "more",
"stops": [
"#99c5e0",
"#f9eaa9",
"#f7765d",
"#c13b72",
"#461070",
"#050308"
]
},
"info": "Facebook high-resolution population density: Darker areas indicate higher population density areas and lighter areas indicate lower population density areas"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "population",
"id": "gibs-population",
"name": "Population",
"type": "raster",
"time_unit": "day",
Expand All @@ -21,7 +21,8 @@
"detection-ship",
"detection-multi",
"water-chlorophyll",
"water-spm"
"water-spm",
"water-pzd"
],
"swatch": {
"color": "#C0C0C0",
Expand Down
4 changes: 3 additions & 1 deletion covid_api/db/static/datasets/nightlights-hd.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
"source": {
"type": "raster",
"tiles": [
"{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/bmhd_30m_monthly/BMHD_VNP46A2_{spotlightId}_{date}_cog.tif&resampling_method=bilinear&bidx=1%2C2%2C3"
"{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/bmhd_30m_monthly/BMHD_VNP46A2_{spotlightId}_{date}_cog.tif&bidx=1&rescale=0,255&color_map=inferno"
]
},
"exclusive_with": [
"agriculture",
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/nightlights-viirs.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"no2",
"co2-diff",
"co2",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/no2-diff.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"exclusive_with": [
"co2",
"co2-diff",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
Expand All @@ -25,6 +26,7 @@
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"no2"
],
"enabled": false,
Expand Down
2 changes: 2 additions & 0 deletions covid_api/db/static/datasets/no2.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"agriculture",
"co2",
"co2-diff",
"fb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-multi",
"water-chlorophyll",
"water-spm",
"water-pzd",
"detections-ship",
"detections-plane",
"detections-contrail",
Expand Down
4 changes: 3 additions & 1 deletion covid_api/db/static/datasets/recovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
"agriculture",
"co2",
"co2-diff",
"gifb-population-density",
"gibs-population",
"car-count",
"nightlights-viirs",
"nightlights-hd",
"detection-ship",
"detection-multi",
"water-chlorophyll",
"water-spm"
"water-spm",
"water-pzd"
],
"enabled": true,
"swatch": {
Expand Down
Loading

0 comments on commit 0acd3ae

Please sign in to comment.