Skip to content

Reports

albert.resources.reports

Attributes:

Name Type Description
ReportItem

ReportItem

ReportItem = dict[str, Any] | list[dict[str, Any]] | None

ReportInfo

Bases: BaseAlbertModel

The result of running a report on demand.

Returned by the get_report family of methods on ReportCollection.

Show JSON schema:
{
  "description": "The result of running a report on demand.\n\nReturned by the ``get_report`` family of methods on\n[`ReportCollection`][albert.collections.reports.ReportCollection].",
  "properties": {
    "reportTypeId": {
      "description": "The report type ID that was run (e.g. ``\"RET51\"``).",
      "title": "Reporttypeid",
      "type": "string"
    },
    "reportType": {
      "description": "The human-readable name of the report type.",
      "title": "Reporttype",
      "type": "string"
    },
    "category": {
      "description": "The report category (e.g. ``\"analytics\"`` or ``\"datascience\"``).",
      "title": "Category",
      "type": "string"
    },
    "Items": {
      "description": "The computed report result rows. Each item is a dict (or list of dicts) whose shape depends on the report type.",
      "items": {
        "anyOf": [
          {
            "additionalProperties": true,
            "type": "object"
          },
          {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          {
            "type": "null"
          }
        ]
      },
      "title": "Items",
      "type": "array"
    }
  },
  "required": [
    "reportTypeId",
    "reportType",
    "category",
    "Items"
  ],
  "title": "ReportInfo",
  "type": "object"
}

Fields:

report_type_id

report_type_id: str

The report type ID that was run (e.g. "RET51").

report_type

report_type: str

The human-readable name of the report type.

category

category: str

The report category (e.g. "analytics" or "datascience").

items

items: list[ReportItem]

The computed report result rows. Each item is a dict (or list of dicts) whose shape depends on the report type.

ColumnState

Bases: BaseAlbertModel

The display and grouping state of a single report column.

Show JSON schema:
{
  "description": "The display and grouping state of a single report column.",
  "properties": {
    "colId": {
      "description": "The identifier of the column.",
      "title": "Colid",
      "type": "string"
    },
    "rowGroupIndex": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The column's position among the row-grouping columns, if grouped.",
      "title": "Rowgroupindex"
    },
    "aggFunc": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The aggregation function applied to the column (e.g. ``\"sum\"``).",
      "title": "Aggfunc"
    },
    "pivot": {
      "default": false,
      "description": "Whether the column is used as a pivot column.",
      "title": "Pivot",
      "type": "boolean"
    },
    "pivotIndex": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The column's position among the pivot columns, if pivoted.",
      "title": "Pivotindex"
    },
    "rowGroup": {
      "default": false,
      "description": "Whether the column is used to group rows.",
      "title": "Rowgroup",
      "type": "boolean"
    }
  },
  "required": [
    "colId"
  ],
  "title": "ColumnState",
  "type": "object"
}

Fields:

col_id

col_id: str

The identifier of the column.

row_group_index

row_group_index: int | None = None

The column's position among the row-grouping columns, if grouped.

agg_func

agg_func: str | None = None

The aggregation function applied to the column (e.g. "sum").

pivot

pivot: bool = False

Whether the column is used as a pivot column.

pivot_index

pivot_index: int | None = None

The column's position among the pivot columns, if pivoted.

row_group

row_group: bool = False

Whether the column is used to group rows.

FilterModel

Bases: BaseAlbertModel

A single filter applied to a report.

Show JSON schema:
{
  "description": "A single filter applied to a report.",
  "properties": {
    "filterType": {
      "description": "The kind of filter (e.g. ``\"set\"`` or ``\"text\"``).",
      "title": "Filtertype",
      "type": "string"
    },
    "values": {
      "anyOf": [
        {
          "items": {},
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The values the filter matches against.",
      "title": "Values"
    }
  },
  "required": [
    "filterType"
  ],
  "title": "FilterModel",
  "type": "object"
}

Fields:

filter_type

filter_type: str

The kind of filter (e.g. "set" or "text").

values

values: list[Any] | None = None

The values the filter matches against.

FilterState

Bases: BaseAlbertModel

The collection of filters applied to a report.

Show JSON schema:
{
  "$defs": {
    "FilterModel": {
      "description": "A single filter applied to a report.",
      "properties": {
        "filterType": {
          "description": "The kind of filter (e.g. ``\"set\"`` or ``\"text\"``).",
          "title": "Filtertype",
          "type": "string"
        },
        "values": {
          "anyOf": [
            {
              "items": {},
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The values the filter matches against.",
          "title": "Values"
        }
      },
      "required": [
        "filterType"
      ],
      "title": "FilterModel",
      "type": "object"
    }
  },
  "description": "The collection of filters applied to a report.",
  "properties": {
    "filterModels": {
      "description": "The individual filters that make up the report's filter state.",
      "items": {
        "$ref": "#/$defs/FilterModel"
      },
      "title": "Filtermodels",
      "type": "array"
    }
  },
  "title": "FilterState",
  "type": "object"
}

Fields:

filter_models

filter_models: list[FilterModel]

The individual filters that make up the report's filter state.

MetadataState

Bases: BaseAlbertModel

The metadata state of a report.

Show JSON schema:
{
  "description": "The metadata state of a report.",
  "properties": {
    "groupedRows": {
      "description": "The identifiers of rows that are grouped in the report.",
      "items": {
        "type": "string"
      },
      "title": "Groupedrows",
      "type": "array"
    }
  },
  "title": "MetadataState",
  "type": "object"
}

Fields:

grouped_rows

grouped_rows: list[str]

The identifiers of rows that are grouped in the report.

ChartConfiguration

Bases: BaseAlbertModel

The configuration of a chart on a report.

Show JSON schema:
{
  "description": "The configuration of a chart on a report.",
  "properties": {
    "chartType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
      "title": "Charttype"
    }
  },
  "title": "ChartConfiguration",
  "type": "object"
}

Fields:

chart_type

chart_type: str | None = None

The type of chart (e.g. "bar" or "line").

ChartTemplate

Bases: BaseAlbertModel

The template describing a chart's base type on a report.

Show JSON schema:
{
  "description": "The template describing a chart's base type on a report.",
  "properties": {
    "chartType": {
      "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
      "title": "Charttype",
      "type": "string"
    }
  },
  "required": [
    "chartType"
  ],
  "title": "ChartTemplate",
  "type": "object"
}

Fields:

chart_type

chart_type: str

The type of chart (e.g. "bar" or "line").

ChartModelState

Bases: BaseAlbertModel

The saved state of a single chart on a report.

Show JSON schema:
{
  "$defs": {
    "ChartConfiguration": {
      "description": "The configuration of a chart on a report.",
      "properties": {
        "chartType": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
          "title": "Charttype"
        }
      },
      "title": "ChartConfiguration",
      "type": "object"
    },
    "ChartTemplate": {
      "description": "The template describing a chart's base type on a report.",
      "properties": {
        "chartType": {
          "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
          "title": "Charttype",
          "type": "string"
        }
      },
      "required": [
        "chartType"
      ],
      "title": "ChartTemplate",
      "type": "object"
    }
  },
  "description": "The saved state of a single chart on a report.",
  "properties": {
    "chartTemplate": {
      "anyOf": [
        {
          "$ref": "#/$defs/ChartTemplate"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The chart's base template."
    },
    "chartConfiguration": {
      "anyOf": [
        {
          "$ref": "#/$defs/ChartConfiguration"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The chart's configuration."
    }
  },
  "title": "ChartModelState",
  "type": "object"
}

Fields:

chart_template

chart_template: ChartTemplate | None = None

The chart's base template.

chart_configuration

chart_configuration: ChartConfiguration | None = None

The chart's configuration.

ColumnMapping

Bases: BaseAlbertModel

A mapping of report fields to columns.

This model currently defines no fields.

Show JSON schema:
{
  "description": "A mapping of report fields to columns.\n\nThis model currently defines no fields.",
  "properties": {},
  "title": "ColumnMapping",
  "type": "object"
}

FullAnalyticalReport

Bases: BaseResource

A saved analytical report in Albert.

This resource represents a complete analytical report: its report type, the data it was run over, and its saved display state (columns, filters, grouping, and charts). Retrieve one with get_full_report or create one with create_report.

Example

from albert.resources.reports import FullAnalyticalReport

report = FullAnalyticalReport(
    report_type_id="ALB#RET22",
    name="My New Report",
    description="A test report",
)
Show JSON schema:
{
  "$defs": {
    "AuditFields": {
      "description": "The audit fields for a resource",
      "properties": {
        "by": {
          "default": null,
          "title": "By",
          "type": "string"
        },
        "byName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Byname"
        },
        "at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "At"
        }
      },
      "title": "AuditFields",
      "type": "object"
    },
    "ChartConfiguration": {
      "description": "The configuration of a chart on a report.",
      "properties": {
        "chartType": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
          "title": "Charttype"
        }
      },
      "title": "ChartConfiguration",
      "type": "object"
    },
    "ChartModelState": {
      "description": "The saved state of a single chart on a report.",
      "properties": {
        "chartTemplate": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChartTemplate"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The chart's base template."
        },
        "chartConfiguration": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChartConfiguration"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The chart's configuration."
        }
      },
      "title": "ChartModelState",
      "type": "object"
    },
    "ChartTemplate": {
      "description": "The template describing a chart's base type on a report.",
      "properties": {
        "chartType": {
          "description": "The type of chart (e.g. ``\"bar\"`` or ``\"line\"``).",
          "title": "Charttype",
          "type": "string"
        }
      },
      "required": [
        "chartType"
      ],
      "title": "ChartTemplate",
      "type": "object"
    },
    "ColumnMapping": {
      "description": "A mapping of report fields to columns.\n\nThis model currently defines no fields.",
      "properties": {},
      "title": "ColumnMapping",
      "type": "object"
    },
    "ColumnState": {
      "description": "The display and grouping state of a single report column.",
      "properties": {
        "colId": {
          "description": "The identifier of the column.",
          "title": "Colid",
          "type": "string"
        },
        "rowGroupIndex": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The column's position among the row-grouping columns, if grouped.",
          "title": "Rowgroupindex"
        },
        "aggFunc": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The aggregation function applied to the column (e.g. ``\"sum\"``).",
          "title": "Aggfunc"
        },
        "pivot": {
          "default": false,
          "description": "Whether the column is used as a pivot column.",
          "title": "Pivot",
          "type": "boolean"
        },
        "pivotIndex": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The column's position among the pivot columns, if pivoted.",
          "title": "Pivotindex"
        },
        "rowGroup": {
          "default": false,
          "description": "Whether the column is used to group rows.",
          "title": "Rowgroup",
          "type": "boolean"
        }
      },
      "required": [
        "colId"
      ],
      "title": "ColumnState",
      "type": "object"
    },
    "FilterModel": {
      "description": "A single filter applied to a report.",
      "properties": {
        "filterType": {
          "description": "The kind of filter (e.g. ``\"set\"`` or ``\"text\"``).",
          "title": "Filtertype",
          "type": "string"
        },
        "values": {
          "anyOf": [
            {
              "items": {},
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The values the filter matches against.",
          "title": "Values"
        }
      },
      "required": [
        "filterType"
      ],
      "title": "FilterModel",
      "type": "object"
    },
    "FilterState": {
      "description": "The collection of filters applied to a report.",
      "properties": {
        "filterModels": {
          "description": "The individual filters that make up the report's filter state.",
          "items": {
            "$ref": "#/$defs/FilterModel"
          },
          "title": "Filtermodels",
          "type": "array"
        }
      },
      "title": "FilterState",
      "type": "object"
    },
    "MetadataState": {
      "description": "The metadata state of a report.",
      "properties": {
        "groupedRows": {
          "description": "The identifiers of rows that are grouped in the report.",
          "items": {
            "type": "string"
          },
          "title": "Groupedrows",
          "type": "array"
        }
      },
      "title": "MetadataState",
      "type": "object"
    },
    "Status": {
      "description": "The status of a resource.\n\nAttributes\n----------\nACTIVE : str\n    The resource is fully operational and visible in normal operations.\nINACTIVE : str\n    The resource is hidden from normal operations and disabled from use.",
      "enum": [
        "active",
        "inactive"
      ],
      "title": "Status",
      "type": "string"
    }
  },
  "description": "A saved analytical report in Albert.\n\nThis resource represents a complete analytical report: its report type, the\ndata it was run over, and its saved display state (columns, filters, grouping,\nand charts). Retrieve one with\n[`get_full_report`][albert.collections.reports.ReportCollection.get_full_report] or create\none with [`create_report`][albert.collections.reports.ReportCollection.create_report].\n\n!!! example\n    ```python\n    from albert.resources.reports import FullAnalyticalReport\n\n    report = FullAnalyticalReport(\n        report_type_id=\"ALB#RET22\",\n        name=\"My New Report\",\n        description=\"A test report\",\n    )\n    ```",
  "properties": {
    "status": {
      "anyOf": [
        {
          "$ref": "#/$defs/Status"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The status of the resource, optional."
    },
    "Created": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the creation of the resource, optional."
    },
    "Updated": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the update of the resource, optional."
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Albert ID of the report (format ``REP...``). Set by Albert; read-only.",
      "title": "Id"
    },
    "reportTypeId": {
      "description": "The report type ID identifying which report to run. Required.",
      "title": "Reporttypeid",
      "type": "string"
    },
    "name": {
      "description": "The report's name (1 to 500 characters). Required.",
      "maxLength": 500,
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "reportType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The human-readable name of the report type.",
      "title": "Reporttype"
    },
    "description": {
      "anyOf": [
        {
          "maxLength": 1000,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A description of the report (maximum 1000 characters).",
      "title": "Description"
    },
    "projectId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Project the report is scoped to, if any (format ``PRO...``).",
      "title": "Projectid"
    },
    "projectName": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The name of the scoped project.",
      "title": "Projectname"
    },
    "parentId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The parent entity the report belongs to, if any.",
      "title": "Parentid"
    },
    "reportV2": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Whether this is a v2 report.",
      "title": "Reportv2"
    },
    "inputData": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Input describing what the report is run over, keyed by field name.",
      "title": "Inputdata"
    },
    "reportState": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A string capturing the overall report state.",
      "title": "Reportstate"
    },
    "columnState": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ColumnState"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "The saved display and grouping state of each column.",
      "title": "Columnstate"
    },
    "filterState": {
      "anyOf": [
        {
          "$ref": "#/$defs/FilterState"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The saved filters applied to the report."
    },
    "metaDataState": {
      "anyOf": [
        {
          "$ref": "#/$defs/MetadataState"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The saved metadata state (e.g. grouped rows)."
    },
    "chartModelState": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ChartModelState"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "The saved state of each chart on the report.",
      "title": "Chartmodelstate"
    },
    "FieldMapping": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ColumnMapping"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "The mapping of report fields to columns.",
      "title": "Fieldmapping"
    },
    "sourceReportId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A report to copy state from when creating this report (format ``REP...``).",
      "title": "Sourcereportid"
    },
    "createdBy": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The ID of the user who created the report. Read-only.",
      "title": "Createdby"
    },
    "report": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The raw report result rows. Populated when the report is retrieved; read-only. Use [`get_raw_dataframe`][albert.resources.reports.FullAnalyticalReport.get_raw_dataframe] to read it as a DataFrame.",
      "title": "Report"
    }
  },
  "required": [
    "reportTypeId",
    "name"
  ],
  "title": "FullAnalyticalReport",
  "type": "object"
}

Fields:

id

id: ReportId | None = None

The Albert ID of the report (format REP...). Set by Albert; read-only.

report_type_id

report_type_id: str

The report type ID identifying which report to run. Required.

name

name: str

The report's name (1 to 500 characters). Required.

report_type

report_type: str | None = None

The human-readable name of the report type.

description

description: str | None = None

A description of the report (maximum 1000 characters).

project_id

project_id: ProjectId | None = None

The Project the report is scoped to, if any (format PRO...).

project_name

project_name: str | None = None

The name of the scoped project.

parent_id

parent_id: str | None = None

The parent entity the report belongs to, if any.

report_v2

report_v2: bool | None = None

Whether this is a v2 report.

input_data

input_data: dict[str, Any] | None = None

Input describing what the report is run over, keyed by field name.

report_state

report_state: str | None = None

A string capturing the overall report state.

column_state

column_state: list[ColumnState] | None

The saved display and grouping state of each column.

filter_state

filter_state: FilterState | None = None

The saved filters applied to the report.

meta_data_state

meta_data_state: MetadataState | None = None

The saved metadata state (e.g. grouped rows).

chart_model_state

chart_model_state: list[ChartModelState] | None

The saved state of each chart on the report.

field_mapping

field_mapping: list[ColumnMapping] | None

The mapping of report fields to columns.

source_report_id

source_report_id: ReportId | None = None

A report to copy state from when creating this report (format REP...).

created_by

created_by: str | None = None

The ID of the user who created the report. Read-only.

report

report: list[dict[str, Any]] | None = None

The raw report result rows. Populated when the report is retrieved; read-only. Use get_raw_dataframe to read it as a DataFrame.

get_raw_dataframe

get_raw_dataframe() -> DataFrame

Return the raw report data as a pandas DataFrame.

Returns:

Type Description
DataFrame

The raw report result rows.

Raises:

Type Description
ValueError

If the report has no result data (e.g. it was built locally rather than retrieved from Albert).

Source code in src/albert/resources/reports.py
def get_raw_dataframe(self) -> pd.DataFrame:
    """Return the raw report data as a pandas DataFrame.

    Returns
    -------
    pd.DataFrame
        The raw report result rows.

    Raises
    ------
    ValueError
        If the report has no result data (e.g. it was built locally rather
        than retrieved from Albert).
    """
    if not self.report:
        raise ValueError("Report data is not available")
    return pd.DataFrame(self.report)