Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
dev container for new db
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan committed Nov 7, 2024
1 parent 1c60eee commit d961652
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 35 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "assesplication-store",
"workspaceFolder": "/assesplication-store",
"shutdownAction": "none",
"customizations": {
"vscode": {
"extensions": [
"ms-python.debugpy",
"ms-python.vscode-pylance",
"eamodio.gitlens",
"ms-python.flake8",
"ms-python.black-formatter"
]
}
}
}
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#10a84a",
"titleBar.activeBackground": "#10a84a",
"titleBar.activeForeground": "#ffffff"
"titleBar.activeBackground": "#e2dc36",
"titleBar.activeForeground": "#000000"
},
"editor.formatOnSave": false,
"python.testing.pytestArgs": [
Expand Down
60 changes: 28 additions & 32 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from os import getenv

import connexion
from _helpers.task_executer_service import AssessmentTaskExecutorService
from apscheduler.schedulers.background import BackgroundScheduler
from config import Config
from connexion import FlaskApp
from connexion.resolver import MethodViewResolver
Expand All @@ -12,8 +10,6 @@
from fsd_utils.healthchecks.healthcheck import Healthcheck
from fsd_utils.logging import logging
from fsd_utils.services.aws_extended_client import SQSExtendedClient
from fsd_utils.sqs_scheduler.context_aware_executor import ContextAwareExecutor
from fsd_utils.sqs_scheduler.scheduler_service import scheduler_executor
from openapi.utils import get_bundled_specs


Expand Down Expand Up @@ -52,35 +48,35 @@ def create_app() -> FlaskApp:
health.add_check(DbChecker(db))

# Initialize sqs extended client
create_sqs_extended_client(flask_app)
# create_sqs_extended_client(flask_app)

executor = ContextAwareExecutor(
max_workers=Config.TASK_EXECUTOR_MAX_THREAD, thread_name_prefix="NotifTask", flask_app=flask_app
)
# Configure Task Executor service
task_executor_service = AssessmentTaskExecutorService(
flask_app=flask_app,
executor=executor,
s3_bucket=Config.AWS_MSG_BUCKET_NAME,
sqs_primary_url=Config.AWS_SQS_IMPORT_APP_PRIMARY_QUEUE_URL,
task_executor_max_thread=Config.TASK_EXECUTOR_MAX_THREAD,
sqs_batch_size=Config.SQS_BATCH_SIZE,
visibility_time=Config.SQS_VISIBILITY_TIME,
sqs_wait_time=Config.SQS_WAIT_TIME,
region_name=Config.AWS_REGION,
endpoint_url_override=Config.AWS_ENDPOINT_OVERRIDE,
aws_access_key_id=Config.AWS_SQS_ACCESS_KEY_ID,
aws_secret_access_key=Config.AWS_SQS_ACCESS_KEY_ID,
)
# Configurations for Flask-Apscheduler
scheduler = BackgroundScheduler()
scheduler.add_job(
func=scheduler_executor,
trigger="interval",
seconds=flask_app.config["SQS_RECEIVE_MESSAGE_CYCLE_TIME"], # Run the job every 'x' seconds
kwargs={"task_executor_service": task_executor_service},
)
scheduler.start()
# executor = ContextAwareExecutor(
# max_workers=Config.TASK_EXECUTOR_MAX_THREAD, thread_name_prefix="NotifTask", flask_app=flask_app
# )
# # Configure Task Executor service
# task_executor_service = AssessmentTaskExecutorService(
# flask_app=flask_app,
# executor=executor,
# s3_bucket=Config.AWS_MSG_BUCKET_NAME,
# sqs_primary_url=Config.AWS_SQS_IMPORT_APP_PRIMARY_QUEUE_URL,
# task_executor_max_thread=Config.TASK_EXECUTOR_MAX_THREAD,
# sqs_batch_size=Config.SQS_BATCH_SIZE,
# visibility_time=Config.SQS_VISIBILITY_TIME,
# sqs_wait_time=Config.SQS_WAIT_TIME,
# region_name=Config.AWS_REGION,
# endpoint_url_override=Config.AWS_ENDPOINT_OVERRIDE,
# aws_access_key_id=Config.AWS_SQS_ACCESS_KEY_ID,
# aws_secret_access_key=Config.AWS_SQS_ACCESS_KEY_ID,
# )
# # Configurations for Flask-Apscheduler
# scheduler = BackgroundScheduler()
# scheduler.add_job(
# func=scheduler_executor,
# trigger="interval",
# seconds=flask_app.config["SQS_RECEIVE_MESSAGE_CYCLE_TIME"], # Run the job every 'x' seconds
# kwargs={"task_executor_service": task_executor_service},
# )
# scheduler.start()

return connexion_app

Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:

assesplication-store:
build:
context: .
volumes:
- .:/assesplication-store:cached
command: sleep infinity
environment:
- DATABASE_URL=postgresql://postgres:password@assesplication-store-db:5432/assesplication_store
- DATABASE_URL_UNIT_TEST=postgresql://postgres:password@fund-store-db:5432/assesplication_store_unit_test
- FLASK_ENV=development



assesplication-store-db:
image: postgres
environment:
- POSTGRES_PASSWORD=password
ports:
- 5434:5432

0 comments on commit d961652

Please sign in to comment.