question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dp.Report failed when using docker image

See original GitHub issue

Following the datapane configuration guidelines, I created a giswqs/geemap-datapane docker image based on nstack/datapane-python-runner. The Python script failed at the last line dp.Report(dp.Plot(Map)).publish(name='geemap_folium_map') with a TypeError: can't pickle weakref objects. Any advice? Thanks.

https://datapane.com/giswqs/scripts/geemap_test/

Dockerfile

from nstack/datapane-python-runner:latest
RUN pip3 install --user -U geemap

datapane.yaml

name: geemap_test
script: geemap_test.py # this could also be ipynb if it was a notebook
container_image_name: giswqs/geemap-datapane

geemap.test.py

import folium
import datapane as dp 
import geemap.eefolium as geemap
import ee
import os

secret = dp.Variable.get(name='EARTHENGINE_TOKEN')
ee_token = secret.value

credential = '{"refresh_token":"%s"}' % ee_token
credential_file_path = os.path.expanduser("~/.config/earthengine/")
os.makedirs(credential_file_path, exist_ok=True)
with open(credential_file_path + 'credentials', 'w') as file:
    file.write(credential)

# m = folium.Map(location=[45.5236, -122.6750])
ee.Initialize()
Map = geemap.Map(center=[40,-100], zoom=4)

# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')

# Set visualization parameters.
vis_params = {
  'min': 0,
  'max': 4000,
  'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}

# Print the elevation of Mount Everest.
xy = ee.Geometry.Point([86.9250, 27.9881])
elev = image.sample(xy, 30).first().get('elevation').getInfo()
print('Mount Everest elevation (m):', elev)

# Add Earth Engine layers to Map
Map.addLayer(image, vis_params, 'DEM')
Map.addLayer(xy, {'color': 'red'}, 'Mount Everest')

# Center the map based on an Earth Engine object or coordinates (longitude, latitude)
# Map.centerObject(xy, 4)
Map.setCenter(86.9250, 27.9881, 4)

# Map.addLayerControl() # This line is not needed for ipyleaflet-based Map.
Map.setControlVisibility()

dp.Report(dp.Plot(Map)).publish(name='geemap_folium_map')

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
giswqscommented, Jul 1, 2020

@mands Thank you for your advice! I am docker beginer. Rebuilding the docker image solved the issue. The report was published successfully. Interestingly, when I checked the Run Report on datapane.com, I can see the the following error. So it seems the script was executed successfully and the report was published even with the import error. I am not sure where this error comes from. I have not encountered this on my local computer.

https://datapane.com/giswqs/reports/geemap_folium_map_496c611a/

0reactions
mandscommented, Jul 7, 2020

Just saw this - yes that hopefully wouldn’t crash the report generation - we capture and send out those logs just for user feedback and information.

Not entirely sure why it doesn’t occur locally but does when running in docker - perhaps adding the missing oauth2client library to your docker requirements.txt file will help

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker+Wasm (Beta) - Docker Documentation
Turn on the containerd feature in Docker Desktop settings and try again. Failed to start shim: failed to resolve runtime path . If...
Read more >
Docker ubuntu:impish: Problem executing scripts DPkg
The failure seems to come with libc6 2.34-0ubuntu2. In a fresh, non-upgraded ubuntu:impish container we currently have libc6 2.33-0ubuntu9, ...
Read more >
"No command specified" from re-imported docker image ...
You can run docker inspect imagename:tagname comparing the original and that imported. I had no luck with import / export and --change ,...
Read more >
You might encounter issues when using Windows Server ...
Symptoms when running or building a container might include: ... You receive the error, “docker: Error response from daemon: container <id> ...
Read more >
Manage Your Docker Builds with JFROG CLI in 5 Easy Steps!
Easily run and manage your Docker builds using JFrog CLI, optimizing your ... jfrog rt dp my-docker-registry.io/my-docker-image:latest ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found