{"id":22423140,"url":"https://github.com/joangq/lyra","last_synced_at":"2026-04-19T17:02:11.039Z","repository":{"id":263164125,"uuid":"889553849","full_name":"joangq/lyra","owner":"joangq","description":"Climate Data Store form parser and grammar transformer for automatic code generation","archived":false,"fork":false,"pushed_at":"2024-11-17T23:30:49.000Z","size":1018,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T10:42:32.840Z","etag":null,"topics":["api","api-client","api-wrapper","cds","cdsapi","climate","climate-data","climate-data-store","code-generation","code-transformation","data-collection","data-science","data-trans","dataset","json","json-parser","netcdf","python","wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc-by-4.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joangq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-16T16:14:11.000Z","updated_at":"2024-12-30T22:30:59.000Z","dependencies_parsed_at":"2024-11-16T22:38:48.309Z","dependency_job_id":null,"html_url":"https://github.com/joangq/lyra","commit_stats":null,"previous_names":["joangq/cds_gen","joangq/lyra"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joangq%2Flyra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joangq%2Flyra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joangq%2Flyra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joangq%2Flyra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joangq","download_url":"https://codeload.github.com/joangq/lyra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791896,"owners_count":20672666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","api-wrapper","cds","cdsapi","climate","climate-data","climate-data-store","code-generation","code-transformation","data-collection","data-science","data-trans","dataset","json","json-parser","netcdf","python","wrapper","wrapper-api"],"created_at":"2024-12-05T18:09:24.933Z","updated_at":"2025-10-14T11:35:12.170Z","avatar_url":"https://github.com/joangq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align='center'\u003e\r\n\u003cimg src=\"assets/lyra.svg\" style=\"width: 700px;\" /\u003e\r\n\u003c/div\u003e\r\n\r\nLyra is a Python library for parsing and transforming JSON-based forms into Python code. It provides tools to parse form definitions and generate corresponding Python code, facilitating the handling of data from the Climate Data Store (CDS) in Python applications.\r\n\r\n## Installation\r\n\r\nTo install Lyra, clone the repository and install the required dependencies:\r\n\r\n```sh\r\ngit clone https://github.com/joangq/lyra\r\ncd lyra\r\npip install -r requirements.txt\r\n```\r\n\r\n## Usage\r\n\r\nHere's a simple example of how to use Lyra to download data using the `cds_collections` module:\r\n\r\n```python\r\nfrom lyra import cds_collections\r\n\r\ncds_collections.reanalysis_era5_single_levels.download(\r\n    product_type = \"reanalysis\",\r\n    data_format  = \"netcdf\",\r\n    variable     = \"2m_temperature\",\r\n    year         = \"2020\",\r\n    month        = \"01\",\r\n    day          = \"01\",\r\n    time         = \"12:00\",\r\n)\r\n```\r\n\r\nThis example demonstrates how to use the generated functions in `cds_collections` to request data directly from the CDS and save it to a file.\r\n\r\n## How It Works\r\n\r\nLyra processes JSON form definitions from the CDS and transforms them into Python code that can be used to interact with the CDS API. The process involves three main components:\r\n\r\n- **Parser**: The parser, implemented in `lyra.parser`, reads the JSON form definitions and creates an abstract syntax tree (AST) representation.\r\n\r\n- **Transformer**: The transformer, found in `lyra.transformer`, takes the AST and transforms it into an intermediate representation suitable for code generation.\r\n\r\n- **Translator**: The translator, located in `lyra.translator`, generates Python code from the intermediate representation, producing a set of functions that mirror the data request forms on the CDS.\r\n\r\nThis automated process allows users to interact with the CDS programmatically, without having to manually construct API requests.\r\n\r\n## Repository Structure\r\n\r\nThe Lyra repository is organized as follows:\r\n\r\n```python\r\nLyra/\r\n├── src/                     # Main code (notebooks + library)\r\n│   └── lyra/                # Library code\r\n│       ├── parser/          # - JSON Form to AST parser\r\n│       ├── transformer/     # - AST to intermediate representation\r\n│       ├── translator/      # - IR to Python code (target cds_collections/)\r\n│       ├── cds_collections/ # - Autogenerated target\r\n│       └── auth/            # - Wrapper for dotenv-based authentication\r\n├── data/                    # Example forms from the CDS.\r\n├── tests/                   # Unit tests\r\n├── assets/                  # Graphical assets\r\n└── .env                     # Expected environament variables file.\r\n```\r\n\r\n---\r\n\u003cdiv align='right'\u003e\r\n\u003cp xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dct=\"http://purl.org/dc/terms/\"\u003e\u003ca property=\"dct:title\" rel=\"cc:attributionURL\" href=\"https://github.com/joangq/lyra\"\u003elyra\u003c/a\u003e by \u003ca rel=\"cc:attributionURL dct:creator\" property=\"cc:attributionName\" href=\"https://github.com/joangq\"\u003eJoan Gonzalez\u003c/a\u003e is licensed under \u003ca href=\"https://creativecommons.org/licenses/by/4.0/?ref=chooser-v1\" target=\"_blank\" rel=\"license noopener noreferrer\" style=\"display:inline-block;\"\u003eCC BY 4.0\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1\" alt=\"\"\u003e\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1\" alt=\"\"\u003e\u003c/a\u003e\u003c/p\u003e\r\n\u003c/div\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoangq%2Flyra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoangq%2Flyra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoangq%2Flyra/lists"}