From bd1c0ccfd400fac065237fbcb24dcd7ce6600745 Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 14:55:54 +0200 Subject: [PATCH 1/8] fix: test with hard coded mapbox tileset name --- harvester/harvester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harvester/harvester.py b/harvester/harvester.py index 3b54c3d6..892ddab4 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -403,7 +403,7 @@ def finishGeojson(feature_list, file_name): url = "https://api.mapbox.com/uploads/v1/{}?access_token={}".format( os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTOKEN")) payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}"}}'.format( - s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET")) + s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), "gdktest") headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers) From 16fab66ad49be45155f36e34782441af7e41abfb Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 15:12:31 +0200 Subject: [PATCH 2/8] revert: hard coded name update test --- harvester/harvester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harvester/harvester.py b/harvester/harvester.py index 892ddab4..3b54c3d6 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -403,7 +403,7 @@ def finishGeojson(feature_list, file_name): url = "https://api.mapbox.com/uploads/v1/{}?access_token={}".format( os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTOKEN")) payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}"}}'.format( - s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), "gdktest") + s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET")) headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers) From 7741b98bc282d3c2ca77215cd2f19fad6773c8bc Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 15:27:58 +0200 Subject: [PATCH 3/8] fix: log payload and env variable --- harvester/harvester.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/harvester/harvester.py b/harvester/harvester.py index 3b54c3d6..877fbd44 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -407,6 +407,8 @@ def finishGeojson(feature_list, file_name): headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers) + logging.info(os.getenv("MAPBOXTILESET")) + logging.info(payload) # wohooo! logging.info("✅ Map updated to timespan: {} to {}".format( startdate, enddate)) From c83aac0c3a6e719226c10cbf1a423227317e045e Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 15:49:11 +0200 Subject: [PATCH 4/8] fix: use other env var for tileset name Plus, assign name to tileset --- harvester/harvester.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/harvester/harvester.py b/harvester/harvester.py index 877fbd44..d6dafb8f 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -402,13 +402,11 @@ def finishGeojson(feature_list, file_name): url = "https://api.mapbox.com/uploads/v1/{}?access_token={}".format( os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTOKEN")) - payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}"}}'.format( - s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET")) + payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}","name":"GDK Dev Trees"}}'.format( + s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESETDEV")) headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers) - logging.info(os.getenv("MAPBOXTILESET")) - logging.info(payload) # wohooo! logging.info("✅ Map updated to timespan: {} to {}".format( startdate, enddate)) From 36239b28c8eb7027462823af2ff46844664039a0 Mon Sep 17 00:00:00 2001 From: Lisa-Stubert <61182572+Lisa-Stubert@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:53:01 +0200 Subject: [PATCH 5/8] add new env variable to workflow --- .github/workflows/test-docker-action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-docker-action.yml b/.github/workflows/test-docker-action.yml index d20221bc..0b6451fa 100644 --- a/.github/workflows/test-docker-action.yml +++ b/.github/workflows/test-docker-action.yml @@ -33,3 +33,4 @@ jobs: MAPBOXUSERNAME: ${{ secrets.MAPBOXUSERNAME }} MAPBOXTOKEN: ${{ secrets.MAPBOXTOKEN }} MAPBOXTILESET: ${{ secrets.MAPBOXTILESET }} + MAPBOXTILESETDEV: ${{ secrets.MAPBOXTILESETDEV }} From 534c3732912e18ce1c61964907da9a6ded12e243 Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 16:26:54 +0200 Subject: [PATCH 6/8] fix: include env var in action.yml --- action.yml | 1 + harvester/harvester.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 58e2aa80..8a59374f 100644 --- a/action.yml +++ b/action.yml @@ -56,5 +56,6 @@ runs: S3_BUCKET: ${{ inputs.S3_BUCKET }} MAPBOXUSERNAME: ${{ inputs.MAPBOXUSERNAME }} MAPBOXTOKEN: ${{ inputs.MAPBOXTOKEN }} + MAPBOXTILESET: ${{ inputs.MAPBOXTILESET }} LOGGING: ${{ inputs.LOGGING }} DATABASE_URL: ${{ inputs.DATABASE_URL }} diff --git a/harvester/harvester.py b/harvester/harvester.py index d6dafb8f..b3b970d0 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -403,7 +403,7 @@ def finishGeojson(feature_list, file_name): url = "https://api.mapbox.com/uploads/v1/{}?access_token={}".format( os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTOKEN")) payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}","name":"GDK Dev Trees"}}'.format( - s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESETDEV")) + s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET")) headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers) From bbd0dd45865650245fd303ab41e3454102ee3735 Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 16:28:11 +0200 Subject: [PATCH 7/8] chore: remove test env var --- .github/workflows/test-docker-action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-docker-action.yml b/.github/workflows/test-docker-action.yml index 0b6451fa..d20221bc 100644 --- a/.github/workflows/test-docker-action.yml +++ b/.github/workflows/test-docker-action.yml @@ -33,4 +33,3 @@ jobs: MAPBOXUSERNAME: ${{ secrets.MAPBOXUSERNAME }} MAPBOXTOKEN: ${{ secrets.MAPBOXTOKEN }} MAPBOXTILESET: ${{ secrets.MAPBOXTILESET }} - MAPBOXTILESETDEV: ${{ secrets.MAPBOXTILESETDEV }} From 7240a9e571169e09481348409b7c52b89b750433 Mon Sep 17 00:00:00 2001 From: Dennis Ostendorf Date: Tue, 10 Aug 2021 16:41:14 +0200 Subject: [PATCH 8/8] fix: give the Mapbox tileset a distinguishable name --- .github/workflows/test-docker-action.yml | 1 + .github/workflows/test.yml | 1 + action.yml | 4 ++++ docker-compose.yml | 1 + harvester/harvester.py | 4 ++-- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-docker-action.yml b/.github/workflows/test-docker-action.yml index d20221bc..fe324cfd 100644 --- a/.github/workflows/test-docker-action.yml +++ b/.github/workflows/test-docker-action.yml @@ -33,3 +33,4 @@ jobs: MAPBOXUSERNAME: ${{ secrets.MAPBOXUSERNAME }} MAPBOXTOKEN: ${{ secrets.MAPBOXTOKEN }} MAPBOXTILESET: ${{ secrets.MAPBOXTILESET }} + MAPBOXLAYERNAME: ${{ secrets.MAPBOXLAYERNAME }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1dc78a0d..b72e6fe4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,7 @@ env: MAPBOXUSERNAME: "123" MAPBOXTOKEN: "456" MAPBOXTILESET: "xyz" + MAPBOXLAYERNAME: "abc" LOGGING: INFO DATABASE_URL: postgresql://fangorn:ent@localhost:5432/trees?schema=public diff --git a/action.yml b/action.yml index 8a59374f..c77114b1 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,9 @@ inputs: MAPBOXTILESET: description: "" required: true + MAPBOXLAYERNAME: + description: "The layer within the tileset that holds the trees data" + required: true LOGGING: description: "" required: true @@ -57,5 +60,6 @@ runs: MAPBOXUSERNAME: ${{ inputs.MAPBOXUSERNAME }} MAPBOXTOKEN: ${{ inputs.MAPBOXTOKEN }} MAPBOXTILESET: ${{ inputs.MAPBOXTILESET }} + MAPBOXLAYERNAME: ${{ inputs.MAPBOXLAYERNAME }} LOGGING: ${{ inputs.LOGGING }} DATABASE_URL: ${{ inputs.DATABASE_URL }} diff --git a/docker-compose.yml b/docker-compose.yml index 3d5fa8e5..68c30051 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,6 +24,7 @@ services: MAPBOXUSERNAME: "123" MAPBOXTOKEN: "456" MAPBOXTILESET: "xyz" + MAPBOXLAYERNAME: "abc" OUTPUT: "True" LOGGING: INFO diff --git a/harvester/harvester.py b/harvester/harvester.py index b3b970d0..6e5bfb12 100644 --- a/harvester/harvester.py +++ b/harvester/harvester.py @@ -402,8 +402,8 @@ def finishGeojson(feature_list, file_name): url = "https://api.mapbox.com/uploads/v1/{}?access_token={}".format( os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTOKEN")) - payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}","name":"GDK Dev Trees"}}'.format( - s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET")) + payload = '{{"url":"http://{}.s3.amazonaws.com/{}","tileset":"{}.{}","name":"{}"}}'.format( + s3_credentials["bucket"], s3_credentials["key"], os.getenv("MAPBOXUSERNAME"), os.getenv("MAPBOXTILESET"), os.getenv("MAPBOXLAYERNAME")) headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Cache-Control': 'no-cache'} response = requests.post(url, data=payload, headers=headers)