Source#
- class lumen.sources.base.Source(*, cache_data, cache_dir, cache_metadata, cache_per_query, cache_schema, cache_with_dask, metadata_func, root, shared, name)#
Source components provide allow querying all kinds of data.
A Source can return one or more tables queried using the .get_tables method, a description of the data returned by each table in the form of a JSON schema accessible via the .get_schema method and lastly a .get method that allows filtering the data.
The Source base class also implements both in-memory and disk caching which can be enabled if a cache_dir is provided. Data cached to disk is stored as parquet files.
Parameters#
type: bool
default: True
Whether to cache actual data.
type: str
default: None
Whether to enable local cache and write file to disk.
type: bool
default: True
Whether to cache metadata.
type: bool
default: True
Whether to query the whole dataset or individual queries.
type: bool
default: True
Whether to cache table schemas.
type: bool
default: True
Whether to read and write cache files with dask if available.
type: type: type: type: Clears any cached data. Return a table; optionally filtered by the given query. table (str) – The name of the table to query query (dict) – A dictionary containing all the query parameters A DataFrame containing the queried table. DataFrame Returns metadata for one, multiple or all tables provided by the source. The metadata for a table is structured as: “description”: …,
“columns”: { “description”: …,
“data_type”: …, } },
**other_metadata } If a list of tables or no table is provided the metadata is nested one additional level: “description”: …,
“columns”: { <COLUMN>: {
“description”: …,
“data_type”: …,
} },
**other_metadata } } } table (str | list[str] | None) – The name of the table to return the schema for. If None
returns schema for all available tables. metadata – Dictionary of metadata indexed by table (if no table was
was provided or individual table metdata. dict Returns JSON schema describing the tables returned by the
Source. table (str | None) – The name of the table to return the schema for. If None
returns schema for all available tables. limit (int | None) – Limits the number of rows considered for the schema calculation JSON schema(s) for one or all the tables. dict Returns the list of tables available on this source. The list of available tables on this source. list Exports the full specification to reconstruct this component. Resolved and instantiated Component object The BaseSQLSource implements the additional API required by The JSONSource is very similar to the FileSource but loads json files. DuckDBSource provides a simple wrapper around the DuckDB SQL An Any
default: None
Function to implement custom metadata lookup for tables.Given a list of tables it should return a dictionary of the form:{ : {“description”: …, “columns”: {“column_name”: “…”}}}May be used to override the default _get_table_metadataimplementation of the Source.
str
default: 'Source'
String identifier for this object.pathlib.Path
default: None
Root folder of the cache_dir, default is config.rootbool
default: False
Whether the Source can be shared across all instances of thedashboard. If set to True
the Source will be loaded oninitial server load.
Methods#
Types#
RESTSource
allows querying REST endpoints conforming to the Lumen REST specification.InMemorySource
can be used to work with in-memory data.FileSource
loads CSV, Excel and Parquet files using pandas and dask read_*
functions.WebsiteSource
queries whether a website responds with a 400 status code.PanelSessionSource
queries the session_info endpoint of a Panel application.JoinedSource
performs a join on tables from one or more sources.DerivedSource
applies filtering and transforms to tables from other sources.IntakeSource
loads data from an Intake catalog.IntakeSQLSource
extends the IntakeSource
with support for SQL data.