Skip to content

Commit

Permalink
Merge branch 'CarmineOptions:master' into interest-rate-bearing
Browse files Browse the repository at this point in the history
  • Loading branch information
MooreTheAnalyst authored Nov 27, 2024
2 parents 4b931cd + eb4a4ad commit 70e7cbf
Show file tree
Hide file tree
Showing 14 changed files with 1,145 additions and 137 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/wep_app_ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: Web App CI Workflow

on:
push:
branches:
- master
pull_request:
branches:
- master
on: [push]

jobs:
run_tests:
Expand All @@ -32,26 +26,40 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies for Web_App
working-directory: ./apps/web_app
run: |
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
poetry lock --no-update
poetry install
- name: Run Tests for Web_App
- name: Prepare Environment File
working-directory: ./apps/web_app
run: |
cp .env.test .env
poetry run pytest --junitxml=results.xml
cp .env.dev .env
sed -i 's/DB_HOST=db/DB_HOST=127.0.0.1/' .env
sed -i 's/DB_PORT=5432/DB_PORT=5433/' .env
- name: Wait for Database to be Ready
run: |
for i in {1..30}; do
pg_isready -h 127.0.0.1 -p 5433 -U postgres && break || sleep 2;
done
- name: Create Test Database
run: |
PGPASSWORD=postgres psql -h 127.0.0.1 -p 5433 -U postgres -c "CREATE DATABASE web_app;"
- name: Run Tests for Web_App
working-directory: ./apps/web_app
run: poetry run pytest --junitxml=results.xml

- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
Expand Down
19 changes: 11 additions & 8 deletions apps/data_handler/celery_app/celery_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# run_loan_states_computation_for_hashtack_v0,;
# run_loan_states_computation_for_hashtack_v1,; run_loan_states_computation_for_nostra_alpha,;
# run_loan_states_computation_for_nostra_mainnet,; run_loan_states_computation_for_zklend,;
# run_liquidable_debt_computation_for_nostra_alpha,;
# run_liquidable_debt_computation_for_nostra_alpha,;
# run_liquidable_debt_computation_for_nostra_mainnet,;
# run_liquidable_debt_computation_for_hashstack_v0,;
# run_liquidable_debt_computation_for_hashstack_v0,;
# run_liquidable_debt_computation_for_hashstack_v1,; uniswap_v2_order_book,

# from data_handler.celery_app.tasks import (
Expand Down Expand Up @@ -68,20 +68,23 @@
"task": "ekubo_order_book",
"schedule": ORDER_BOOK_TIME_INTERVAL,
},
f"process_zklend_events_{CRONTAB_TIME}_mins": {
"task": "process_zklend_events",
"schedule": crontab(minute=f"*/{CRONTAB_TIME}"),
f"process_zklend_events_{CRONTAB_TIME}_mins": {
"task": "process_zklend_events",
"schedule": crontab(minute=f"*/{CRONTAB_TIME}"),
},
f"process_nostra_events_{CRONTAB_TIME}_mins": {
"task": "process_nostra_events",
"schedule": crontab(minute=f"*/{CRONTAB_TIME}"),
},
}

from data_handler.celery_app.order_books_tasks import ekubo_order_book
from data_handler.celery_app.tasks import (
run_liquidable_debt_computation_for_zklend, )
from data_handler.celery_app.tasks import run_liquidable_debt_computation_for_zklend

# run_loan_states_computation_for_hashtack_v0,; run_loan_states_computation_for_hashtack_v1,;
# run_loan_states_computation_for_nostra_alpha,; run_loan_states_computation_for_nostra_mainnet,;
# run_loan_states_computation_for_zklend,; run_liquidable_debt_computation_for_nostra_alpha,;
# run_liquidable_debt_computation_for_nostra_mainnet,;
# run_liquidable_debt_computation_for_nostra_mainnet,;
# run_liquidable_debt_computation_for_hashstack_v0,;
# run_liquidable_debt_computation_for_hashstack_v1,; uniswap_v2_order_book,

Expand Down
58 changes: 53 additions & 5 deletions apps/data_handler/celery_app/event_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from datetime import datetime

from data_handler.celery_app.celery_conf import app
from data_handler.handlers.events.nostra.transform_events import NostraTransformer
from data_handler.handlers.events.zklend.transform_events import ZklendTransformer


logger = logging.getLogger(__name__)


@app.task(name="process_zklend_events")
def process_zklend_events():
"""
Expand All @@ -30,21 +31,68 @@ def process_zklend_events():
"Successfully processed ZkLend events in %.2fs. Blocks: %d to %d",
execution_time,
transformer.last_block - transformer.PAGINATION_SIZE,
transformer.last_block
transformer.last_block,
)
except (ValueError, TypeError, RuntimeError) as exc: # Catching more specific exceptions
except (
ValueError,
TypeError,
RuntimeError,
) as exc: # Catching more specific exceptions
execution_time = (datetime.utcnow() - start_time).total_seconds()
logger.error(
"Error processing ZkLend events after %.2fs: %s",
execution_time,
exc,
exc_info=True
exc_info=True,
)
except Exception as exc: # Still keeping a general exception catch as a fallback
execution_time = (datetime.utcnow() - start_time).total_seconds()
logger.error(
"Unexpected error processing ZkLend events after %.2fs: %s",
execution_time,
exc,
exc_info=True
exc_info=True,
)


@app.task(name="process_nostra_events")
def process_nostra_events():
"""
Process and store Nostra protocol events.
Fetches events from the blockchain, transforms them into the required format,
and saves them to the database.
"""
start_time = datetime.utcnow()
logger.info("Starting Nostra event processing")
try:
# Initialize and run transformer
transformer = NostraTransformer()
transformer.run()
# Log success metrics
execution_time = (datetime.utcnow() - start_time).total_seconds()
logger.info(
"Successfully processed Nostra events in %.2fs. Blocks: %d to %d",
execution_time,
transformer.last_block - transformer.PAGINATION_SIZE,
transformer.last_block,
)
except (
ValueError,
TypeError,
RuntimeError,
) as exc: # Catching more specific exceptions
execution_time = (datetime.utcnow() - start_time).total_seconds()
logger.error(
"Error processing Nostra events after %.2fs: %s",
execution_time,
exc,
exc_info=True,
)
except Exception as exc: # Still keeping a general exception catch as a fallback
execution_time = (datetime.utcnow() - start_time).total_seconds()
logger.error(
"Unexpected error processing Nostra events after %.2fs: %s",
execution_time,
exc,
exc_info=True,
)
Loading

0 comments on commit 70e7cbf

Please sign in to comment.