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

Exports missing some images #34

Closed
jywarren opened this issue May 6, 2019 · 38 comments
Closed

Exports missing some images #34

jywarren opened this issue May 6, 2019 · 38 comments

Comments

@jywarren
Copy link
Member

jywarren commented May 6, 2019

Not sure where this is happening, it could be in mapknitter-exporter:

This map: https://mapknitter.org/maps/ceres--2/

Looks like this on MapKnitter:

image

Output in this app is:

image

@jywarren
Copy link
Member Author

jywarren commented May 7, 2019

We probably need to inspect individual images post-warping, and console log out their lat/lon coords too.

@jywarren
Copy link
Member Author

jywarren commented May 7, 2019

As in publiclab/mapknitter-exporter#24

@jywarren
Copy link
Member Author

jywarren commented May 8, 2019

More examples in #23

@icarito
Copy link
Member

icarito commented May 8, 2019

😕
No idea really!

@jywarren
Copy link
Member Author

#32 (comment) maybe found the issue, or part of it!

@jywarren
Copy link
Member Author

Let's solve this first - then go back to cropping:

image

we solved the flipped image. Now let's get all images showing.

@jywarren
Copy link
Member Author

jywarren commented May 22, 2019

Logs from that last run:

I  gdal2tiles.py -k --s_srs EPSG:3857 -t 1558552082 -g AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ public/warps/1558552082/1558552082-geo.tif public/tms/1558552082/
 
I  > generating geotiffs of each warpable in GDAL
 
I  gdal_translate -of GTiff -a_srs EPSG:4326  
-gcp 0.0, 648.9185041561723, 144.9828654528, -37.7664063648 
-gcp 123.41394528001547, 0.0, 144.9831980467, -37.7650239004 
-gcp 589.2020792812109, 83.6029689963907, 144.9844533205, -37.7652020107 
-gcp 465.78813400119543, 732.5214869491756, 144.9841207266, -37.7665844718  
-co "TILED=NO" public/warps/1558564995/w306187-masked.png public/warps/1558564995/w306187-geo-unwarped.tif
 
I  gdalwarp -of GTiff -t_srs EPSG:4326 public/warps/1558564995/w306187-geo-unwarped.tif public/warps/1558564995/w306187.tif
 
I  gdal_translate -of GTiff -a_srs EPSG:4326  
-gcp 0.0, 629.557330114767, 144.983251167, -37.7665679068 
-gcp 122.93185767531395, 0.0, 144.9835824617, -37.765226693 
-gcp 593.175405882299, 86.5655223801732, 144.9848497426, -37.7654111143 
-gcp 480.4295413568616, 705.4702839311212, 144.9845458986, -37.7667296307  
-co "TILED=NO" public/warps/1558564995/w306188-masked.png public/warps/1558564995/w306188-geo-unwarped.tif
 
I  gdalwarp -of GTiff -t_srs EPSG:4326 public/warps/1558564995/w306188-geo-unwarped.tif public/warps/1558564995/w306188.tif
 
I  gdal_translate -of GTiff -a_srs EPSG:4326  
-gcp 0.0, 627.0225297138095, 144.9845230579, -37.7667668191 
-gcp 121.42340435832739, 0.0, 144.9848502874, -37.7654310091 
-gcp 531.4762441441417, 35.82988232374191, 144.9859553576, -37.7655073418 
-gcp 477.73145374655724, 656.8807462733239, 144.9858105183, -37.7668304285  
-co "TILED=NO" public/warps/1558564995/w306189-masked.png public/warps/1558564995/w306189-geo-unwarped.tif
 
I  gdalwarp -of GTiff -t_srs EPSG:4326 public/warps/1558564995/w306189-geo-unwarped.tif public/warps/1558564995/w306189.tif
 
I  gdalwarp -s_srs EPSG:3857 -te 144.9828654528 -37.7668304285 144.9859553576 -37.7650239004 public/warps/1558564995/w306187.tif public/warps/1558564995/1558564995.tif
 
I  gdalwarp public/warps/1558564995/w306188.tif public/warps/1558564995/1558564995.tif
 
I  gdalwarp public/warps/1558564995/w306189.tif public/warps/1558564995/1558564995.tif
 
I  gdal2tiles.py -k --s_srs EPSG:3857 -t 1558564995 -g AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ public/warps/1558564995/1558564995.tif public/tms/1558564995/

@jywarren
Copy link
Member Author

The only image showing is this one:

{"cm_per_pixel":4.99408,"created_at":"2019-02-22T05:56:05Z","deleted":false,"height":2976,"history":"","id":306187,"image_content_type":"image/jpeg","image_file_name":"DJI_1207.JPG","image_file_size":8148349,"locked":false,"map_id":13015,"nodes":[
{"author":"anonymous","body":null,"color":"black","created_at":"2019-02-27T23:13:20Z","description":"","id":2593754,"lat":"-37.7664063648","lon":"144.9828654528","map_id":0,"name":"","order":0,"updated_at":"2019-02-27T23:13:20Z","way_id":0,"way_order":0},
{"author":"anonymous","body":null,"color":"black","created_at":"2019-02-27T23:13:20Z","description":"","id":2593755,"lat":"-37.7650239004","lon":"144.9831980467","map_id":0,"name":"","order":0,"updated_at":"2019-02-27T23:13:20Z","way_id":0,"way_order":0},
{"author":"anonymous","body":null,"color":"black","created_at":"2019-02-27T23:13:20Z","description":"","id":2593756,"lat":"-37.7652020107","lon":"144.9844533205","map_id":0,"name":"","order":0,"updated_at":"2019-02-27T23:13:20Z","way_id":0,"way_order":0},
{"author":"anonymous","body":null,"color":"black","created_at":"2019-02-27T23:13:20Z","description":"","id":2593757,"lat":"-37.7665844718","lon":"144.9841207266","map_id":0,"name":"","order":0,"updated_at":"2019-02-27T23:13:20Z","way_id":0,"way_order":0}
],"parent_id":null,"thumbnail":null,"updated_at":"2019-02-27T23:13:21Z","width":3968,"src":"https://s3.amazonaws.com/grassrootsmapping/warpables/306187/DJI_1207.JPG","srcmedium":"https://s3.amazonaws.com/grassrootsmapping/warpables/306187/DJI_1207_medium.JPG"},

@jywarren
Copy link
Member Author

Hmm. I really can't see why the 2nd and 3rd images aren't getting composited over the first. Maybe I should try uploading the 2nd and 3rd to cloud storage so we can inspect them...

@jywarren
Copy link
Member Author

@jywarren
Copy link
Member Author

I'm adding a new route add working file access: get '/working/:id/:filename' so we can look at the in-between file states.

@jywarren
Copy link
Member Author

We should be able to view with http://export.mapknitter.org/working/1558570858/w306187.tif although the cluster may mess things up... we'll see.

@jywarren
Copy link
Member Author

Alternatively we can upload our working files...

@jywarren
Copy link
Member Author

But, we'd have to modify the gem to do that, since the gem doesn't. Maybe we can find the filenames brute force with a Dir command or something?

@jywarren
Copy link
Member Author

Otherwise I'll try to run it in development mode on Tycho maybe.

@jywarren
Copy link
Member Author

OK, interesting. i was able to download the working images, and all three look good; here are JPG conversions of them:

image

@jywarren
Copy link
Member Author

And using gdalwarp locally i was able to generate this:

image

That was without setting the bounds in the first step. But when I did this:

gdalwarp -s_srs EPSG:3857 -te 144.9828654528 -37.7668304285 144.9859553576 -37.7650239004 w306187.tif output.tif
Creating output file that is 1272P x 744L.
Processing input file w306187.tif.
Using band 4 of source image as alpha.
Using band 4 of destination image as alpha.
0...10...20...30...40...50...60...70...80...90...100 - done.
(xenial)warren@localhost:~/sites/mapknitter-exporter-sinatra/public/debug$ gdalwarp w306188.tif output.tif 
Processing input file w306188.tif.
Using band 4 of source image as alpha.
Using band 4 of destination image as alpha.
0...10...20...30...40...50...60...70...80...90...100 - done.
(xenial)warren@localhost:~/sites/mapknitter-exporter-sinatra/public/debug$ gdalwarp w306189.tif output.tif 
Processing input file w306189.tif.
Using band 4 of source image as alpha.
Using band 4 of destination image as alpha.
0...10...20...30...40...50...60...70...80...90...100 - done.

I got our bug! Great!

image

So, what's wrong with our first step:

gdalwarp -s_srs EPSG:3857 -te 144.9828654528 -37.7668304285 144.9859553576 -37.7650239004 w306187.tif output.tif

@jywarren
Copy link
Member Author

OK, i don't know what was wrong, but a combined command fixes it, and I've released a new gem v1.0.5, which uses a combined command, like:

gdalwarp -s_srs EPSG:3857 -te 144.9828654528 -37.7668304285 144.9859553576 -37.7650239004 w306187.tif w306188.tif w306189.tif output.tif

Fingers 🤞 this should solve the issue!

@jywarren
Copy link
Member Author

We did it!!!!

image

@jywarren
Copy link
Member Author

This may now be solved, as well as #32 -- we should test on a large map!

@jywarren
Copy link
Member Author

jywarren commented May 23, 2019

http://export.mapknitter.org/id/1558588105/status.json (update: this got to 36/44 and stalled)

http://export.mapknitter.org/id/1558588271/status.json (update: this got to 36/44 and stalled)

I accidentally ran 2 at once, and now both seem stalled? It's a really big export... and maybe the scale is too big... but not sure, one got to 1 of 44, and the other got to 3 of 44, and now both seem stuck.

Could a redeploy have happened, interrupting them?

@jywarren
Copy link
Member Author

Ok restarted at scale 50, /id/1558617025/status.json

Also noticed an export running late in the night towards 44 got to 3x...
Screenshot_20190523-091200

@jywarren
Copy link
Member Author

Did it stall after that?

@jywarren
Copy link
Member Author

jywarren commented May 23, 2019

1558617025 seems to have gotten to 44 images! So, in the logs:

2019-05-23 11:55:59.349 EDT
warping 44 of 44

Then i see a /lot/ of gc which I assume is garbage collection. This is the stage where it should be starting to composite them all into one big image.

About 20m later, with lots of gc logs, we then see:

2019-05-23 12:13:31.148 EDT
convert +antialias -size 169x169 xc:none -draw "fill black stroke red stroke-width 30 polyline 75,0 169,115 91,166 0,70 75,0" -alpha set -channel A -transparent red -blur 0x8 -channel R -evaluate set 0 +channel public/warps/1558617025/w306517-mask.png

Then it continues: Creating output file that is 206P x 121L.

minlat 53.8246589557, minlon -7.306684514, maxlat 54.1269084184, maxlon -5.3424996117

Aha!

I  minlat 53.8246589557, minlon -7.306684514, maxlat 54.1269084184, maxlon -5.3424996117
 
  undefined
I  gdalwarp -s_srs EPSG:3857 -te -7.306684514 53.8246589557 -5.3424996117 54.1269084184  public/warps/1558617025/w305302.tif public/warps/1558617025/w305303.tif public/warps/1558617025/w305304.tif public/warps/1558617025/w305305.tif public/warps/1558617025/w305306.tif public/warps/1558617025/w305307.tif public/warps/1558617025/w305308.tif public/warps/1558617025/w305310.tif public/warps/1558617025/w305311.tif public/warps/1558617025/w305313.tif public/warps/1558617025/w306085.tif public/warps/1558617025/w306086.tif public/warps/1558617025/w306087.tif public/warps/1558617025/w306088.tif public/warps/1558617025/w306090.tif public/warps/1558617025/w306091.tif public/warps/1558617025/w306092.tif public/warps/1558617025/w306093.tif public/warps/1558617025/w306097.tif public/warps/1558617025/w306098.tif public/warps/1558617025/w306099.tif public/warps/1558617025/w306100.tif public/warps/1558617025/w306103.tif public/warps/1558617025/w306105.tif public/warps/1558617025/w306106.tif public/warps/1558617025/w306107.tif public/warps/1558617025/w306108.tif public/warps/1558617025/w306109.tif public/warps/1558617025/w306110.tif public/warps/1558617025/w306111.tif public/warps/1558617025/w306112.tif public/warps/1558617025/w306114.tif public/warps/1558617025/w306115.tif public/warps/1558617025/w306506.tif public/warps/1558617025/w306507.tif public/warps/1558617025/w306508.tif public/warps/1558617025/w306509.tif public/warps/1558617025/w306510.tif public/warps/1558617025/w306512.tif public/warps/1558617025/w306513.tif public/warps/1558617025/w306514.tif public/warps/1558617025/w306515.tif public/warps/1558617025/w306516.tif public/warps/1558617025/w306517.tif public/warps/1558617025/1558617025.tif
 
E  ERROR 4: public/warps/1558617025/w305304.tif: No such file or directory
 
I  identify -quiet -format '%b,%w,%h' public/warps/1558617025/1558617025.tif
 
E  identify-im6.q16: unable to open image `public/warps/1558617025/1558617025.tif': No such file or directory @ error/blob.c/OpenBlob/2874.
 
E  saved status.json
 
E  app.rb:179:in `initialize': No such file or directory @ rb_sysopen - public/warps/1558617025/1558617025.tif (Errno::ENOENT)
 
E  	from app.rb:179:in `open'
 
E  	from app.rb:179:in `save_file'
 
E  	from app.rb:152:in `save'
 
E  	from /var/lib/gems/2.5.0/gems/mapknitter-exporter-1.0.5/lib/mapknitterExporter.rb:382:in `run_export'
 
E  	from app.rb:95:in `block in run_export'

It then saved status.json without attempting the next image:

{"status_url":"https://mapknitter-exports-warps.storage.googleapis.com/1558617025/status.json","status":"compositing","tms":false,"geotiff":"public/warps/1558617025/1558617025.tif","zip":false,"jpg":false,"export_id":1558617025,"user_id":null,"size":null,"width":null,"height":null,"cm_per_pixel":50.0}
I  gdalwarp -s_srs EPSG:3857 -te -7.306684514 53.8246589557 -5.3424996117 54.1269084184  
public/warps/1558617025/w305302.tif 
public/warps/1558617025/w305303.tif 
public/warps/1558617025/w305304.tif 
public/warps/1558617025/w305305.tif 
public/warps/1558617025/w305306.tif 
public/warps/1558617025/w305307.tif 
public/warps/1558617025/w305308.tif 
public/warps/1558617025/w305310.tif 
public/warps/1558617025/w305311.tif 
public/warps/1558617025/w305313.tif 
public/warps/1558617025/w306085.tif 
public/warps/1558617025/w306086.tif 
public/warps/1558617025/w306087.tif 
public/warps/1558617025/w306088.tif 
public/warps/1558617025/w306090.tif 
public/warps/1558617025/w306091.tif 
public/warps/1558617025/w306092.tif 
public/warps/1558617025/w306093.tif 
public/warps/1558617025/w306097.tif 
public/warps/1558617025/w306098.tif 
public/warps/1558617025/w306099.tif 
public/warps/1558617025/w306100.tif 
public/warps/1558617025/w306103.tif 
public/warps/1558617025/w306105.tif 
public/warps/1558617025/w306106.tif 
public/warps/1558617025/w306107.tif 
public/warps/1558617025/w306108.tif 
public/warps/1558617025/w306109.tif 
public/warps/1558617025/w306110.tif 
public/warps/1558617025/w306111.tif 
public/warps/1558617025/w306112.tif 
public/warps/1558617025/w306114.tif 
public/warps/1558617025/w306115.tif 
public/warps/1558617025/w306506.tif 
public/warps/1558617025/w306507.tif 
public/warps/1558617025/w306508.tif 
public/warps/1558617025/w306509.tif 
public/warps/1558617025/w306510.tif 
public/warps/1558617025/w306512.tif 
public/warps/1558617025/w306513.tif 
public/warps/1558617025/w306514.tif 
public/warps/1558617025/w306515.tif 
public/warps/1558617025/w306516.tif 
public/warps/1558617025/w306517.tif 
public/warps/1558617025/1558617025.tif
 
E  ERROR 4: 
public/warps/1558617025/w305304.tif: No such file or directory

@jywarren
Copy link
Member Author

OK, yeah - core dumped! Found it, earlier in the process; it was the 3rd image in the sequence:

E  error: info: extensions/v1beta1, Resource=daemonsets "fluentd-gcp-v3.1.1" was not changed
 
I  - [-1626584.6566874061, 14387634.305211876]
 
I  warping 3 of 44
 
I  convert -contrast-stretch 0 public/warps/1558617025-working/w305304-G0131007.JPG -crop 242152x242152+0+0! -flatten -distort Perspective '0,0 0,0  2521,0 611,0  2521,2250 242152,72156  0,2250 0,305' -flatten -crop 72156x72156+0+0! +repage public/warps/1558617025/w305304.png
 
I  [2019-05-23T13:11:02.541Z] "GET /healthzHTTP/1.1" 200 - 0 0 0 0 "-" "kube-probe/1.12+" "a0957d70-f852-480d-9b05-3834232f2b4c" "10.20.7.26:8080" "127.0.0.1:8080" inbound|80||activator-service.knative-serving.svc.cluster.local - 10.20.7.26:8080 10.20.7.1:36566
 
I  [2019-05-23T13:11:07.477Z] "GET /healthzHTTP/1.1" 200 - 0 0 0 0 "-" "kube-probe/1.12+" "21f84c25-98ac-42b2-9d96-0870a1c21f74" "10.20.7.26:8080" "127.0.0.1:8080" inbound|80||activator-service.knative-serving.svc.cluster.local - 10.20.7.26:8080 10.20.7.1:36570
 
E  Aborted (core dumped)
 
I  convert +antialias -size 72156x72156  xc:none -draw "fill black stroke red stroke-width 30 polyline 0,0 611,0 242152,72156 0,305 0,0"  -alpha set -channel A -transparent red -blur 0x8 -channel R -evaluate set 0 +channel public/warps/1558617025/w305304-mask.png
 
E  Aborted (core dumped)
 
I  composite public/warps/1558617025/w305304-mask.png public/warps/1558617025/w305304.png -compose DstIn -alpha Set public/warps/1558617025/w305304-masked.png
 
E  composite-im6.q16: unable to open image `public/warps/1558617025/w305304-mask.png': No such file or directory @ error/blob.c/OpenBlob/2874.
 
E  composite-im6.q16: unable to open image `public/warps/1558617025/w305304.png': No such file or directory @ error/blob.c/OpenBlob/2874.
 
E  composite-im6.q16: unable to open image `public/warps/1558617025/w305304.png': No such file or directory @ error/blob.c/OpenBlob/2874.
 
E  composite-im6.q16: missing an image filename `public/warps/1558617025/w305304-masked.png' @ error/composite.c/CompositeImageCommand/1616.
 
I  gdal_translate -of GTiff -a_srs EPSG:4326  -gcp 0.0, 0.0, -6.430146096, 54.0155232812 -gcp 611.4962192384992, 0.0, -6.427399514, 54.0155232812 -gcp 242152.5055570323, 72156.55470036156, -5.3424996117, 53.8246589557 -gcp 0.0, 305.7481164522469, -6.430146096, 54.0147163742  -co "TILED=NO" public/warps/1558617025/w305304-masked.png public/warps/1558617025/w305304-geo-unwarped.tif
 
E  ERROR 4: public/warps/1558617025/w305304-masked.png: No such file or directory
 
I  gdalwarp -of GTiff -t_srs EPSG:4326 public/warps/1558617025/w305304-geo-unwarped.tif public/warps/1558617025/w305304.tif
 
E  ERROR 4: public/warps/1558617025/w305304-geo-unwarped.tif: No such file or directory
 
E  rm: cannot remove 'public/warps/305304-working/': No such file or directory
 
E  rm: cannot remove 'public/warps/305304/*.png': No such file or directory
 
E  saved status.json
 
I  - [-1431601.1780668714, 14346193.529944427]
 
I  warping 4 of 44

So, when this happens, should we try to get it to retry with a try block?

@jywarren
Copy link
Member Author

Like:

begin
  retries ||= 0
  # try to warp
rescue Exception => e
  puts "failed to warp #{filename}"
  retry if (retries += 1) < 3
end

@jywarren
Copy link
Member Author

LOL

s - I convert -contrast-stretch 0 public/warps/1558617025-working/w305304-G0131007.JPG -crop 242152x242152+0+0! -flatten -distort Perspective '0,0 0,0 2521,0 611,0 2521,2250 242152,72156 0,2250 0,305' -flatten -crop 72156x72156+0+0! +repage public/warps/1558617025/w305304.png

ohhhhhhhh
haha
yeah well, that would fail
it's trying to make a 242,000 pixel wide image

@jywarren
Copy link
Member Author

@jywarren
Copy link
Member Author

Haha, got it. There was one image that was stretched wildly out of proportion, and went into the Irish sea by hundreds of miles:

image

We should think about how to catch these!

@jywarren
Copy link
Member Author

@jywarren
Copy link
Member Author

Accidentally started 2 at once... we'll see how it goes...

@jywarren
Copy link
Member Author

OK, this is still running... warping 18 of 43 -- http://export.mapknitter.org/id/1558630399/status.json

@jywarren
Copy link
Member Author

warping 23 of 43 wow this is big

@jywarren
Copy link
Member Author

OK, it got through warping and to compositing. But another image is missing:

2019-05-23 15:56:10.070 EDT ERROR 4: public/warps/1558630399/w306098.tif: No such file or directory

I'll see if it's wildly out of shape.

{"cm_per_pixel":3.1266,"created_at":"2019-02-13T11:58:29Z","deleted":false,"height":1957,"history":"","id":306098,"image_content_type":"image/jpeg","image_file_name":"G0098074_(2).jpg","image_file_size":578781,"locked":false,"map_id":12986,"nodes":[{"author":"kensuke","body":null,"color":"black","created_at":"2019-03-05T14:55:42Z","description":"","id":2595230,"lat":"54.1252599056","lon":"-7.3042572006","map_id":0,"name":"","order":0,"updated_at":"2019-03-05T14:55:42Z","way_id":0,"way_order":0},{"author":"kensuke","body":null,"color":"black","created_at":"2019-03-05T14:55:42Z","description":"","id":2595231,"lat":"54.1252407307","lon":"-7.3038095697","map_id":0,"name":"","order":0,"updated_at":"2019-03-05T14:55:42Z","way_id":0,"way_order":0},{"author":"kensuke","body":null,"color":"black","created_at":"2019-03-05T14:55:42Z","description":"","id":2595232,"lat":"54.1249600378","lon":"-7.3036641765","map_id":0,"name":"","order":0,"updated_at":"2019-03-05T14:55:42Z","way_id":0,"way_order":0},{"author":"kensuke","body":null,"color":"black","created_at":"2019-03-05T14:55:42Z","description":"","id":2595233,"lat":"54.1248968147","lon":"-7.30414723","map_id":0,"name":"","order":0,"updated_at":"2019-03-05T14:55:42Z","way_id":0,"way_order":0}],"parent_id":null,"thumbnail":null,"updated_at":"2019-03-05T14:55:42Z","width":1598,"src":"https://s3.amazonaws.com/grassrootsmapping/warpables/306098/G0098074_%282%29.jpg","srcmedium":"https://s3.amazonaws.com/grassrootsmapping/warpables/306098/G0098074_%282%29_medium.jpg"}

Hmm. It doesn't look bad. I'll see if there was a memory dump.

@jywarren
Copy link
Member Author

jywarren commented May 23, 2019

OK! It's a filename encoding error:

I  - [-1626179.1233224624, 14387895.887682032]
 
I  warping 19 of 43
 
E  sh: 1: Syntax error: "(" unexpected
 
I  convert -contrast-stretch 0 public/warps/1558630719-working/w306098-G0098074_(2).jpg -crop 1957x1957+0+0! -flatten -distort Perspective '0,0 0,0  1598,0 99,7  1598,1957 132,113  0,1957 24,137' -flatten -crop 137x137+0+0! +repage public/warps/1558630719/w306098.png
 
E  sh: 1: Syntax error: "(" unexpected

Hmm, how to fix this?

@jywarren
Copy link
Member Author

@jywarren
Copy link
Member Author

Dealing with the ( in a new commit!

@jywarren
Copy link
Member Author

And, that big map worked - update at #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants