Skip to content

Commit

Permalink
build script updated + video rendering bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushK52 committed Sep 7, 2023
1 parent bf1e840 commit 4f36a18
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 35 deletions.
76 changes: 76 additions & 0 deletions .aws/task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"taskDefinitionArn": "arn:aws:ecs:ap-south-1:861629679241:task-definition/backend-banodoco-frontend-task:6",
"containerDefinitions": [
{
"name": "backend-banodoco-frontend",
"image": "861629679241.dkr.ecr.ap-south-1.amazonaws.com/banodoco-frontend:latest",
"cpu": 512,
"memory": 2048,
"portMappings": [
{
"containerPort": 5500,
"hostPort": 5500,
"protocol": "tcp"
}
],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/backend/banodoco-frontend",
"awslogs-region": "ap-south-1",
"awslogs-stream-prefix": "backend/banodoco-frontend"
}
}
}
],
"family": "backend-banodoco-frontend-task",
"taskRoleArn": "arn:aws:iam::861629679241:role/ecs-task-role",
"executionRoleArn": "arn:aws:iam::861629679241:role/ecs-task-execution-role",
"networkMode": "awsvpc",
"revision": 6,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "512",
"memory": "2048",
"registeredAt": "2023-08-22T11:01:22.464Z",
"registeredBy": "arn:aws:iam::861629679241:user/tf-admin",
"tags": []
}
28 changes: 26 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy to ECR
on:

push:
branches: [ main ]
branches: [ main, piyush-dev ]

jobs:

Expand Down Expand Up @@ -33,6 +33,30 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: banodoco-frontend
IMAGE_TAG: latest
id: build-image
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
env:
ECS_TASK_DEFINITION: .aws/task-definition.json
CONTAINER_NAME: backend-banodoco-frontend
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
env:
ECS_SERVICE: backend-banodoco-frontend-service
ECS_CLUSTER: backend-banodoco-frontend-cluster
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
sentry_sdk.init(
environment=SENTRY_ENV,
dsn=SENTRY_DSN,
traces_sample_rate=1.0
traces_sample_rate=0
)

def main():
Expand Down
9 changes: 0 additions & 9 deletions inference_log/log.csv

This file was deleted.

6 changes: 5 additions & 1 deletion shared/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os
from utils.enum import ExtendedEnum
from dotenv import load_dotenv

load_dotenv()


##################### enums #####################
Expand Down Expand Up @@ -62,7 +66,7 @@ class AnimationStyleType(ExtendedEnum):


##################### global constants #####################
SERVER = ServerType.PRODUCTION.value
SERVER = os.getenv('SERVER', ServerType.PRODUCTION.value)

AUTOMATIC_FILE_HOSTING = SERVER != ServerType.DEVELOPMENT.value # automatically upload project files to s3 (images, videos, gifs)
AWS_S3_BUCKET = 'banodoco'
Expand Down
3 changes: 3 additions & 0 deletions ui_components/common_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,8 @@ def generate_individual_clip(timing_uuid, quality):
video = create_individual_clip(timing_uuid)
data_repo.update_specific_timing(timing_uuid, interpolated_clip_id=video.uuid)
output_video = update_speed_of_video_clip(timing.interpolated_clip, True, timing_uuid)

timing = data_repo.get_timing_from_uuid(timing_uuid)
data_repo.update_specific_timing(timing_uuid, timed_clip_id=output_video.uuid)
return output_video

Expand Down Expand Up @@ -2114,6 +2116,7 @@ def generate_individual_clip(timing_uuid, quality):
''')
gen1, gen2 = st.columns([1, 1])

with gen1:
if st.button("Generate Low-Resolution Clip", key=f"generate_preview_video_{idx}"):
generate_individual_clip(timing.uuid, 'preview')
Expand Down
28 changes: 7 additions & 21 deletions ui_components/components/frame_styling_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,24 @@ def frame_styling_page(mainheader2, project_uuid: str):
if st.session_state['frame_styling_view_type'] == "List View":
st.markdown(
f"#### :red[{st.session_state['main_view_type']}] > **:green[{st.session_state['frame_styling_view_type']}]** > :orange[{st.session_state['page']}]")

else:
st.markdown(
f"#### :red[{st.session_state['main_view_type']}] > **:green[{st.session_state['frame_styling_view_type']}]** > :orange[{st.session_state['page']}] > :blue[Frame #{st.session_state['current_frame_index']}]")

project_settings = data_repo.get_project_setting(project_uuid)

if st.session_state['frame_styling_view_type'] == "Individual View":

with st.sidebar:
frame_selector_widget()


if st.session_state['page'] == "Motion":

idx = st.session_state['current_frame_index'] - 1


timing1, timing2, timing3 = st.columns([0.5, 1,1])

with timing1:
update_animation_style_element(st.session_state['current_frame_uuid'], horizontal=False)

with timing2:
num_timing_details = len(timing_details)
current_individual_clip_element(st.session_state['current_frame_uuid'])

with timing3:
Expand All @@ -107,11 +100,8 @@ def frame_styling_page(mainheader2, project_uuid: str):
variants = timing.alternative_images_list

if st.session_state['show_comparison'] == "Other Variants":

mainimages1, mainimages2 = st.columns([1, 1])

aboveimage1, aboveimage2, aboveimage3 = st.columns(
[1, 0.25, 0.75])
aboveimage1, aboveimage2, aboveimage3 = st.columns([1, 0.25, 0.75])

with aboveimage1:
st.info(
Expand All @@ -138,7 +128,6 @@ def frame_styling_page(mainheader2, project_uuid: str):
last_ten_variants)-1, horizontal=True, key=f"Main variant for {st.session_state['current_frame_index']}")

with mainimages1:

project_settings = data_repo.get_project_setting(project_uuid)
st.success("**Main variant**")
if len(timing_details[st.session_state['current_frame_index'] - 1].alternative_images_list):
Expand All @@ -148,19 +137,16 @@ def frame_styling_page(mainheader2, project_uuid: str):
st.error("No variants found for this frame")

with mainimages2:

if len(timing_details[st.session_state['current_frame_index'] - 1].alternative_images_list):
if which_variant - 1 == current_variant:
st.success("**Main variant**")

else:
st.info(f"**Variant #{which_variant}**")

st.image(variants[which_variant- 1].location,
use_column_width=True)

if which_variant- 1 != current_variant:

if st.button(f"Promote Variant #{which_variant}", key=f"Promote Variant #{which_variant} for {st.session_state['current_frame_index']}", help="Promote this variant to the primary image"):
promote_image_variant(
st.session_state['current_frame_uuid'], which_variant - 1)
Expand Down Expand Up @@ -484,11 +470,11 @@ def frame_styling_page(mainheader2, project_uuid: str):
if timing_details[idx].frame_time != frame_time:
update_frame_time(timing_details[idx].uuid, frame_time)

with timing2:
current_individual_clip_element(timing_details[idx].uuid)

with timing3:
current_preview_video_element(timing_details[idx].uuid)
if timing_details[idx].aux_frame_index != len(timing_details) - 1:
with timing2:
current_individual_clip_element(timing_details[idx].uuid)
with timing3:
current_preview_video_element(timing_details[idx].uuid)

st.markdown("***")

Expand Down
9 changes: 9 additions & 0 deletions utils/common_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def wrapped_method(*args, **kwargs):

return Wrapper

def log_time(func):
def wrapper(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
end_time = time.time()
execution_time = end_time - start_time
print(f"{args[1] if args and len(args) >= 2 else kwargs['url']} took {execution_time:.4f} seconds to execute.")
return result
return wrapper

def measure_execution_time(cls):
class WrapperClass:
Expand Down
7 changes: 6 additions & 1 deletion utils/data_repo/api_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import requests
import streamlit as st
from shared.constants import SERVER, InternalFileType, InternalResponse, ServerType
from utils.common_decorators import log_time

from utils.constants import AUTH_TOKEN, AUTH_TOKEN, LOGGED_USER
from utils.local_storage.url_storage import delete_url_param, get_url_param
Expand Down Expand Up @@ -56,7 +57,7 @@ def _setup_urls(self):
self.FILE_URL = '/v1/data/file'
self.FILE_LIST_URL = '/v1/data/file/list'
self.FILE_UUID_LIST_URL = '/v1/data/file/uuid-list'
self.FILE_UPLOAD_URL = 'v1/data/file/upload'
self.FILE_UPLOAD_URL = '/v1/data/file/upload'

# app setting
self.APP_SETTING_URL = '/v1/data/app-setting'
Expand Down Expand Up @@ -86,10 +87,12 @@ def _get_headers(self, content_type="application/json"):

return headers

@log_time
def http_get(self, url, params = None):
res = requests.get(self.base_url + url, params = params, headers=self._get_headers())
return res.json()

@log_time
def http_post(self, url, data = {}, file_content = None):
if file_content:
files = {'file': file_content}
Expand All @@ -99,10 +102,12 @@ def http_post(self, url, data = {}, file_content = None):

return res.json()

@log_time
def http_put(self, url, data = None):
res = requests.put(self.base_url + url, json=data, headers=self._get_headers())
return res.json()

@log_time
def http_delete(self, url, params=None):
res = requests.delete(self.base_url + url, params=params, headers=self._get_headers())
return res.json()
Expand Down

0 comments on commit 4f36a18

Please sign in to comment.