Skip to content

Move long running computation from the dashboard_app to the data_handler #664

@Valera56pub

Description

@Valera56pub

Guideline

  1. Carefully read the issue description before applying to ensure you have all the necessary information to start working on it.
  2. Write a brief description of how you will approach the task (without using ChatGPT).
  3. Add your Telegram handler in your application (e.g., in OnlyDust or similar)
  4. Write ETA in your application

What should I do if I have a problem

  1. Try to google it before asking. Googling is taking major part of dev work
  2. If you couldn't find answer your question with Google, text your question to dev group with your question.
  3. Do not send DM to maintainer, it would be better and faster to ask other contributors in chat

How to prepare PR

  1. Check if your code smell good
  2. Add close # to link your issue with your PR
  3. Do not commit changes which is not related to your task
  4. Check after you created PR, if you committed everything.

Task description

  1. Search for def compute_liquidable_debt_at_price
  2. Also explore apps/dashboard_app/helpers/tools.py
 data["liquidable_debt"] = data["collateral_token_price"].apply(
        lambda x: state.compute_liquidable_debt_at_price(
            prices=prices,
            collateral_token_underlying_address=collateral_token_underlying_address,
            collateral_token_price=x,
            debt_token_underlying_address=debt_token_underlying_address,
        )
    )
  1. This function runs for a long time (about 20s) and blocks the streamlit app. The task is to move this computation to the data_handler
  2. The data_handler must continuously compute the results and store them in Redis. The dashboard_app (streamlit) must only read the results from Redis and display them.
  3. To understand the logic, explore this apps/shared/redis_client.py and usages.
  4. Since the dashboard_app and the data handler_app may run separately, run the data_handler then create a snapshot of the computation results, and fill them in the test environment in the dashboard_app (for example, search for def streamlit_dev_fill_with_test_data():)

PS:
In apps/dashboard_app/dashboard.py change:
REFRESH_TIME = ONE_MINUTE_IN_MILISECONDS * int(CRONTAB_TIME)
to
REFRESH_TIME = ONE_MINUTE_IN_MILISECONDS * int(CRONTAB_TIME)*10
To avoid frequent auto-refresh

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions