cuspatial icon indicating copy to clipboard operation
cuspatial copied to clipboard

[DOC] cuSpatial Documentation Example Errors

Open Nicholas-7 opened this issue 3 years ago • 2 comments

Describe the bug cuSpatial documentation has errors in some of the examples present. There are examples that relies on code that cannot be ran without errors in the most recent RAPIDS releases. I've began testing going back to 0.19 and there may have been some change to the API before that release. Not sure if these changes were intentional or if it was an uncaught bug.

Steps/Code to reproduce bug Steps to reproduce the behavior: 1.Go to Rapids cuSpatial documentation website 2.Click on the cuspatial API Reference link 3.Run the content for the examples therein as illustrated below

Expected behavior There will be several examples that will create an error. Many examples miss details that could aide in implementation. The code will be a few commits behind from the 21.10 repo.

Environment details (please complete the following information):

  • Environment location: Paperspace
  • Linux Distro/Architecture: Ubuntu 18.04 amd64
  • GPU Model/Driver: P5000
  • CUDA: 11.4
  • Method of cuDF & cuSpatial install:
docker pull rapidsai/rapidsai:21.10-cuda11.4-runtime-ubuntu18.04-py3.8
docker run --gpus all --rm -it -p 8888:8888 -p 8787:8787 -p 8786:8786 \
    rapidsai/rapidsai:21.10-cuda11.4-runtime-ubuntu18.04-py3.8

Additional context Examples of Discrepancies: Example # 1

import cuspatial
import cudf
import pandas 

try:
    import geopandas
except ModuleNotFoundError:
    os.system('conda install -c conda-forge -y geopandas')
    import geopandas

gpdf = geopandas.read_file('arbitrary.txt')
cugpdf = cuspatial.from_geopandas(gpdf)

Error thrown below:

---------------------------------------------------------------------------
CPLE_OpenFailedError                      Traceback (most recent call last)
fiona/_shim.pyx in fiona._shim.gdal_open_vector()

fiona/_err.pyx in fiona._err.exc_wrap_pointer()

CPLE_OpenFailedError: arbitrary.txt: No such file or directory

During handling of the above exception, another exception occurred:

DriverError                               Traceback (most recent call last)
<ipython-input-4-e03113524eea> in <module>
      9     import geopandas
     10 
---> 11 gpdf = geopandas.read_file('arbitrary.txt')
     12 cugpdf = cuspatial.from_geopandas(gpdf)

/opt/conda/envs/rapids/lib/python3.8/site-packages/geopandas/io/file.py in _read_file(filename, bbox, mask, rows, **kwargs)
    158 
    159     with fiona_env():
--> 160         with reader(path_or_bytes, **kwargs) as features:
    161 
    162             # In a future Fiona release the crs attribute of features will

/opt/conda/envs/rapids/lib/python3.8/site-packages/fiona/env.py in wrapper(*args, **kwargs)
    406     def wrapper(*args, **kwargs):
    407         if local._env:
--> 408             return f(*args, **kwargs)
    409         else:
    410             if isinstance(args[0], str):

/opt/conda/envs/rapids/lib/python3.8/site-packages/fiona/__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs)
    254 
    255         if mode in ('a', 'r'):
--> 256             c = Collection(path, mode, driver=driver, encoding=encoding,
    257                            layer=layer, enabled_drivers=enabled_drivers, **kwargs)
    258         elif mode == 'w':

/opt/conda/envs/rapids/lib/python3.8/site-packages/fiona/collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
    160             if self.mode == 'r':
    161                 self.session = Session()
--> 162                 self.session.start(self, **kwargs)
    163             elif self.mode in ('a', 'w'):
    164                 self.session = WritingSession()

fiona/ogrext.pyx in fiona.ogrext.Session.start()

fiona/_shim.pyx in fiona._shim.gdal_open_vector()

DriverError: arbitrary.txt: No such file or directory

Where I am not able to test without some sort of "arbitrary.txt' to determine success

Example # 2

import cuspatial
import cudf
import pandas 

try:
    import geopandas
except ModuleNotFoundError:
    os.system('conda install -c conda-forge -y geopandas')
    import geopandas
    
cugpdf = cuspatial.GeoDataFrame(gpdf)

Where gpdf will not have definition without the above code finishing successfully.

Error thrown below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-94b435d43abf> in <module>
      9     import geopandas
     10 
---> 11 cugpdf = cuspatial.GeoDataFrame(gpdf)

NameError: name 'gpdf' is not defined

Example # 3

import cuspatial
import cudf
import pandas 

try:
    import geopandas
except ModuleNotFoundError:
    os.system('conda install -c conda-forge -y geopandas')
    import geopandas
    
cuseries.points

Where cuseries.points is not recognized as the code is written

Error thrown below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-24-7975a968805a> in <module>
      9     import geopandas
     10 
---> 11 cuseries.points

NameError: name 'cuseries' is not defined

Example # 4

buffers = GeoArrowBuffers({
    "points_xy":
        [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2],
    "multipoints_xy":
        [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2],
    "multipoints_offsets":
        [0, 6, 12, 18],
    "lines_xy":
        [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2, 3, 0,
         3, 1, 3, 2, 4, 0, 4, 1, 4, 2],
    "lines_offsets":
        [0, 6, 12, 18, 24, 30],
    "mlines":
        [1, 3],
    "polygons_xy":
        [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2, 3, 0,
         3, 1, 3, 2, 4, 0, 4, 1, 4, 2],
    "polygons_polygons": [0, 1, 2],
    "polygons_rings": [0, 1, 2],
    "mpolygons": [1, 3],
})

Where I've added commas to original code to delineate however, 'GeoArrowBuffers' is still not recognized as the code is written in the example. Additional context could be valuable

Error thrown below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-11-edf05c824215> in <module>
----> 1 buffers = GeoArrowBuffers({
      2     "points_xy":
      3         [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2],
      4     "multipoints_xy":
      5         [0, 0, 0, 1, 0, 2, 1, 0, 1, 1, 1, 2, 2, 0, 2, 1, 2, 2],

NameError: name 'GeoArrowBuffers' is not defined

Example # 5

import cuspatial
import cudf
import pandas 

try:
    import geopandas
except ModuleNotFoundError:
    os.system('conda install -c conda-forge -y geopandas')
    import geopandas
    
buffers2 = GeoArrowBuffers(buffers)

Where 'GeoArrowBuffers' is not recognized as the code is written in the example. Additional context could be valuable

Error thrown below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-26-ab87ce1385de> in <module>
      9     import geopandas
     10 
---> 11 buffers2 = GeoArrowBuffers(buffers)

NameError: name 'GeoArrowBuffers' is not defined

Example # 6

objects, traj_offsets = cuspatial.derive_trajectories(...)
dists_and_speeds = cuspatial.trajectory_distances_and_speeds(
        len(traj_offsets)
        objects['object_id'],
        objects['x'],
        objects['y'],
        objects['timestamp']
    )
print(dists_and_speeds)

Where "objects['object_id']", is not recognized as the code is written in documentation

Error thrown below:

---------------------------------------------------------------------------
File "<ipython-input-31-00f2ed148b34>", line 4
    objects['object_id'],
    ^
SyntaxError: invalid syntax

Example # 7

objects, traj_offsets = trajectory.derive_trajectories(
        [0, 0, 1, 1],  # object_id
        [0, 1, 2, 3],  # x
        [0, 0, 1, 1],  # y
        [0, 10, 0, 10] # timestamp
    )
traj_bounding_boxes = cuspatial.trajectory_bounding_boxes(
        len(traj_offsets),
        objects['object_id'],
        objects['x'],
        objects['y']
    )
print(traj_bounding_boxes)

Where "trajectory", is not recognized as the code is written in documentation

Error thrown below:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-33-3811b1e0118c> in <module>
----> 1 objects, traj_offsets = trajectory.derive_trajectories(
      2         [0, 0, 1, 1],  # object_id
      3         [0, 1, 2, 3],  # x
      4         [0, 0, 1, 1],  # y
      5         [0, 10, 0, 10] # timestamp

NameError: name 'trajectory' is not defined

Desired outcome Examples present in cuSpatial documentation should be ready to replicated and implemented with less effort. Examples should reflect the commits made to the repositories during each release cycle. cuSpatial functions and models work as expected.

Request impacts Our cuSpatial documentation is public and requires accurate information - Low Priority

@harrism @taureandyernv for awareness

Nicholas-7 avatar Nov 09 '21 13:11 Nicholas-7

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar Dec 10 '21 00:12 github-actions[bot]

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

github-actions[bot] avatar Mar 10 '22 00:03 github-actions[bot]