trilogy-public-models
Overview
This repository contains semantic models describing public datasets as Trilogy data models.
You can use this to quickly get started with Trilogy, or just as a place to find fun data to explore.
Contributing
Model setup
All models should be in a double nested directory; first the platform and then the semantic label of the model.
Models should have the following
- entrypoint.preql
- README.md
To expose models in the studio, run the 'build.py' script under the studio folder.
Examples will be picked up from matching subdirectories under the 'examples' folder.
Installation
pip install trilogy-public-models
Examples
This repository also contains a examples/ folder, which can be browsed for in-depth code examples.
Quickstart
This will import and set up a duckdb engine with a SF .5 environment.
from trilogy_public_models import data_models
from trilogy_public_models import get_executor
executor = get_executor("duckdb.tpc-ds")
QA_1 ="""
select
store_sales.date.year,
count(store_sales.customer.id)->customer_count
order by
store_sales.date.year desc ;
""" # noqa: E501
results = executor.execute_text(QA_1)
for row in results[0].fetchall():
print(row)
Advanced Usage
This example assumes you are querying Bigquery Datasets.
To utilize a model, instantiate a standard Trilogy executor (in this case, a bigquery client) and then pass in one of the existing environments from this package into the environment argument.
That will enable you to run queries against the semantic model.
from google.auth import default
from google.cloud import bigquery
from trilogy.executor import Executor, Dialects
from sqlalchemy.engine import create_engine
from trilogy_public_models.bigquery import google_search_trends
from trilogy_public_models import get_executor
# use default auth
exec = get_executor('google_search_trends')
# or provide client explicitly
# if using more complicated auth
project, auth = default()
bq_client = bigquery.Client(auth, project)
engine = create_engine(f"bigquery://{project}?user_supplied_client=True",
connect_args={'client': bq_client})
exec = Executor(
dialect=Dialects.BIGQUERY, engine=engine,
environment=google_search_trends
)
results = exec.execute_text("""
SELECT
trends.term,
trends.rank,
trends.week,
trends.refresh_date,
WHERE
trends.week > '2023-01-01'
and trends.refresh_date = '2023-02-22'
and trends.rank < 10
ORDER BY
trends.week desc,
trends.rank asc
limit 100;
""")
# you can execute multiple queries separate by a semicolon
# so our results will be in the first element of the arra
for row in results[0]:
print(row)
You can access all models through the data_model object:
from trilog_public_models import data_models
for k, v in data_models.items():
print(k)
_ = v.environment # environment
Combining Models
Trilogy supports combining multiple environments into a single environment. This enables simplified querying of universal concepts, like looking up StackOverflow links embedded in Github commits, or merging GPS data across different domains.
Use the standard trilogy toolkit of merges to do this.
Model Tests
All models will be imported and verified. Validation methods will depend on the defined backend.
All models require that the datasets being shared with the preql validation account.
Current verifications:
- model imports successfully
- datasource bindings exist
- datasource to concept mappings are appropriately typed
- concept relations are consistently typed
Metadata
Release files for trilogy-public-models 0.1.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trilogy_public_models-0.1.26.tar.gz | 278.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trilogy_public_models-0.1.26-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 821.3 kB
Release files / trilogy_public_models-0.1.26.tar.gz
| Download URL | trilogy_public_models-0.1.26.tar.gz |
|---|---|
| Size | 278.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11d08246a38f7560477ad423b902a34636506229bb357a7db0d41be58c9d6a5f
|
|
BLAKE2b-256 checksum How to use checksums |
5e003c3390d4987854f5dd2553dc5d72f18d9f5151b2205cc92d8f642da48502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / trilogy_public_models-0.1.26-py3-none-any.whl
| Download URL | trilogy_public_models-0.1.26-py3-none-any.whl |
|---|---|
| Size | 543.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a92861397f6d4f9f90ed466798626fef1e31012d860f0f5eda46eb58cbbf554
|
|
BLAKE2b-256 checksum How to use checksums |
58303f902963ddb6092f6633e20868ba20ed008aa4d17a22723f0bd26c534f4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency log