diff --git a/.envrc.example b/.envrc.example index 42acb99..2c8b82c 100644 --- a/.envrc.example +++ b/.envrc.example @@ -1,3 +1,18 @@ +#!/bin/bash + +################################################################ +# Change the variables below for access and security. +################################################################ +export DJANGO_ALLOWED_HOSTS="" +export OPENTPOD_DB_PASSWORD="secret!change me!" +export OPENTPOD_REDIS_PASSWORD="secret!change me!" +export DJANGO_SECRET_KEY="secret!change me!" + +################################################################ +# Default environment setup. +# Do not change, unless you know what you are doing +################################################################ + # python setup export PYTHONDONTWRITEBYTECODE=1 @@ -9,23 +24,18 @@ export PORT=3001 export OPENTPOD_TESTING=false # DB -export OPENTPOD_DB_HOST="localhost" -export OPENTPOD_DB="" -export OPENTPOD_DB_PASSWORD="" -export OPENTPOD_DB_PORT="" -export OPENTPOD_DB_VIEWER_PORT="" +export OPENTPOD_DB_HOST="opentpod-db" +export OPENTPOD_DB="opentpod" +export OPENTPOD_DB_PORT="5432" +export OPENTPOD_DB_VIEWER_PORT="18080" # Redis -export OPENTPOD_REDIS_HOST="localhost" -export OPENTPOD_REDIS_PASSWORD="" -export OPENTPOD_REDIS_PORT="" +export OPENTPOD_REDIS_HOST="opentpod-redis" +export OPENTPOD_REDIS_PORT="6379" # Django specific environs -export DJANGO_DEBUG=true -export DJANGO_SECRET_KEY="" -export DJANGO_ALLOWED_HOSTS="" +export DJANGO_DEBUG=false export REDIS_URL="redis://:${OPENTPOD_REDIS_PASSWORD}@${OPENTPOD_REDIS_HOST}:${OPENTPOD_REDIS_PORT}/0" export REDIS_CACHE_URL="redis://:${OPENTPOD_REDIS_PASSWORD}@${OPENTPOD_REDIS_HOST}:${OPENTPOD_REDIS_PORT}/1" export DATABASE_URL="postgres://root:${OPENTPOD_DB_PASSWORD}@${OPENTPOD_DB_HOST}:${OPENTPOD_DB_PORT}/${OPENTPOD_DB}" export CELERY_BROKER_URL=${REDIS_URL} -export USE_DOCKER=false diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index e21f25a..5e7db5c 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1 +1 @@ -Junjue Wang +Junjue Wang diff --git a/Procfile b/Procfile deleted file mode 100644 index 785fea8..0000000 --- a/Procfile +++ /dev/null @@ -1,3 +0,0 @@ -release: python manage.py migrate -web: gunicorn config.wsgi:application -worker: celery worker --app=config.celery_app --loglevel=info diff --git a/config/settings/base.py b/config/settings/base.py index 7232a36..7dc629e 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -78,7 +78,6 @@ "rest_auth", "rest_auth.registration", "django_rq", - "django_celery_beat", "drf_yasg", # for rest api swagger "cacheops", "sendfile", @@ -312,29 +311,6 @@ "root": {"level": "INFO", "handlers": ["console"]}, } -# Celery -# ------------------------------------------------------------------------------ -if USE_TZ: - # http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-timezone - CELERY_TIMEZONE = TIME_ZONE -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url -CELERY_BROKER_URL = env("CELERY_BROKER_URL") -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend -CELERY_RESULT_BACKEND = CELERY_BROKER_URL -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content -CELERY_ACCEPT_CONTENT = ["json"] -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer -CELERY_TASK_SERIALIZER = "json" -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer -CELERY_RESULT_SERIALIZER = "json" -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-time-limit -# TODO: set to whatever value is adequate in your circumstances -CELERY_TASK_TIME_LIMIT = 5 * 60 -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-soft-time-limit -# TODO: set to whatever value is adequate in your circumstances -CELERY_TASK_SOFT_TIME_LIMIT = 60 -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#beat-scheduler -CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler" # django-allauth # ------------------------------------------------------------------------------ ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True) diff --git a/config/settings/local.py b/config/settings/local.py index b07752d..96ccea4 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -45,19 +45,8 @@ } # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] -if env("USE_DOCKER") == "yes": - import socket - - hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS += [ip[:-1] + "1" for ip in ips] # django-extensions # ------------------------------------------------------------------------------ # https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration INSTALLED_APPS += ["django_extensions"] # noqa F405 - -# Celery -# ------------------------------------------------------------------------------ - -# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates -CELERY_TASK_EAGER_PROPAGATES = False # True will make celery run tasks in main thread for dev diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml index b2153ee..3cca536 100644 --- a/docker-compose.debug.yml +++ b/docker-compose.debug.yml @@ -75,8 +75,6 @@ services: - REDIS_URL - REDIS_CACHE_URL - DATABASE_URL - - CELERY_BROKER_URL - - USE_DOCKER - NVIDIA_VISIBLE_DEVICES=all # needed for this to be cuda devices to be visible - NVIDIA_DRIVER_CAPABILITIES=compute,utility depends_on: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index f3badb4..916bd14 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -76,7 +76,6 @@ services: - REDIS_CACHE_URL - DATABASE_URL - CELERY_BROKER_URL - - USE_DOCKER - NVIDIA_VISIBLE_DEVICES=all # needed for this to be cuda devices to be visible - NVIDIA_DRIVER_CAPABILITIES=compute,utility depends_on: diff --git a/docs/development-README.rst b/docs/development-README.rst deleted file mode 100644 index abb40ba..0000000 --- a/docs/development-README.rst +++ /dev/null @@ -1,148 +0,0 @@ -OpenTPOD -======== - -Open Toolkit for Painless Object Detection - -.. image:: https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg - :target: https://github.com/pydanny/cookiecutter-django/ - :alt: Built with Cookiecutter Django -.. image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/ambv/black - :alt: Black code style - - -:License: Apache Software License 2.0 - -Installation --------- - - $ conda env create -f requirements/environment-dev.yml - $ ln -s third_party/cvat/cvat cvat - $ # for developemnt - $ source .envrc - $ docker-compose up - $ supervisord -n -c supervisord/dev.conf - $ # for deployment - $ source .envrc.prod - $ docker-compose -f docker-compose.prod.yml up - - $ # old instructions - $ python manage.py migrate - $ python manage.py createsuperuser - $ python manage.py collectstatic - $ python manage.py rqworker default low - $ python manage.py runserver 0.0.0.0:5000 - $ cd frontend - $ npm i - $ npm run-script watch - - -Settings --------- - -Moved to settings_. - -.. _settings: http://cookiecutter-django.readthedocs.io/en/latest/settings.html - -Basic Commands --------------- - -Setting Up Your Users -^^^^^^^^^^^^^^^^^^^^^ - -* To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go. - -* To create an **superuser account**, use this command:: - - $ python manage.py createsuperuser - -For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. - -Type checks -^^^^^^^^^^^ - -Running type checks with mypy: - -:: - - $ mypy opentpod - -Test coverage -^^^^^^^^^^^^^ - -To run the tests, check your test coverage, and generate an HTML coverage report:: - - $ coverage run -m pytest - $ coverage html - $ open htmlcov/index.html - -Running tests with py.test -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - $ pytest - -Live reloading and Sass CSS compilation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Moved to `Live reloading and SASS compilation`_. - -.. _`Live reloading and SASS compilation`: http://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html - - - -Celery -^^^^^^ - -This app comes with Celery. - -To run a celery worker: - -.. code-block:: bash - - cd opentpod - celery -A config.celery_app worker -l info - -Please note: For Celery's import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right. - - - - -Email Server -^^^^^^^^^^^^ - -In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server `MailHog`_ with a web interface is available as docker container. - -Container mailhog will start automatically when you will run all docker containers. -Please check `cookiecutter-django Docker documentation`_ for more details how to start all containers. - -With MailHog running, to view messages that are sent by your application, open your browser and go to ``http://127.0.0.1:8025`` - -.. _mailhog: https://github.com/mailhog/MailHog - - - -Deployment ----------- - -The following details how to deploy this application. - - -Heroku -^^^^^^ - -See detailed `cookiecutter-django Heroku documentation`_. - -.. _`cookiecutter-django Heroku documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-on-heroku.html - - - -Docker -^^^^^^ - -See detailed `cookiecutter-django Docker documentation`_. - -.. _`cookiecutter-django Docker documentation`: http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html - -env DOCKER_BUILDKIT=1 docker build -t opentpod . diff --git a/local.yml b/local.yml deleted file mode 100644 index 2aa070f..0000000 --- a/local.yml +++ /dev/null @@ -1,69 +0,0 @@ -version: '3' - -volumes: - local_postgres_data: {} - local_postgres_data_backups: {} - -services: - django: &django - build: - context: . - dockerfile: ./compose/local/django/Dockerfile - image: opentpod_local_django - depends_on: - - postgres - - mailhog - volumes: - - .:/app - env_file: - - ./.envs/.local/.django - - ./.envs/.local/.postgres - ports: - - "8000:8000" - command: /start - - postgres: - build: - context: . - dockerfile: ./compose/production/postgres/Dockerfile - image: opentpod_production_postgres - volumes: - - local_postgres_data:/var/lib/postgresql/data - - local_postgres_data_backups:/backups - env_file: - - ./.envs/.local/.postgres - - mailhog: - image: mailhog/mailhog:v1.0.0 - ports: - - "8025:8025" - - redis: - image: redis:5.0 - - celeryworker: - <<: *django - image: opentpod_local_celeryworker - depends_on: - - redis - - postgres - - mailhog - ports: [] - command: /start-celeryworker - - celerybeat: - <<: *django - image: opentpod_local_celerybeat - depends_on: - - redis - - postgres - - mailhog - ports: [] - command: /start-celerybeat - - flower: - <<: *django - image: opentpod_local_flower - ports: - - "5555:5555" - command: /start-flower diff --git a/requirements/base.txt b/requirements/base.txt index 75e94d3..55d6127 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -3,9 +3,6 @@ python-slugify==3.0.2 # https://github.com/un33k/python-slugify Pillow==6.1.0 # https://github.com/python-pillow/Pillow argon2-cffi==19.1.0 # https://github.com/hynek/argon2_cffi redis==3.2.1 # https://github.com/antirez/redis -celery==4.3.0 # pyup: < 5.0 # https://github.com/celery/celery -django-celery-beat==1.5.0 # https://github.com/celery/django-celery-beat -flower==0.9.3 # https://github.com/mher/flower # Django # ------------------------------------------------------------------------------ diff --git a/requirements/local.txt b/requirements/local.txt index deb0c25..c7715d6 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -16,7 +16,6 @@ flake8==3.7.8 # https://github.com/PyCQA/flake8 coverage==4.5.3 # https://github.com/nedbat/coveragepy black==19.3b0 # https://github.com/ambv/black pylint-django==2.0.11 # https://github.com/PyCQA/pylint-django -pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery # Django # ------------------------------------------------------------------------------