Skip to content

Commit 4810360

Browse files
Lendemormasenf
andauthored
deploy pipeline (#47)
* test pipeline * update * update * test matrix * fix output * fix output again * add deploy.sh * fix path of deploy.sh * allow exec of deploy.sh * update pipeline * add debug print for auth token * fix export deprecation check * fix * fix deprec check * fi * f * _ * fix output * remove debug print * test stuff * test array secret * works better if I use the correct name * do it case by case * fix syntax * remove fail-fast and fix typo * add ;; * add environment config * actually deploy let's go * fix name of app for api_admin_panel * use bigger vm for nba example * typo * fix customer_data_app * change trigger condition of pipeline * test deploy@v0 for templates * install dep is handled by the action * rewrite workflow logic * fix stuff maybe * wrong path * try without fromJSON * readd fromJSON * debug output * debug more output * ensure valid json format * define output in the correct place * try to run with dry mode * use dry_run * remove debug output and use reusable job * fix indent * enable submodules for deploy * update checkout version * run with deploy-action@v1 * deploy on publish only * fix warning in ai_image_gen * update reflex-chat submodule * use OPENAI_API_KEY env var * use OPENAI_API_KEY env var * Set OPENAI_API_KEY for reflex-chat skip deploy for reflex-llamaindex-template * deploy: deploy from lendemor/deploy_pipeline branch * have OPENAI_API_KEY in the environment for reflex-chat build * auto-migrate local db for apps that use database * enable temporary db for apps that require it * customer_data_app has non-standard structure * sorry for the insanity * really scratching my head here why are the lines from `temporary_db.py` not getting picked up * skip checking out code when doing deploy * temporary_db: add some whitespace for breathing room * remove debugging stuff * remove debugging route * Fix broken sales app --------- Co-authored-by: Masen Furer <m_github@0x26.net>
1 parent 77748cc commit 4810360

File tree

36 files changed

+172
-171
lines changed

36 files changed

+172
-171
lines changed

.deploy/temporary_db.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
# reflex-dev/templates:.deploy/temporary_db.py to create default reflex.db when deployed
4+
import reflex as rx
5+
rx.utils.prerequisites.check_db_initialized() or rx.Model.alembic_init()
6+
rx.Model.migrate(autogenerate=True)

.github/workflows/check_export.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,14 @@ on:
1313
description: 'Reflex dep (raw pip spec)'
1414

1515
jobs:
16-
list-examples:
17-
runs-on: ubuntu-latest
18-
outputs:
19-
examples: ${{ steps.generate-matrix.outputs.examples }}
20-
steps:
21-
- uses: actions/checkout@v4
22-
- name: Generate Matrix
23-
id: generate-matrix
24-
run: |
25-
EXAMPLES="$(find . -not -name '.*' -maxdepth 1 -type d | cut -f2 -d/ | sort | grep -vw chakra_apps | jq -R | jq -s -c)"
26-
echo $EXAMPLES
27-
echo "examples=$EXAMPLES" >> $GITHUB_OUTPUT
28-
16+
list-templates:
17+
uses: ./.github/workflows/list-templates.yml
18+
2919
check-export:
30-
needs: [list-examples]
20+
needs: [list-templates]
3121
strategy:
3222
matrix:
33-
example: ${{ fromJSON(needs.list-examples.outputs.examples) }}
23+
folder: ${{ fromJSON(needs.list-templates.outputs.templates) }}
3424
fail-fast: false
3525
runs-on: ubuntu-latest
3626
steps:
@@ -42,7 +32,7 @@ jobs:
4232
python-version: 3.9
4333
- id: export-check
4434
run: |
45-
f=${{ matrix.example }}
35+
f=${{ matrix.folder }}
4636
if [[ ! -d $f ]]; then
4737
echo "$f is not a directory!"
4838
exit 1
@@ -80,7 +70,7 @@ jobs:
8070
8171
- name: Check for DeprecationWarning in logs
8272
run: |
83-
cd ${{ matrix.example }}
73+
cd ${{ matrix.folder }}
8474
dep_lines=$(grep -i "DeprecationWarning:" export_logs.txt || true)
8575
if [ -n "$dep_lines" ]; then
8676
echo "Found Deprecation warning:"

.github/workflows/deploy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: deploy
2+
3+
# only redeploy when we push a new release.
4+
on:
5+
release:
6+
types: [published]
7+
push:
8+
branches:
9+
- lendemor/deploy_pipeline
10+
11+
jobs:
12+
list-templates:
13+
uses: ./.github/workflows/list-templates.yml
14+
15+
deploy:
16+
needs: list-templates
17+
runs-on: ubuntu-latest
18+
environment: Cloud Deploy
19+
strategy:
20+
matrix:
21+
folder: ${{ fromJSON(needs.list-templates.outputs.templates) }}
22+
exclude:
23+
# No deploy due to missing service dependencies.
24+
- folder: reflex-llamaindex-template
25+
fail-fast: false
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
- name: Set environment variables
31+
id: set-env
32+
run: |
33+
case ${{ matrix.folder }} in
34+
ai_image_gen)
35+
echo "EXTRA_ARGS=--env REPLICATE_API_TOKEN=${{ secrets.REPLICATE_API_TOKEN }}" >> $GITHUB_ENV
36+
;;
37+
customer_data_app)
38+
cat .deploy/temporary_db.py >> ${{ matrix.folder }}/customer_data/customer_data.py
39+
;;
40+
sales)
41+
echo "EXTRA_ARGS=--env OPENAI_API_KEY=${{ secrets.OPEN_AI_KEY }}" >> $GITHUB_ENV
42+
cat .deploy/temporary_db.py >> ${{ matrix.folder }}/${{ matrix.folder }}/${{ matrix.folder }}.py
43+
;;
44+
reflex-chat)
45+
echo "EXTRA_ARGS=--env OPENAI_API_KEY=${{ secrets.OPEN_AI_KEY }}" >> $GITHUB_ENV
46+
echo "OPENAI_API_KEY=${{ secrets.OPEN_AI_KEY }}" >> $GITHUB_ENV
47+
;;
48+
nba)
49+
echo "EXTRA_ARGS=--vmtype ${{ vars.NBA_VM_TYPE }}" >> $GITHUB_ENV
50+
;;
51+
*)
52+
echo "EXTRA_ARGS=" >> $GITHUB_ENV
53+
;;
54+
esac
55+
- name: Deploy to ReflexCloud
56+
uses: reflex-dev/reflex-deploy-action@masenf/skip-checkout
57+
with:
58+
auth_token: ${{ secrets.REFLEX_AUTH_TOKEN }}
59+
project_id: ${{ secrets.REFLEX_PROJECT_ID }}
60+
app_directory: ${{ matrix.folder }}
61+
extra_args: ${{ env.EXTRA_ARGS }}
62+
dry_run: ${{ vars.DRY_RUN }}
63+
skip_checkout: "true"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
workflow_call:
3+
outputs:
4+
templates:
5+
description: 'List of templates'
6+
value: ${{ jobs.list-templates.outputs.templates }}
7+
jobs:
8+
list-templates:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
templates: ${{ steps.generate-matrix.outputs.templates }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: List all templates
15+
id: generate-matrix
16+
run: |
17+
TEMPLATES="$(find . -not -name '.*' -maxdepth 1 -type d | cut -f2 -d/ | sort | grep -vw chakra_apps | jq -R | jq -s -c)"
18+
TEMPLATES=$(echo "$TEMPLATES" | jq -c '.') # Ensure valid JSON format
19+
echo "templates=$TEMPLATES" >> $GITHUB_OUTPUT
20+
- name: Debug output
21+
run: |
22+
echo "Templates: ${{ steps.generate-matrix.outputs.templates }}"

ai_image_gen/ai_image_gen/backend/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ def set_guidance_scale(self, value: list):
7878
def randomize_prompt(self):
7979
self.prompt = random.choice(prompt_list)
8080

81-
@rx.var
81+
@rx.var(cache=False)
8282
def selected_style_prompt(self) -> str:
8383
if self.selected_style == "":
8484
return ""
8585
return self.styles_preset[self.selected_style]["prompt"]
8686

87-
@rx.var
87+
@rx.var(cache=False)
8888
def dimensions_str(self) -> str:
8989
width, height = self.selected_dimensions
9090
return f"{width} × {height}"
File renamed without changes.

api_admin_panel/app/app.py renamed to api_admin_panel/api_admin_panel/api_admin_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import reflex as rx
2-
from app.pages import *
2+
from api_admin_panel.pages import *
33

44

55
class State(rx.State):
File renamed without changes.

api_admin_panel/app/components/drawer.py renamed to api_admin_panel/api_admin_panel/components/drawer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import reflex as rx
22

3-
from app.states.queries import QueryAPI
3+
from api_admin_panel.states.queries import QueryAPI
44

55

66
def render_data(data: tuple[str, str]):

api_admin_panel/app/components/navbar.py renamed to api_admin_panel/api_admin_panel/components/navbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import reflex as rx
22

3-
from app.states.base import BaseState
4-
from app.styles import text
3+
from api_admin_panel.states.base import BaseState
4+
from api_admin_panel.styles import text
55

66
navbar: dict[str, str] = {
77
"width": "100%",

0 commit comments

Comments
 (0)