Pipeline runs and Block runs data are stored in pipeline_run and block_run tables in the database.
If you want to query the PipelineRun and BlockRun metadata, you can either directly query the data
from database or use Python code to fetch PipelineRun and BlockRun models.
from mage_ai.orchestration.db import db_connectionfrom mage_ai.orchestration.db.models.schedules import PipelineRun, BlockRundb_connection.start_session()# Fetch running pipeline runs of a pipelinepipeline_runs = PipelineRun.query.filter( # Filter by pipeline uuid PipelineRun.pipeline_uuid == 'example_pipeline', # Filter by status PipelineRun.status == PipelineRun.PipelineRunStatus.RUNNING, # Filter by execution_date PipelineRun.execution_date >= '2024-01-01', PipelineRun.execution_date < '2024-02-01',)# Get the block runs of a pipeline runblock_runs = pipeline_runs.all()[0].block_runsprint(f'Block runs: {[b.to_dict() for b in block_runs]}')# Get pipeline run countprint(f'Number of pipeline runs {pipeline_runs.count()}')# Batch update pipeline run statusPipelineRun.batch_update_status([p.id for p in pipeline_runs], PipelineRun.PipelineRunStatus.CANCELLED)