Skip to content

Commit d1c719f

Browse files
Merge pull request #12 from yral-dapp/stage
Stage
2 parents df2f360 + acf60a1 commit d1c719f

32 files changed

+2826
-152
lines changed
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Build and Check linting for staging
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
publish-artifact:
7+
default: false
8+
required: false
9+
type: boolean
10+
workflow_dispatch:
11+
pull_request:
12+
branches:
13+
- main
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository and submodules
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: recursive
27+
28+
- name: Install prereqs
29+
run: |
30+
sudo apt-get install protobuf-compiler musl-tools
31+
32+
- name: Rust Setup
33+
uses: dtolnay/rust-toolchain@master
34+
with:
35+
toolchain: "stable"
36+
targets: "x86_64-unknown-linux-musl"
37+
38+
- name: Build setup
39+
run: |
40+
rustup target add x86_64-unknown-linux-musl
41+
rustup component add rustfmt
42+
rustup component add clippy
43+
# - name: lint check
44+
# run: |
45+
# cargo fmt --check
46+
# cargo clippy --no-deps --all-features --release -- -Dwarnings
47+
- name: Build
48+
run: cargo build --release --target x86_64-unknown-linux-musl --features staging
49+
env:
50+
TARGET_CC: x86_64-linux-musl-gcc
51+
# - name: Run tests
52+
# run: cargo test --verbose
53+
- run: touch .empty
54+
- name: Archive production artifacts
55+
uses: actions/upload-artifact@v4
56+
if: ${{ inputs.publish-artifact }}
57+
with:
58+
name: build-musl
59+
path: |
60+
target/x86_64-unknown-linux-musl/release/ml-feed-rust
61+
.empty

.github/workflows/deploy-staging.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy to Fly on push to main
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- stage
7+
8+
jobs:
9+
build_check_staging:
10+
uses: ./.github/workflows/build-check-staging.yml
11+
with:
12+
publish-artifact: true
13+
14+
deploy:
15+
name: Deploy
16+
needs: build_check_staging
17+
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Download build
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: build-musl
25+
- run: chmod 0777 target/x86_64-unknown-linux-musl/release/ml-feed-rust
26+
- uses: superfly/flyctl-actions/setup-flyctl@master
27+
- name: Set cloudflare token
28+
run: |
29+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" "UPSTASH_URL=$UPSTASH_URL"
30+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" "UPSTASH_TOKEN=$UPSTASH_TOKEN"
31+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" PROJECT="hot-or-not-feed-intelligence"
32+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" "SERVICE_CRED=$SERVICE_CRED"
33+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" GS_VIDEO_BUCKET="yral-videos"
34+
flyctl secrets set --stage --app "yral-ml-feed-server-staging" "GRPC_OFF_CHAIN_JWT_TOKEN=$GRPC_OFF_CHAIN_JWT_TOKEN"
35+
env:
36+
FLY_API_TOKEN: ${{ secrets.YRAL_GPU_COMPUTE_TASKS_GITHUB_ACTION_FLY_IO_DEPLOYMENT_TOKEN }}
37+
UPSTASH_URL: ${{ secrets.UPSTASH_URL }}
38+
UPSTASH_TOKEN: ${{ secrets.UPSTASH_TOKEN }}
39+
SERVICE_CRED: ${{ secrets.SERVICE_CRED }}
40+
GRPC_OFF_CHAIN_JWT_TOKEN: ${{ secrets.ENCODED_JWT_TOKEN_FOR_CALLING_ML_FEED_SERVER_FROM_OFFCHAIN_AGENT_SERVER }}
41+
- name: Deploy a docker container to fly.io
42+
run: flyctl deploy --remote-only --yes -c fly-staging.toml
43+
env:
44+
FLY_API_TOKEN: ${{ secrets.YRAL_GPU_COMPUTE_TASKS_GITHUB_ACTION_FLY_IO_DEPLOYMENT_TOKEN }}

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,9 @@ poetry.lock
165165
*.ipynb
166166

167167
helper_queries.py
168-
init.txt
168+
init.txt
169+
.env
170+
python_src/.env
171+
*.csv
172+
test.py
173+
todo.txt

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ path = "rust_src/main.rs"
4040

4141
[features]
4242
local-bin = []
43+
staging = []

README.md

+88
Original file line numberDiff line numberDiff line change
@@ -1 +1,89 @@
11
# yral-ml-feed-server
2+
3+
```mermaid
4+
flowchart TD
5+
subgraph User["User Journey"]
6+
U[User Requests Feed]
7+
WH{Has Watch History?}
8+
UWH[New User]
9+
UWH2[User with History]
10+
end
11+
12+
subgraph Input["Input Processing"]
13+
SP[Sample Successful Plays]
14+
SWS[Sample with Weighted Scoring]
15+
CS[Calculate Engagement Score]
16+
CE[Calculate Exploitation vs Exploration Ratio]
17+
end
18+
19+
subgraph RecommendationPaths["Recommendation Paths (Parallel Execution)"]
20+
subgraph Exploitation["Exploitation (0-90% for engaged users)"]
21+
SAR[Score-Aware Recommendation]
22+
VS[Vector Search on Similar Content]
23+
NFILTER1[NSFW/Clean Content Filtering]
24+
RAR[Recency-Aware Recommendation]
25+
RVS[Vector Search on Recent Similar Content]
26+
NFILTER2[NSFW/Clean Content Filtering]
27+
end
28+
29+
subgraph Exploration["Exploration (10-100% for new users)"]
30+
PV[Popular Videos]
31+
GPV[Global Popularity Ranking]
32+
NFILTER3[NSFW/Clean Content Filtering]
33+
RR[Random Recent Videos]
34+
NFILTER4[NSFW/Clean Content Filtering]
35+
end
36+
end
37+
38+
subgraph Weighting["Weighting & Combination"]
39+
SW[Score Weighting]
40+
CF[Combine Feeds]
41+
DD[De-duplicate Items]
42+
WS[Weighted Sampling]
43+
end
44+
45+
subgraph FinalFeed["Final Feed Generation"]
46+
FF[Format Feed]
47+
LOG[Log Metrics]
48+
RES[Return Results]
49+
end
50+
51+
U --> WH
52+
WH -- No --> UWH
53+
WH -- Yes --> UWH2
54+
UWH --> CE
55+
UWH2 --> SP
56+
SP --> SWS
57+
SWS --> CS
58+
CS --> CE
59+
60+
CE --> RecommendationPaths
61+
62+
CE --> SAR
63+
SAR --> VS
64+
VS --> NFILTER1
65+
66+
CE --> RAR
67+
RAR --> RVS
68+
RVS --> NFILTER2
69+
70+
CE --> PV
71+
PV --> GPV
72+
GPV --> NFILTER3
73+
74+
CE --> RR
75+
RR --> NFILTER4
76+
77+
NFILTER1 --> SW
78+
NFILTER2 --> SW
79+
NFILTER3 --> SW
80+
NFILTER4 --> SW
81+
82+
SW --> CF
83+
CF --> DD
84+
DD --> WS
85+
86+
WS --> FF
87+
FF --> LOG
88+
LOG --> RES
89+
```

contracts

fly-staging.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
app = 'yral-ml-feed-server-staging'
2+
primary_region = 'sin'
3+
kill_signal = 'SIGINT'
4+
kill_timeout = '5s'
5+
6+
[build]
7+
[build.args]
8+
NONROOT_USER = "pythonuser" # Access this value in the Dockerfile using `ARG NONROOT_USER`
9+
10+
[env]
11+
PORT = '8080'
12+
13+
[processes]
14+
rust_proc = "./ml-feed-rust"
15+
python_proc = "/bin/bash -c ./entrypoint.sh $PYTHON_USER"
16+
17+
[[services]]
18+
internal_port = 50051
19+
protocol = "tcp"
20+
processes = ["rust_proc"]
21+
22+
[[services.ports]]
23+
handlers = ["tls"]
24+
tls_options = { "alpn" = ["h2"], "versions" = ["TLSv1.2", "TLSv1.3"] }
25+
port = 443
26+
27+
[services.concurrency]
28+
hard_limit = 1000
29+
soft_limit = 500
30+
31+
[[vm]]
32+
memory = '8gb'
33+
cpu_kind = 'shared'
34+
cpus = 8
35+
36+
[mounts]
37+
source = "data"
38+
destination = "/home/pythonuser"
39+
initial_size = "50gb"

0 commit comments

Comments
 (0)