### Run Taskiq Admin Panel Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_broker Command to run the Taskiq admin panel application. This command executes the Python script with the 'admin_panel' argument, starting the dashboard interface. ```bash uv run python -m docs.examples.example_with_broker admin_panel ``` -------------------------------- ### Initialize Development Environment - Make Source: https://danfimov.github.io/taskiq-dashboard/contributing Initializes the local development environment by creating a virtual environment, activating it, installing dependencies, and setting up pre-commit hooks. This command simplifies the setup process. ```bash make init ``` -------------------------------- ### Configure Taskiq Dashboard with PostgreSQL Broker and Run Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_broker This Python code configures Taskiq Dashboard with an AsyncpgBroker for PostgreSQL, defines a sample task, and sets up functions to run the admin panel or send tasks to the broker. It requires the `taskiq`, `taskiq-pg`, and `taskiq-dashboard` libraries. The code takes a command-line argument ('admin_panel' or 'send_task') to determine its execution mode. Outputs include starting messages and task execution status. ```python import asyncio import random import sys import typing as tp from taskiq_pg.asyncpg import AsyncpgBroker, AsyncpgResultBackend from taskiq_dashboard import DashboardMiddleware, TaskiqDashboard ds n = 'postgres://taskiq-dashboard:look_in_vault@localhost:5432/taskiq-dashboard' broker = ( AsyncpgBroker(dsn) .with_result_backend(AsyncpgResultBackend(dsn)) .with_middlewares( DashboardMiddleware( url='http://0.0.0.0:8000', # the url to your taskiq-admin instance api_token='supersecret', # any secret enough string broker_name='my_worker', ) ) ) @broker.task( task_name='task_in_example_with_broker', ) async def best_task_ever(*args, **kwargs) -> dict[str, tp.Any]: """Solve all problems in the world.""" await asyncio.sleep(15) print('All problems are solved!') error_probability = 0.2 if random.random() < error_probability: raise RuntimeError('An unexpected error occurred while solving problems.') return { 'status': 'success', 'random_number': random.randint(1, 42), 'args': args, 'kwargs': kwargs, } def run_admin_panel() -> None: app = TaskiqDashboard( api_token='supersecret', broker=broker, host='0.0.0.0', port=8000, ) app.run() async def send_task() -> None: """Send a task to the broker.""" await broker.startup() await best_task_ever.kiq('some arg', key='value') await broker.shutdown() if __name__ == '__main__': if sys.argv[1] == 'admin_panel': print('Starting admin panel...') run_admin_panel() elif sys.argv[1] == 'send_task': print('Sending task to the broker...') asyncio.run(send_task()) ``` -------------------------------- ### Start Dashboard Application - Make Source: https://danfimov.github.io/taskiq-dashboard/contributing Starts the Taskiq Dashboard application locally. This command is used after all other setup steps are completed to run the application for testing and development. ```bash make run ``` -------------------------------- ### Run Taskiq Worker Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_broker Command to run the Taskiq worker process. It specifies the broker instance to use and the number of worker processes. Ensure the path to the broker instance is correct. ```bash uv run taskiq worker docs.examples.example_with_broker:broker --workers 1 ``` -------------------------------- ### Send Task to Broker Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_broker Command to send a task to the Taskiq broker. This executes the Python script with the 'send_task' argument, initiating a task that will be processed by the worker. ```bash uv run python -m docs.examples.example_with_broker send_task ``` -------------------------------- ### Install Taskiq Dashboard with Pip, Poetry, or UV Source: https://danfimov.github.io/taskiq-dashboard/index Installs the taskiq-dashboard package using different Python package managers. Ensure you have the respective package manager installed and configured. ```shell pip install taskiq-dashboard ``` ```shell poetry add taskiq-dashboard ``` ```shell uv pip install taskiq-dashboard ``` -------------------------------- ### Run PostgreSQL with Docker - Make Source: https://danfimov.github.io/taskiq-dashboard/contributing Starts a local PostgreSQL instance using Docker. This is necessary for the dashboard application to function correctly during local development. ```bash make run_infra ``` -------------------------------- ### Taskiq Dashboard with Scheduler Setup (Python) Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_scheduler This Python script demonstrates how to set up Taskiq Dashboard with a TaskiqScheduler. It configures the AsyncpgBroker, AsyncpgResultBackend, DashboardMiddleware, and TaskiqScheduler. A sample task 'solve_all_problems' is defined with cron and time-based schedules. The script includes a function to run the admin panel. ```python import asyncio import datetime as dt import random import typing as tp from taskiq import TaskiqScheduler from taskiq_pg.asyncpg import AsyncpgBroker, AsyncpgResultBackend, AsyncpgScheduleSource from taskiq_dashboard import DashboardMiddleware, TaskiqDashboard dsn = 'postgres://taskiq-dashboard:look_in_vault@localhost:5432/taskiq-dashboard' broker = ( AsyncpgBroker(dsn) .with_result_backend(AsyncpgResultBackend(dsn)) .with_middlewares( DashboardMiddleware( url='http://0.0.0.0:8000', # the url to your taskiq-admin instance api_token='supersecret', # any secret enough string broker_name='my_worker', ) ) ) scheduler = TaskiqScheduler( broker=broker, sources=[ AsyncpgScheduleSource( dsn=dsn, broker=broker, ), ], ) @broker.task( task_name='solve_all_problems', schedule=[ {'cron': '*/1 * * * *'}, {'time': dt.datetime.now(dt.timezone.utc) + dt.timedelta(minutes=2)}, ], ) async def best_task_ever(*args, **kwargs) -> dict[str, tp.Any]: """Solve all problems in the world.""" await asyncio.sleep(15) print('All problems are solved!') error_probability = 0.2 if random.random() < error_probability: raise RuntimeError('An unexpected error occurred while solving problems.') return { 'status': 'success', 'random_number': random.randint(1, 42), 'args': args, 'kwargs': kwargs, } def run_admin_panel() -> None: app = TaskiqDashboard( api_token='supersecret', broker=broker, scheduler=scheduler, host='0.0.0.0', port=8000, ) app.run() if __name__ == '__main__': run_admin_panel() ``` -------------------------------- ### Run Taskiq Admin Panel (Shell) Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_scheduler Command to run the Taskiq admin panel. This command starts the web server for the Taskiq Dashboard, allowing you to monitor and interact with your tasks. ```shell uv run python -m docs.examples.example_with_scheduler ``` -------------------------------- ### Configure Taskiq-Dashboard via Environment Variables (SQLite) Source: https://danfimov.github.io/taskiq-dashboard/index This example demonstrates configuring Taskiq-dashboard for SQLite using environment variables. It includes settings for the driver, file path for the database, and API configuration parameters. ```shell TASKIQ_DASHBOARD__SQLITE__DRIVER=sqlite+aiosqlite TASKIQ_DASHBOARD__SQLITE__FILE_PATH=taskiq-dashboard.db # or just use DSN: TASKIQ_DASHBOARD__SQLITE__DSN=sqlite+aiosqlite:///taskiq_dashboard.db TASKIQ_DASHBOARD__API__HOST=localhost TASKIQ_DASHBOARD__API__PORT=8000 TASKIQ_DASHBOARD__API__TOKEN=supersecret ``` -------------------------------- ### Pull Taskiq Dashboard Docker Image Source: https://danfimov.github.io/taskiq-dashboard/index Pulls the latest Docker image for the taskiq-dashboard application. This requires Docker to be installed and running on your system. ```shell docker pull ghcr.io/danfimov/taskiq-dashboard:latest ``` -------------------------------- ### Run Taskiq Scheduler (Shell) Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_scheduler Command to run the Taskiq scheduler. This command starts the scheduler process, which is responsible for triggering scheduled tasks based on their defined schedules. ```shell uv run taskiq scheduler docs.examples.example_with_scheduler:scheduler ``` -------------------------------- ### Run Taskiq Dashboard with Docker Compose (PostgreSQL) Source: https://danfimov.github.io/taskiq-dashboard/index Sets up and runs the Taskiq Dashboard and a PostgreSQL database using Docker Compose. This configuration requires Docker and Docker Compose to be installed. Ensure environment variables, especially the API token, are set correctly. ```yaml services: postgres: image: postgres:18 environment: POSTGRES_USER: taskiq-dashboard POSTGRES_PASSWORD: look_in_vault POSTGRES_DB: taskiq-dashboard volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" dashboard: image: ghcr.io/danfimov/taskiq-dashboard:latest depends_on: - postgres environment: TASKIQ_DASHBOARD__STORAGE_TYPE: postgres TASKIQ_DASHBOARD__POSTGRES__HOST: postgres TASKIQ_DASHBOARD__API__TOKEN: supersecret ports: - "8000:8000" volumes: postgres_data: ``` -------------------------------- ### Configure Taskiq-Dashboard via Environment Variables (PostgreSQL) Source: https://danfimov.github.io/taskiq-dashboard/index This example shows how to configure Taskiq-dashboard for PostgreSQL using environment variables. It covers database connection parameters like driver, host, port, user, password, database name, and pool sizes, as well as API settings. ```shell TASKIQ_DASHBOARD__POSTGRES__DRIVER=postgresql+asyncpg TASKIQ_DASHBOARD__POSTGRES__HOST=localhost TASKIQ_DASHBOARD__POSTGRES__PORT=5432 TASKIQ_DASHBOARD__POSTGRES__USER=taskiq-dashboard TASKIQ_DASHBOARD__POSTGRES__PASSWORD=look_in_vault TASKIQ_DASHBOARD__POSTGRES__DATABASE=taskiq-dashboard TASKIQ_DASHBOARD__POSTGRES__MIN_POOL_SIZE=1 TASKIQ_DASHBOARD__POSTGRES__MAX_POOL_SIZE=5 # or just use DSN: TASKIQ_DASHBOARD__POSTGRES__DSN=postgresql+asyncpg://taskiq-dashboard:look_in_vault@localhost:5432/taskiq-dashboard TASKIQ_DASHBOARD__API__HOST=localhost TASKIQ_DASHBOARD__API__PORT=8000 TASKIQ_DASHBOARD__API__TOKEN=supersecret ``` -------------------------------- ### Run Taskiq Worker (Shell) Source: https://danfimov.github.io/taskiq-dashboard/tutorial/run_with_scheduler Command to run the Taskiq worker. This command starts a worker process that listens for tasks and executes them. It specifies the broker instance to use and the number of worker processes. ```shell uv run taskiq worker docs.examples.example_with_scheduler:broker --workers 1 ``` -------------------------------- ### Configure Taskiq-Dashboard with PostgreSQL Source: https://danfimov.github.io/taskiq-dashboard/index This snippet demonstrates how to initialize TaskiqDashboard using PostgreSQL as the storage backend. It shows how to pass API token, storage type, database DSN, and uvicorn parameters directly to the constructor. ```python app = TaskiqDashboard( api_token='supersecret', storage_type='postgres', database_dsn="postgresql://taskiq-dashboard:look_in_vault@postgres:5432/taskiq-dashboard", # all this keywords will be passed to uvicorn host='localhost', port=8000, log_level='info', access_log=False, ) ``` -------------------------------- ### View All Commands - Make Source: https://danfimov.github.io/taskiq-dashboard/contributing Displays a help message listing all available commands for the project. This is useful for discovering other development and management tasks. ```bash make help ``` -------------------------------- ### Configure Taskiq-Dashboard with SQLite Source: https://danfimov.github.io/taskiq-dashboard/index This snippet illustrates the initialization of TaskiqDashboard with SQLite as the storage. It highlights the use of the 'sqlite+aiosqlite' driver and the file path for the database, along with uvicorn configuration via constructor arguments. ```python app = TaskiqDashboard( api_token='supersecret', storage_type='sqlite', database_dsn="sqlite+aiosqlite:///taskiq_dashboard.db", # all this keywords will be passed to uvicorn host='localhost', port=8000, log_level='info', access_log=False, ) ``` -------------------------------- ### Run Taskiq Dashboard with Code (SQLite) Source: https://danfimov.github.io/taskiq-dashboard/index Initializes and runs the TaskiqDashboard application using Python code, configured to use a SQLite database. Ensure the API token matches the middleware configuration. ```python from taskiq_dashboard import TaskiqDashboard from your_project.broker import broker # your Taskiq broker instance def run_admin_panel() -> None: app = TaskiqDashboard( api_token='supersecret', # the same secret as in middleware storage_type='sqlite', database_dsn="sqlite+aiosqlite:///taskiq_dashboard.db", broker=broker, # pass your broker instance here to enable additional features host='0.0.0.0', port=8000, ) app.run() if __name__ == '__main__': run_admin_panel() ``` -------------------------------- ### Run Taskiq Dashboard with Code (PostgreSQL) Source: https://danfimov.github.io/taskiq-dashboard/index Initializes and runs the TaskiqDashboard application using Python code, configured to use a PostgreSQL database. Ensure PostgreSQL is accessible at the provided DSN and the API token matches the middleware configuration. ```python from taskiq_dashboard import TaskiqDashboard from your_project.broker import broker # your Taskiq broker instance def run_admin_panel() -> None: app = TaskiqDashboard( api_token='supersecret', # the same secret as in middleware storage_type='postgres', database_dsn="postgresql://taskiq-dashboard:look_in_vault@postgres:5432/taskiq-dashboard", broker=broker, # pass your broker instance here to enable additional features host='0.0.0.0', port=8000, ) app.run() if __name__ == '__main__': run_admin_panel() ``` -------------------------------- ### Integrate TaskiqAdminMiddleware with Taskiq Broker Source: https://danfimov.github.io/taskiq-dashboard/index Connects the TaskiqAdminMiddleware to your Taskiq broker instance. This enables communication between your Taskiq workers and the dashboard. Requires a Taskiq broker instance and result backend. ```python from taskiq.middlewares.taskiq_admin_middleware import TaskiqAdminMiddleware broker = ( RedisStreamBroker( url=redis_url, queue_name="my_lovely_queue", ) .with_result_backend(result_backend) .with_middlewares( TaskiqAdminMiddleware( url="http://localhost:8000", # the url to your taskiq-dashboard instance api_token="supersecret", # secret for accessing the dashboard API taskiq_broker_name="my_worker", # it will be worker name in the dashboard ) ) ) ``` -------------------------------- ### Run Taskiq Dashboard with Docker Compose (SQLite) Source: https://danfimov.github.io/taskiq-dashboard/index Sets up and runs the Taskiq Dashboard using Docker Compose, configured with a SQLite database. This configuration requires Docker and Docker Compose. Ensure environment variables, especially the API token, are set correctly. ```yaml services: dashboard: image: ghcr.io/danfimov/taskiq-dashboard:latest environment: TASKIQ_DASHBOARD__STORAGE_TYPE: postgres TASKIQ_DASHBOARD__SQLITE__DSN: sqlite+aiosqlite:///taskiq_dashboard.db TASKIQ_DASHBOARD__API__TOKEN: supersecret volumes: - taskiq_dashboard_sqlite:/app/taskiq-dashboard.db ports: - "8000:8000" volumes: taskiq_dashboard_sqlite: ``` -------------------------------- ### Clone Repository - Git Source: https://danfimov.github.io/taskiq-dashboard/contributing Clones the Taskiq Dashboard repository from GitHub to your local machine. This is the first step in setting up the development environment. ```bash git clone https://github.com/danfimov/taskiq-dashboard.git cd taskiq-dashboard ``` -------------------------------- ### Run TailwindCSS Watch Mode - PNPM Source: https://danfimov.github.io/taskiq-dashboard/contributing Compiles CSS using tailwindcss in watch mode. This command ensures that any changes to the CSS are automatically reflected, streamlining the styling development process. ```bash pnpm run dev ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.