Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colors for types and cache/perf tweaks #855

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/create_prefect_dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Prefect Image DEV
name: Create Prefect Image
on:
push:
branches:
Expand All @@ -8,18 +8,17 @@ on:
- 'server/prefect/**'
jobs:
build:
name: Create Dev Prefect Image
name: Create Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and Push Dev Prefect to Docker Hub
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
path: server/prefect
repository: la311data/311_data_prefect
tags: latest
tag_with_ref: true
tag_with_sha: true
7 changes: 3 additions & 4 deletions .github/workflows/create_release_dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create API Image DEV
name: Create API Docker Image
on:
push:
branches:
Expand All @@ -8,18 +8,17 @@ on:
- 'server/api/**'
jobs:
build:
name: Create Dev Docker Images
name: Create Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build and Push Dev API to Docker Hub
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
path: server/api
repository: la311data/311_data_api
tags: latest
tag_with_ref: true
tag_with_sha: true
2 changes: 1 addition & 1 deletion server/api/api.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Application Settings: sets picklecache enable and file location
DEBUG=True
ENV_SOURCE=api.env

CACHE_ENDPOINT=localhost
CACHE_MAX_RETRIES = 5

Expand Down
3 changes: 2 additions & 1 deletion server/api/code/lacity_data_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_managed_secrets(env_name):
# checking for testing or debug
DEBUG = config("DEBUG", cast=bool, default=False)
TESTING = config("TESTING", cast=bool, default=False)
ENV_SOURCE = config("ENV_SOURCE", default=None)
STAGE = config("STAGE", default="Development")

# set to dev or prod when running in ECS
ENV_NAME = config("ENV_NAME", default=None)
Expand Down Expand Up @@ -90,6 +90,7 @@ def get_managed_secrets(env_name):
# set up endpoint for REDIS cache
CACHE_ENDPOINT = config('CACHE_ENDPOINT', default="localhost")
CACHE_MAX_RETRIES = config('CACHE_MAX_RETRIES', cast=int, default=5)
CACHE_MAXMEMORY = config('CACHE_MAXMEMORY', cast=int, default=524288000)

# set up GitHub data
GITHUB_TOKEN = config('GITHUB_TOKEN', default=None)
Expand Down
1 change: 1 addition & 0 deletions server/api/code/lacity_data_api/models/request_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RequestType(db.Model):

type_id = db.Column(db.SmallInteger, primary_key=True)
type_name = db.Column(db.String)
color = db.Column(db.String)


@cached(cache=Cache.REDIS,
Expand Down
1 change: 1 addition & 0 deletions server/api/code/lacity_data_api/models/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class Config:
class RequestType(BaseModel):
type_id: int
type_name: str
color: str

class Config:
orm_mode = True
Expand Down
5 changes: 5 additions & 0 deletions server/api/code/lacity_data_api/models/service_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ async def get_open_requests() -> List[ServiceRequest]:
return result


@cached(cache=Cache.REDIS,
endpoint=CACHE_ENDPOINT,
namespace="filtered",
serializer=serializers.PickleSerializer(),
)
async def get_filtered_requests(
start_date: datetime.date,
end_date: datetime.date,
Expand Down
7 changes: 4 additions & 3 deletions server/api/code/lacity_data_api/routers/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ..models.schemas import StatusTypes
from ..services import status, utilities
from ..config import GITHUB_CODE_VERSION, GITHUB_SHA, DEBUG
from ..config import GITHUB_CODE_VERSION, GITHUB_SHA, DEBUG, STAGE

router = APIRouter()

Expand All @@ -29,9 +29,10 @@ async def check_status_type(status_type: StatusTypes):
if status_type == StatusTypes.api:
return {
'currentTime': datetime.datetime.now(),
'gitSha': GITHUB_SHA,
'lastPulled': await status.get_last_updated(),
'stage': STAGE,
'version': GITHUB_CODE_VERSION,
'lastPulled': await status.get_last_updated()
'gitSha': GITHUB_SHA
}

if status_type == StatusTypes.database:
Expand Down
8 changes: 4 additions & 4 deletions server/api/code/lacity_data_api/services/status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..models import db, cache
from ..config import CACHE_MAXMEMORY


async def get_last_updated():
Expand Down Expand Up @@ -58,11 +59,10 @@ async def get_cache_keys():


async def reset_cache():
'''need to think about when to call this'''
# setting memory limit and policy on Redis
await cache.raw("config_set", "maxmemory-policy", "allkeys-lru")
await cache.raw("config_set", "maxmemory", CACHE_MAXMEMORY)
await cache.raw("flushdb")
# config set maxmemory 1000mb
# config set maxmemory-policy allkeys-lru
# used memory peak: 286 390 120
return True


Expand Down