trilogy-public-models


Nametrilogy-public-models JSON
Version 0.0.18 PyPI version JSON
download
home_pageNone
SummaryPublic trilogy/preql models.
upload_time2024-04-01 00:49:13
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
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": null,
    "name": "trilogy-public-models",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "preql-community@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4a/d5/48cc02a9c8e7ffede6e55f69687e9edc01091b73fa8b4262d31a7ef5bccd/trilogy-public-models-0.0.18.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": null,
    "summary": "Public trilogy/preql models.",
    "version": "0.0.18",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ccb8da82992db6dbb405c709b9a7c27962d0166ab9caf6fce012792ffbd90dc",
                "md5": "fdbab5d32be202eda10f53444b99551b",
                "sha256": "dbdf372e5cf065ca6c4309add98933ee0f5a32b469142fd680f76ebcc95ac309"
            },
            "downloads": -1,
            "filename": "trilogy_public_models-0.0.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fdbab5d32be202eda10f53444b99551b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 45647,
            "upload_time": "2024-04-01T00:49:11",
            "upload_time_iso_8601": "2024-04-01T00:49:11.027058Z",
            "url": "https://files.pythonhosted.org/packages/0c/cb/8da82992db6dbb405c709b9a7c27962d0166ab9caf6fce012792ffbd90dc/trilogy_public_models-0.0.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ad548cc02a9c8e7ffede6e55f69687e9edc01091b73fa8b4262d31a7ef5bccd",
                "md5": "b1203cb5f4a30653f832631506dc70e1",
                "sha256": "9f07f7fa1342212c651b42d2a5023f21d6e237a1fdedd66e1a6c6b3be1a1e884"
            },
            "downloads": -1,
            "filename": "trilogy-public-models-0.0.18.tar.gz",
            "has_sig": false,
            "md5_digest": "b1203cb5f4a30653f832631506dc70e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26280,
            "upload_time": "2024-04-01T00:49:13",
            "upload_time_iso_8601": "2024-04-01T00:49:13.213371Z",
            "url": "https://files.pythonhosted.org/packages/4a/d5/48cc02a9c8e7ffede6e55f69687e9edc01091b73fa8b4262d31a7ef5bccd/trilogy-public-models-0.0.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 00:49:13",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "trilogy-public-models"
}
        
Elapsed time: 0.34798s