curl -sSL https://install.python-poetry.org | python3 -
poetry new suantrazabilidad
Or if project pre-exists, inside the project folder then:
poetry init
poetry add <dependency>
poetry add --dev $(cat requirements.txt)
poetry install
- Locally
- Clone the repo
- Install dependencies with Poetry
- Copy credentials.ini and rename it credentials.local.ini. Update the env values.
- Update the env values
- Start the application using main.py file
- Once the application is run, it creates the first tables project and Principalform and update records from the excel file attached in utils/data.
- Use /kobo/forms/upgrade and /kobo/data/upgrade endpoints to create form tables with data from kobo for all existing forms in kobo or /data/upgrade/{form_id}/ for only form_id
- This form tables are alembic based versionning
- Reflect the change in the excel file found in utils/data.
- Start the application using main.py file
- Use previous kobo upgrades endpoints to make the updates.
Create docker file
Run following commands to create or update the image
docker build -t suantrazabilidad .
docker run -d --name suantrazabilidadapi -p 80:80 suantrazabilidad
Other useful docker commands
docker rm {image}
docker image ls
Install copilot
curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot --help
Then we just need to start copilot CLI
copilot init
Other useful commands
copilot app delete
Create new environment
copilot env init
copilot env deploy --name prod
copilot env ls
When the new environment is created, no service is attached. To deploy service run:
copilot deploy
And select the environment.
poetry add alembic
alembic init alembic
Additional commands for alembic are:
alembic revision --autogenerate -m "Creation of tables"
alembic upgrade head
alembic downgrade -1 # downgrade to previous version
alembic downgrade head # drop tables
- Install celery with broker and backend dependencies (sqs or redis or rabbitmq) and then start both services
aws apprunner list-services
aws apprunner describe-service --service-arn <service-arn>
<!-- 2. Install watchdog to autoupload celery in development whenever there's a change in one of the project files
```shell
poetry add celery[sqs]
#or
poetry add celery[redis]
watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A suantrazabilidad.celery worker --loglevel info
Wathcdemo is only meant to be run in dev mode.
aws ecs describe-tasks --cluster <name_of_the_cluster> --tasks <task_id>
aws ecs describe-tasks --cluster api-test-Cluster-jGAd1ckpBU8v --tasks ee0d8a03f97c4267b193ecbd2ccaad60
aws ecs execute-command \
--cluster <your-cluster-name> \
--task <task-id> \
--container <container-name> \
--interactive \
--command "/bin/sh"
celery -A suantrazabilidad.celery_app worker --loglevel debug
celery -A suantrazabilidad.celery_app beat --loglevel debug