Name | trilogy-public-models JSON |
Version |
0.0.10
JSON |
| download |
home_page | |
Summary | Public trilogy/preql models. |
upload_time | 2023-05-26 12:51:13 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# trilogy-public-models
## Overview
This repository contains semantic models on public datasets for the Preql/Trilogy language.
This supports the interactive PreQL demo, but can also be used by anyone to boostrap exploration
of these public datasets.
You can install this library directly and import models to use.
## Installation
```commandline
pip install trilogy-public-models
```
## Examples
This repository also contains a examples/ folder, which can be browsed for in-depth code examples.
## Local Usage
This example assumes you are querying Bigquery Datasets.
To utilize a model, instantiate a standard PreQL 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.
```python
from google.auth import default
from google.cloud import bigquery
from preql.executor import Executor, Dialects
from sqlalchemy.engine import create_engine
from trilogy_public_models.bigquery import google_search_trends
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)
```
## Combining Models
Coming soon!
Preql 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.
## 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
### 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
Raw data
{
"_id": null,
"home_page": "",
"name": "trilogy-public-models",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "preql-community@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2e/68/5c1041475e5504a599fd763c8581f3bce5180d4206fdae5cff40473ffd66/trilogy-public-models-0.0.10.tar.gz",
"platform": null,
"description": "# trilogy-public-models\n\n## Overview\n\nThis repository contains semantic models on public datasets for the Preql/Trilogy language. \n\nThis supports the interactive PreQL demo, but can also be used by anyone to boostrap exploration\nof these public datasets.\n\nYou can install this library directly and import models to use.\n\n## Installation\n\n```commandline\npip install trilogy-public-models\n```\n\n## Examples\n\nThis repository also contains a examples/ folder, which can be browsed for in-depth code examples.\n\n## Local Usage\n\nThis example assumes you are querying Bigquery Datasets.\n\nTo utilize a model, instantiate a standard PreQL executor (in this case, a bigquery client) \nand then pass in one of the existing environments from this package into the environment argument.\n\nThat will enable you to run queries against the semantic model.\n\n```python\nfrom google.auth import default\nfrom google.cloud import bigquery\nfrom preql.executor import Executor, Dialects\nfrom sqlalchemy.engine import create_engine\n\nfrom trilogy_public_models.bigquery import google_search_trends\n\nproject, auth = default()\nbq_client = bigquery.Client(auth, project)\n\nengine = create_engine(f\"bigquery://{project}?user_supplied_client=True\",\n connect_args={'client': bq_client})\n\nexec = Executor(\n dialect=Dialects.BIGQUERY, engine=engine,\n environment=google_search_trends\n)\n\nresults = exec.execute_text(\"\"\"\nSELECT \n\ttrends.term,\n\ttrends.rank,\n\ttrends.week,\n\ttrends.refresh_date,\nWHERE\n trends.week > '2023-01-01'\n and trends.refresh_date = '2023-02-22'\n and trends.rank < 10\nORDER BY \n trends.week desc,\n trends.rank asc\nlimit 100;\n\n\"\"\")\n\n# you can execute multiple queries separate by a semicolon\n# so our results will be in the first element of the arra\nfor row in results[0]:\n print(row)\n\n\n```\n\n## Combining Models\n\nComing soon!\n\nPreql supports combining multiple environments into a single environment. This enables simplified querying\nof universal concepts, like looking up StackOverflow links embedded in Github commits, or merging GPS\ndata across different domains. \n\n## Contributing\n\n### Model setup\n\nAll models should be in a double nested directory; first the platform and then the semantic label of the model\n\nModels should have the following\n\n- entrypoint.preql\n- README.md\n\n\n### Model Tests\n\nAll models will be imported and verified. Validation methods will depend on the defined backend. \n\nAll models require that the datasets being shared with the preql validation account. \n\nCurrent verifications:\n\n - model imports successfully\n - datasource bindings exist\n - datasource to concept mappings are appropriately typed\n - concept relations are consistently typed\n",
"bugtrack_url": null,
"license": "",
"summary": "Public trilogy/preql models.",
"version": "0.0.10",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "85ce4409c4ce60c19bf00f2bdc5b58fb4fe605b14fbbb28847e07858fc212009",
"md5": "afa46a0f69c820cd934bb3f43c18c1d6",
"sha256": "b5d6d6de3d8c665d993bec29dab92069ecd3c20d01ff1ca356f3fdab09e6d7f8"
},
"downloads": -1,
"filename": "trilogy_public_models-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "afa46a0f69c820cd934bb3f43c18c1d6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 33493,
"upload_time": "2023-05-26T12:51:12",
"upload_time_iso_8601": "2023-05-26T12:51:12.289752Z",
"url": "https://files.pythonhosted.org/packages/85/ce/4409c4ce60c19bf00f2bdc5b58fb4fe605b14fbbb28847e07858fc212009/trilogy_public_models-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2e685c1041475e5504a599fd763c8581f3bce5180d4206fdae5cff40473ffd66",
"md5": "39ecbbaec8ba425a721209cc450af59a",
"sha256": "a193bbbd77e06e8516ee0d76f86beb1e8396802c8d3d3cfdbd36f1f34cc9ea33"
},
"downloads": -1,
"filename": "trilogy-public-models-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "39ecbbaec8ba425a721209cc450af59a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18428,
"upload_time": "2023-05-26T12:51:13",
"upload_time_iso_8601": "2023-05-26T12:51:13.928969Z",
"url": "https://files.pythonhosted.org/packages/2e/68/5c1041475e5504a599fd763c8581f3bce5180d4206fdae5cff40473ffd66/trilogy-public-models-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-26 12:51:13",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "trilogy-public-models"
}