PecanProject / BETYdb-YABA

Yet Another BETYdb API (for metadata upload)
BSD 3-Clause "New" or "Revised" License
5 stars 18 forks source link

Not able to insert sites table properly #55

Open im-prakher opened 4 years ago

im-prakher commented 4 years ago

Actually, when I was inserting sites table using the client route,

curl -F "fileName=@input_files/sites.csv" \ -F "shp_file=@input_files/S8_two_row_polys.shp" \ -F "dbf_file=@input_files/S8_two_row_polys.dbf" \ -F "prj_file=@input_files/S8_two_row_polys.prj" \ -F "shx_file=@input_files/S8_two_row_polys.shx" \ http://localhost:6001/sites

the app returned the response 410 and logged this error,

ERROR:root:Traceback (most recent call last): yaba_api_1 | File "fiona/_shim.pyx", line 74, in fiona._shim.gdal_open_vector yaba_api_1 | File "fiona/_err.pyx", line 270, in fiona._err.exc_wrap_pointer yaba_api_1 | fiona._err.CPLE_OpenFailedError: '/code/temp/shp_file' not recognized as a supported file format. yaba_api_1 | yaba_api_1 | During handling of the above exception, another exception occurred: yaba_api_1 | yaba_api_1 | Traceback (most recent call last): yaba_api_1 | File "/code/Meta.py", line 132, in insert_sites yaba_api_1 | data_g1=gpd.read_file(shp_file_target) yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/geopandas/io/file.py", line 77, in read_file yaba_api_1 | with reader(path_or_bytes, **kwargs) as features: yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/env.py", line 398, in wrapper yaba_api_1 | return f(*args, **kwargs) yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/__init__.py", line 254, in open yaba_api_1 | layer=layer, enabled_drivers=enabled_drivers, **kwargs) yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/collection.py", line 154, in __init__ yaba_api_1 | self.session.start(self, **kwargs) yaba_api_1 | File "fiona/ogrext.pyx", line 484, in fiona.ogrext.Session.start yaba_api_1 | File "fiona/_shim.pyx", line 81, in fiona._shim.gdal_open_vector yaba_api_1 | fiona.errors.DriverError: '/code/temp/shp_file' not recognized as a supported file format.

But when I use the yaba_api route for inserting sites table,

curl -F "fileName=@input_files/sites.csv" \ -F "shp_file=@input_files/S8_two_row_polys.shp" \ -F "dbf_file=@input_files/S8_two_row_polys.dbf" \ -F "prj_file=@input_files/S8_two_row_polys.prj" \ -F "shx_file=@input_files/S8_two_row_polys.shx" \ http://localhost:5001/yaba/v1/sites

it succeeded in doing so. Also, when I am making a request using the browser, both routes log the same error. Don't know what is causing this.

@Chris-Schnaufer @saurabh1969 @dlebauer @KristinaRiemer

saurabh1969 commented 4 years ago

@im-prakher Firstly,the above api call are POST.And when you request through browser,it is always GET call.And,whenever you are using client api route( http://localhost:6001/sites) ,make sure your server is running properly.

And for above error,it seems like it is file path issue.Please check this link : https://github.com/Toblerity/Fiona/issues/742. It will surely help.

im-prakher commented 4 years ago

Making requests using cuRL or browser doesn't make any difference on the request method part, and the request method here is POST for the route. Also, I am making POST requests to the other routes and that's working fine. https://github.com/PecanProject/BETYdb-YABA/blob/7518714f5de479cbdbc56219e70444efcfe5712f/client/client.py#L32-L36

Will look into this Toblerity/Fiona/issues/742. Thanks!