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

Implement video upload workflow in Celery #3747

Merged
merged 35 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ba6b147
Move video upload workflow to celery
marcoacierno Mar 3, 2024
2c175e9
Fix tags, tests
marcoacierno Mar 3, 2024
97cbb4f
remove celery-heimdall
marcoacierno Mar 4, 2024
c699cd4
tests
marcoacierno Mar 8, 2024
c3d29d4
improvements
marcoacierno Mar 9, 2024
71f2fe7
more tests
marcoacierno Mar 9, 2024
eda54fd
changes
marcoacierno Mar 9, 2024
4982c30
check container build in ci
marcoacierno Mar 9, 2024
3a02991
docekrx
marcoacierno Mar 9, 2024
eea66e8
test
marcoacierno Mar 9, 2024
bcec78f
fix job
marcoacierno Mar 9, 2024
ca923c0
remove debug
marcoacierno Mar 9, 2024
2a571e5
fix ref
marcoacierno Mar 9, 2024
7b68c36
Stop processing when the quota is finished
marcoacierno Mar 9, 2024
072c9b6
more tests
marcoacierno Mar 9, 2024
b771015
generator function
marcoacierno Mar 9, 2024
8e74153
remove temporal
marcoacierno Mar 9, 2024
6c968f6
more tests
marcoacierno Mar 9, 2024
31b18f7
assert build call
marcoacierno Mar 9, 2024
17c6982
remove never working action
marcoacierno Mar 9, 2024
4daaec3
Revert "remove never working action"
marcoacierno Mar 9, 2024
2384e00
remove plan
marcoacierno Mar 9, 2024
bd9a0fb
remove plan
marcoacierno Mar 9, 2024
2e9c94c
reduce sleep time
marcoacierno Mar 9, 2024
2c547bb
dummy lock
marcoacierno Mar 9, 2024
1ae0373
dummy lock
marcoacierno Mar 9, 2024
84e12dd
changes
marcoacierno Mar 9, 2024
0c2e6cd
changs
marcoacierno Mar 9, 2024
1fcf9d0
changes
marcoacierno Mar 9, 2024
7c05404
fix
marcoacierno Mar 9, 2024
c110ff7
redis
marcoacierno Mar 9, 2024
1ba8f25
ee
marcoacierno Mar 9, 2024
cf02107
parallel
marcoacierno Mar 9, 2024
7ffc106
worker
marcoacierno Mar 9, 2024
c2577c6
lock improvement
marcoacierno Mar 9, 2024
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
**/.ruff_cache/**
**/.pnpm-store/**
**/__pycache__/**
**/__pypackages__/**
.pdm-python
**/.pytest_cache/**
Dockerfile
**/_dist/**
**/backend/media
*.sqlite3
30 changes: 30 additions & 0 deletions .github/workflows/backend-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,33 @@ jobs:
STRIPE_SECRET_API_KEY: ""
STRIPE_SUBSCRIPTION_PRICE_ID: ""
STRIPE_WEBHOOK_SIGNATURE_SECRET: ""
CELERY_BROKER_URL: ""
CELERY_RESULT_BACKEND: ""

check-building-container:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend

steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.service.name }}
- name: Build test
uses: docker/[email protected]
with:
context: ./backend
file: ./backend/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
provenance: false
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64
7 changes: 5 additions & 2 deletions .github/workflows/backend-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
redis:
image: redis:7.2.3
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -62,8 +64,9 @@ jobs:
exit $STATUS
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/postgres
CELERY_BROKER_URL: redis://redis:6379/0
CELERY_RESULT_BACKEND: redis://redis:6379/1
CACHE_URL: redis://localhost:6379/0
CELERY_BROKER_URL: redis://redis:6379/1
CELERY_RESULT_BACKEND: redis://redis:6379/2
STRIPE_SECRET_API_KEY: fake-key
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
MEDIA_FILES_STORAGE_BACKEND: django.core.files.storage.FileSystemStorage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ jobs:
runs-on: ubuntu-latest
needs: [terraform]
steps:
- name: Sleep for 20 seconds
run: sleep 20s
- name: Sleep for 10 seconds
run: sleep 10s
shell: bash

# Migrate the database
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/global-terraform-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,3 @@ jobs:
run: terraform fmt -check
env:
TF_IN_AUTOMATION: 1

plan:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./infrastructure/global
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.2.4
- name: Terraform Init
run: terraform init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_IN_AUTOMATION: 1
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
run: terraform plan -no-color &> /dev/null
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
TF_IN_AUTOMATION: 1
- name: Find Plan comment
uses: peter-evans/find-comment@v1
id: find_comment
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: pythonitaliabot
body-includes: "# Global Terraform"
- name: Create or Update comment
uses: peter-evans/create-or-update-comment@v1
if: steps.find_comment.outputs.comment-id != ''
with:
token: ${{ secrets.BOT_TOKEN }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
# Global Terraform

## Terraform Validation 🤖
${{ steps.validate.outputs.stdout }}

## Terraform Plan 📖
${{ steps.plan.outcome }}
55 changes: 0 additions & 55 deletions .github/workflows/terraform-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,58 +38,3 @@ jobs:
run: terraform fmt -check
env:
TF_IN_AUTOMATION: 1

plan:
name: Plan [AWS]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./infrastructure/applications
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.2.4
- name: Terraform Init
run: terraform init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_IN_AUTOMATION: 1
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
run: terraform plan -no-color &> /dev/null
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-central-1
TF_IN_AUTOMATION: 1
- name: Find Plan comment
uses: peter-evans/find-comment@v1
id: find_comment
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: pythonitaliabot
body-includes: "# Terraform"
- name: Create or Update comment
uses: peter-evans/create-or-update-comment@v1
if: steps.find_comment.outputs.comment-id != ''
with:
token: ${{ secrets.BOT_TOKEN }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
# Terraform

## Terraform Validation 🤖
${{ steps.validate.outputs.stdout }}

## Terraform Plan 📖
${{ steps.plan.outcome }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,4 @@ badge-service/badges.zip
*.generated.ts
backend/custom_admin/src/types.ts
backend/schema.graphql
backend/__pypackages__/
2 changes: 1 addition & 1 deletion Dockerfile.python.local
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ARG FUNCTION_DIR
RUN mkdir -p ${FUNCTION_DIR}
WORKDIR ${FUNCTION_DIR}

RUN pip install pdm==2.10.4
RUN pip install pdm==2.12.4

COPY pyproject.toml pdm.lock ${FUNCTION_DIR}

Expand Down
16 changes: 16 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ cov.xml
**/__pycache__/**
**/node_modules/**
*.sqlite3
**/node_modules
**/.env
**/.npmrc
**/.pdm-build
**/.venv/**
**/.ruff_cache/**
**/.pnpm-store/**
**/__pycache__/**
.pdm-python
**/.pytest_cache/**
Dockerfile
**/_dist/**
**/backend/media
*.sqlite3
db.sqlite3
**/.virtualenv
42 changes: 39 additions & 3 deletions backend/api/conferences/tests/test_query_talk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from conferences.tests.factories import ConferenceFactory
from conferences.tests.factories import ConferenceFactory, KeynoteFactory
from i18n.strings import LazyI18nString
from languages.models import Language
import pytest
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_exposes_abstract_elevator_pitch_in_correct_language(
}


def test_empty_abstract_elevator_pitch_with_no_submission(graphql_client, user):
def test_abstract_fallbacks_to_description(graphql_client, user):
graphql_client.force_login(user)

schedule_item = ScheduleItemFactory(
Expand All @@ -90,6 +90,7 @@ def test_empty_abstract_elevator_pitch_with_no_submission(graphql_client, user):
type=ScheduleItem.TYPES.talk,
conference=ConferenceFactory(),
attendees_total_capacity=None,
description="Description",
)

response = graphql_client.query(
Expand All @@ -105,7 +106,42 @@ def test_empty_abstract_elevator_pitch_with_no_submission(graphql_client, user):
)

assert response["data"]["conference"]["talk"] == {
"abstract": "",
"abstract": "Description",
"elevatorPitch": "",
}


def test_abstract_shows_keynote_description(graphql_client, user):
graphql_client.force_login(user)
conference = ConferenceFactory()

schedule_item = ScheduleItemFactory(
status=ScheduleItem.STATUS.confirmed,
submission=None,
keynote=KeynoteFactory(
conference=conference,
description=LazyI18nString({"en": "Description Keynote", "it": ""}),
),
type=ScheduleItem.TYPES.keynote,
conference=conference,
attendees_total_capacity=None,
description="Description",
)

response = graphql_client.query(
"""query($slug: String!, $code: String!) {
conference(code: $code) {
talk(slug: $slug) {
abstract
elevatorPitch
}
}
}""",
variables={"slug": schedule_item.slug, "code": schedule_item.conference.code},
)

assert response["data"]["conference"]["talk"] == {
"abstract": "Description Keynote",
"elevatorPitch": "",
}

Expand Down
15 changes: 2 additions & 13 deletions backend/api/schedule/types/schedule_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,8 @@ class ScheduleItem:
] | None
youtube_video_id: str | None

@strawberry.field
def abstract(self) -> str:
if self.submission_id:
return self.submission.abstract.localize(self.language.code)

return ""

@strawberry.field
def elevator_pitch(self) -> str:
if self.submission_id:
return self.submission.elevator_pitch.localize(self.language.code)

return ""
abstract: str
elevator_pitch: str

@strawberry.field
def has_limited_capacity(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion backend/conferences/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class ConferenceAdmin(OrderedInlineModelAdminMixin, admin.ModelAdmin):
)
},
),
("YouTube", {"fields": ("youtube_video_bottom_text",)}),
("YouTube", {"fields": ("video_title_template", "video_description_template")}),
)
inlines = [DeadlineInline, DurationInline, SponsorLevelInline, IncludedEventInline]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2024-03-03 11:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('conferences', '0041_remove_conference_visa_application_form_link'),
]

operations = [
migrations.AddField(
model_name='conference',
name='video_description_template',
field=models.TextField(blank=True, default=''),
),
migrations.AddField(
model_name='conference',
name='video_title_template',
field=models.TextField(blank=True, default=''),
),
]
9 changes: 9 additions & 0 deletions backend/conferences/models/conference.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ class Conference(GeoLocalizedModel, TimeFramedModel, TimeStampedModel):
default=None,
)

video_title_template = models.TextField(
default="",
blank=True,
)
video_description_template = models.TextField(
default="",
blank=True,
)

youtube_video_bottom_text = models.TextField(
default="",
blank=True,
Expand Down
10 changes: 4 additions & 6 deletions backend/google_api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def build_google_flow(self, request, obj, *, state=None):
reverse("admin:google-api-oauth-callback")
)

# flow.redirect_uri = flow.redirect_uri + f"?obj_id={obj.id}"

return flow

def auth_callback(self, request):
Expand Down Expand Up @@ -115,15 +113,15 @@ def google_oauth_obj_id_for_state(self, state):
return f"google_api:data:{state}"

def get_urls(self):
return super().get_urls() + [
return [
path(
"<int:object_id>/auth",
"<int:object_id>/auth/",
self.admin_site.admin_view(self.auth),
name="google-api-oauth-auth",
),
path(
"auth-callback",
"auth-callback/",
self.admin_site.admin_view(self.auth_callback),
name="google-api-oauth-callback",
),
]
] + super().get_urls()
2 changes: 2 additions & 0 deletions backend/google_api/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class NoGoogleCloudQuotaLeftError(Exception):
pass
Loading
Loading