You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.0 KiB

  1. # Getting started
  2. ## Usage
  3. doccano has two options to run:
  4. - (Recommended) Docker Compose
  5. - Docker
  6. The usage of docker compose version is explained in the [README.md](https://github.com/doccano/doccano/blob/master/README.md#usage). We highly recommend that you should use docker compose version. However, we explain the usage of Docker version and Python/Node version for the additional information.
  7. ### Docker
  8. As a one-time setup, create a Docker container for Doccano:
  9. ```bash
  10. docker pull doccano/doccano
  11. docker container create --name doccano \
  12. -e "ADMIN_USERNAME=admin" \
  13. -e "ADMIN_EMAIL=admin@example.com" \
  14. -e "ADMIN_PASSWORD=password" \
  15. -p 8000:8000 doccano/doccano
  16. ```
  17. Next, start Doccano by running the container:
  18. ```bash
  19. docker container start doccano
  20. ```
  21. To stop the container, run `docker container stop doccano -t 5`.
  22. All data created in the container will persist across restarts.
  23. Go to <http://127.0.0.1:8000/>.
  24. ### Setup development environment
  25. You can setup development environment via Python and Node.js. You need to install Git and to clone the repository:
  26. ```bash
  27. git clone https://github.com/doccano/doccano.git
  28. cd doccano
  29. ```
  30. ### Backend
  31. The doccano backend is built in Python 3.8+ and uses [Poetry](https://github.com/python-poetry/poetry) as a dependency manager. If you haven't installed them yet, please see [Python](https://www.python.org/downloads/) and [Poetry](https://python-poetry.org/docs/) documentation.
  32. First, to install the defined dependencies for our project, just run the `install` command. After that, activate the virtual environment by runnning `shell` command:
  33. ```bash
  34. cd backend
  35. poetry install
  36. poetry shell
  37. ```
  38. Second, setup database and run the development server. Doccano uses [Django](https://www.djangoproject.com/) and [Django Rest Framework](https://www.django-rest-framework.org/) as a backend. We can setup them by using Django command:
  39. ```bash
  40. python manage.py migrate
  41. python manage.py create_roles
  42. python manage.py create_admin --noinput --username "admin" --email "admin@example.com" --password "password"
  43. python manage.py runserver
  44. ```
  45. In another terminal, you need to run Celery to use import/export dataset feature:
  46. ```bash
  47. cd doccano/backend
  48. celery --app=config worker --loglevel=INFO --concurrency=1
  49. ```
  50. After you change the code, don't forget to run [mypy](https://mypy.readthedocs.io/en/stable/index.html), [flake8](https://flake8.pycqa.org/en/latest/), [black](https://github.com/psf/black), and [isort](https://github.com/PyCQA/isort). These ensures the code consistency. To run them, just run the following commands:
  51. ```bash
  52. poetry run task mypy
  53. poetry run task flake8
  54. poetry run task black
  55. poetry run task isort
  56. ```
  57. Similarly, you can run the test by executing the following command:
  58. ```bash
  59. poetry run task test
  60. ```
  61. Did you pass the test? Great!
  62. ### Frontend
  63. The doccano frontend is built in Node.js and uses [Yarn](https://yarnpkg.com/) as a package manager. If you haven't installed them yet, please see [Node.js](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/) documentation.
  64. First, to install the defined dependencies for our project, just run the `install` command.
  65. ```bash
  66. cd frontend
  67. yarn install
  68. ```
  69. Then run the `dev` command to serve with hot reload at <localhost:3000>:
  70. ```bash
  71. yarn dev
  72. ```
  73. ## How to create a Python package
  74. During development, you may want to create a Python package and verify it works correctly. In such a case, you can create a package by running the following command in the root directory of your project:
  75. ```bash
  76. ./tools/create-package.sh
  77. ```
  78. This command builds the frontend, copies the files, and packages them. This will take a few minutes. After finishing the command, you will find `sdist` and `wheel` in `backend/dist`:
  79. ```bash
  80. Building doccano (1.5.5.post335.dev0+6be6d198)
  81. - Building sdist
  82. - Built doccano-1.5.5.post335.dev0+6be6d198.tar.gz
  83. - Building wheel
  84. - Built doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl
  85. ```
  86. Then, you can install the package via `pip install` command:
  87. ```bash
  88. pip install doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl
  89. ```