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

Add ability to create a new project via api

Open LizMcQuillan opened this issue 3 years ago • 1 comments

Feature description

Often I need to create multiple, very similar projects. Currently the workflow is to go into the UI and manually create these - it's very repetitive and time consuming. It would be great to have the ability to create a new project using the API, including the ability to upload a dataset, labels, and assign members.

LizMcQuillan avatar Jul 13 '22 19:07 LizMcQuillan

@LizMcQuillan This is currently possible using a series of different functions in the base object, the DoccanoClient has a function create_project for initializing a project. To Attach members to the project the post_members function can be used. Uploading a dataset uses the post_doc_upload function. Adding in the labels will use functions based on the project type, for example a SequenceLabeling project uses the post_span_type_upload . The general flow is

  1. Initialize a DoccanoClient object
  2. Pick a project_type and a resource_type (SequenceLabeling & SequenceLabelingProject etc.)
  3. Get the Username/s and Role Name/s that should be attached to the project
  4. Set a upload Document Path
  5. Set a label upload path
...
project = doccano_client.create_project(name=...., description=...., project_type=...., resourcetype=..., collaborative_annoation=...)
project_id = project["id"]
users = [user]
roles = [role]
_result = doccano_client.post_members(project_id=project_id, usernames=users, roles=roles)

doccano_client.post_span_type_upload(project_id=project_id, file_name=..., file_path=...)
doccano_client.post_doc_upload(project_id=project_id, file_name=..., file_path=...)

Hope this helps!

david-engelmann avatar Jul 18 '22 14:07 david-engelmann