Skip to content
Snippets Groups Projects

Add create_transcriptions function to call CreateTranscriptions API endpoint

Merged Eva Bardou requested to merge support-create-transcriptions into master

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Bastien Abadie added 2 commits

    added 2 commits

    • 1a9756d0 - 1 commit from branch master
    • 41204d06 - Add create_transcriptions function to call CreateTranscriptions API endpoint

    Compare with previous version

  • This wonderful little worker does not work with use_cache=True, and crashes on a missing ID (when using https://gitlab.com/arkindex/backend/-/merge_requests/1286 on a local backend)

    # -*- coding: utf-8 -*-
    from arkindex_worker.worker import ElementsWorker
    class Demo(ElementsWorker):
        def process_element(self, element):
            print("Demo processing element", element)
            out = self.create_elements(
                parent=element,
                elements=[
                    {
                        "name": f"demo {i}",
                        "type": "crash",
                        "polygon": [
                            [10*i, 10*i],
                            [10*i, 100*i],
                            [100*i, 100*i],
                            [100*i, 10*i],
                            [10*i, 10*i],
                        ]
                    }
                    for i in range(1, 3)
                ]
            )
            from pprint import pprint
            pprint(out)
            out = self.create_transcriptions([
                {
                    "element_id": e["id"],
                    "text": "plop",
                    "score": 0.9
                }
                for e in out
            ])
            pprint(out)
    def main():
        Demo(use_cache=True, description="lol").run()
    if __name__ == "__main__":
        main()

    Traceback:

    2021-03-26 10:56:09,565 INFO/arkindex_worker: Connection to local cache /home/bastien/dev/ark/workers/base/db.sqlite established.
    2021-03-26 10:56:09,565 INFO/arkindex_worker: Starting ML report for unknown worker
    2021-03-26 10:56:11,059 INFO/arkindex_worker: Loaded worker Kaldi Horae revision 48ed481 from API
    2021-03-26 10:56:11,268 INFO/arkindex_worker: Processing page 210545209_006_0013.jpg (1de656ab-1f01-4289-9a23-b10bffd5d4a8) (1/1)
    Demo processing element page 210545209_006_0013.jpg (1de656ab-1f01-4289-9a23-b10bffd5d4a8)
    [{'id': '4a7e229e-2e38-4052-9b90-63cf744172de'},
     {'id': '58d76dbf-3062-4811-a2f4-d6d77b580bf0'}]
    {'confidence': 0.9,
     'element_id': '58d76dbf-3062-4811-a2f4-d6d77b580bf0',
     'text': 'plop'}
    Traceback (most recent call last):
      File "test.py", line 47, in <module>
        main()
      File "test.py", line 43, in main
        Demo(use_cache=True, description="lol").run()
      File "/home/bastien/dev/ark/workers/base/arkindex_worker/worker.py", line 279, in run
        self.process_element(element)
      File "test.py", line 30, in process_element
        out = self.create_transcriptions([
      File "/home/bastien/dev/ark/workers/base/arkindex_worker/worker.py", line 577, in create_transcriptions
        to_insert = [
      File "/home/bastien/dev/ark/workers/base/arkindex_worker/worker.py", line 579, in <listcomp>
        id=convert_str_uuid_to_hex(created_tr["id"]),
    KeyError: 'id'
  • My bad: an outdated schema.yml was inducing the error !

  • Bastien Abadie approved this merge request

    approved this merge request

Please register or sign in to reply
Loading