opencultureconsulting / openrefine-client

The OpenRefine Python Client from Paul Makepeace provides a library for communicating with an OpenRefine server. This fork extends the command line interface (CLI) and is distributed as a convenient one-file-executable (Windows, Linux, Mac). It is also available via Docker Hub, PyPI and Binder.
GNU General Public License v3.0
83 stars 19 forks source link

Cannot delete project if corrupted #16

Open magdmartin opened 3 years ago

magdmartin commented 3 years ago

I can delete corrupted project from OpenRefine interface but not using the openrefine-client. I have the following error:

Traceback (most recent call last):
  File "/home/felix/openrefine-client/refine.py", line 35, in <module>
  File "/home/felix/openrefine-client/google/refine/__main__.py", line 256, in main
  File "/home/felix/openrefine-client/google/refine/cli.py", line 140, in delete
  File "/home/felix/openrefine-client/google/refine/refine.py", line 371, in __init__
  File "/home/felix/openrefine-client/google/refine/refine.py", line 409, in get_models
  File "/home/felix/openrefine-client/google/refine/refine.py", line 395, in do_json
  File "/home/felix/openrefine-client/google/refine/refine.py", line 114, in urlopen_json
  File "/home/felix/openrefine-client/google/refine/refine.py", line 100, in urlopen
Exception: HTTP 500 "Failed to find project id #2603132304878 - may be corrupt" for http://127.0.0.1:3333/command/core/get-models?project=2603132304878&csrf_token=hD0LqXzZcuNH3vc6RsNgy3yGwFFvE6Vp
    {}
[31739] Failed to execute script refine

Using

felixlohmeier commented 3 years ago

Hi @magdmartin,

I don't know exactly how to reproduce the error. Projects detected as "corrupted" at startup are renamed in the workspace directory (e.g. 1761702727570.project.corrupted) and are then no longer visible via the OpenRefine interface, right? Do you have a hint how I can create a fresh corrupted project for testing? :-)

The difference to the OpenRefine interface could be the initialization of the project via the RefineProject() class in the delete() function which triggers get_models(). That would be this line in the log:

File "/home/felix/openrefine-client/google/refine/refine.py", line 409, in get_models

We could test if the error does not occur with plain curl. Note to self:

curl --data project="1761702727570" "http://localhost:3333/command/core/delete-project?csrf_token=$(curl -s http://localhost:3333/command/core/get-csrf-token | cut -d '"' -f 4)"

Is this error an important problem for your use case or did you just want to let me know?