doccano-client icon indicating copy to clipboard operation
doccano-client copied to clipboard

doccano-client failed to upload a file

Open kovidiament opened this issue 4 years ago • 8 comments

How to reproduce the behaviour

doccano_client = DoccanoClient(
    'http://127.0.0.1:8000/',
    'admin',
    'password'
)
project_info = doccano_client.create_project(name="First Python Project")
upload_file = doccano_client.post_doc_upload(project_id=project_info['id'],
                                             file_name='anexample.json',
                                             format='JSON'
                                             )

Content of an example:

[
    {
        "text": "**Terrible** customer **service**.",
        "label": [],
        "metadata": "hi there",
        "ticker": "TSL"
    },
    {
        "text": "**Great** customer service.",
        "label": [],
        "metadata": "hi there",
        "ticker": "TSL"
    }
]

The problem is, I get exit code 0, but when I look in the dataset for the project, the content is not uploaded. It only works when I do it in GUI.

Your Environment

  • Operating System:
  • Python Version Used: 3.7
  • When you install doccano: 7/5/21
  • How did you install doccano (Heroku button etc): docker

kovidiament avatar Jul 09 '21 19:07 kovidiament

It seems post_doc_upload is not doing anything, in that data does not appear in dataset

kovidiament avatar Jul 09 '21 19:07 kovidiament

Yeah this is a current bug reported in doccano_client repository but it hasn't been fixed yet. If someone can check this in doccano's team it would be great

EnzoNclt avatar Jul 12 '21 07:07 EnzoNclt

May have found the problem, you have to precise to post_doc_upload() the format you want to use. For me, as i used txt files, it looks like this:

    doccano_client.post_doc_upload(project["id"], f, file_path, format="TextFile")

EDIT: You can find the list of available format here

EnzoNclt avatar Jul 12 '21 08:07 EnzoNclt

Yes, I specified format, still doesn't do anything.

kovidiament avatar Jul 12 '21 14:07 kovidiament

appears to be a bug as you said. Any way to programatically upload dataset without this?

kovidiament avatar Jul 12 '21 14:07 kovidiament

Okay so I tried downloading the current code from the repo, as opposed to using pip. Now post_doc_upload works

kovidiament avatar Jul 12 '21 15:07 kovidiament

I'm currently seeing this. Has this been fixed in the latest pull request?

peter-mccabe avatar Feb 08 '22 11:02 peter-mccabe

Tested downloading the latest code and i'm still experiencing this.

peter-mccabe avatar Feb 08 '22 11:02 peter-mccabe