developmentseed / eoAPI

[Active Development] Earth Observation API (Metadata, Raster and Vector services)
https://eoapi.dev
MIT License
206 stars 22 forks source link

Error on demo data ingestion #15

Closed drnextgis closed 3 years ago

drnextgis commented 3 years ago

Hi! I'm trying to upload some data to the database according to this manual:

$ pypgstac version --dsn postgresql://username:password@localhost:5432/postgis
0.3.4

$ pypgstac load collections oam_collection.json --dsn postgresql://username:password@localhost:5432/postgis --method insert
loading oam_collection.json into collections using insert
Traceback (most recent call last):
  File "/usr/local/bin/pypgstac", line 5, in <module>
    app()
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "/opt/src/pypgstac/pypgstac/pypgstac.py", line 43, in load
    typer.echo(asyncio.run(load_ndjson(file=file, table=table, dsn=dsn, method=method)))
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/opt/src/pypgstac/pypgstac/load.py", line 246, in load_ndjson
    await load_iterator(f, table, conn, method)
  File "/opt/src/pypgstac/pypgstac/load.py", line 230, in load_iterator
    await copy(iter, table, conn)
  File "/opt/src/pypgstac/pypgstac/load.py", line 125, in copy
    delimiter=chr(31),
  File "/usr/local/lib/python3.7/dist-packages/asyncpg/connection.py", line 859, in copy_to_table
    return await self._copy_in(copy_stmt, source, timeout)
  File "/usr/local/lib/python3.7/dist-packages/asyncpg/connection.py", line 1042, in _copy_in
    copy_stmt, reader, data, None, None, timeout)
  File "asyncpg/protocol/protocol.pyx", line 506, in copy_in
asyncpg.exceptions.InvalidTextRepresentationError: invalid input syntax for type json
DETAIL:  The input string ended unexpectedly.
vincentsarago commented 3 years ago

@drnextgis can you make sure your collection is in one line e.g

{"id": "openaerialmap", "title": "OpenAerialMap", "description": "OpenAerialMap Dataset", "stac_version": "1.0.0", "license": "public-domain", "links": [], "extent": {"spatial": {"bbox": [[-180, -90, 180, 90]]}, "temporal": {"interval": [["1944-12-31T13:00:00.000Z", "null"]]}}}

I'll update the readme

drnextgis commented 3 years ago

It did the trick. Thank you Vincent!