{"id":16003611,"url":"https://github.com/cmungall/basin3d_schema","last_synced_at":"2025-04-05T01:41:24.550Z","repository":{"id":66914326,"uuid":"539662689","full_name":"cmungall/basin3d_schema","owner":"cmungall","description":"EXPERIMENTAL","archived":false,"fork":false,"pushed_at":"2022-09-22T15:22:04.000Z","size":905,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T10:54:37.999Z","etag":null,"topics":["environmental-data","exemplar","linkml"],"latest_commit_sha":null,"homepage":"https://cmungall.github.io/basin3d_schema","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmungall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-09-21T19:56:41.000Z","updated_at":"2022-09-21T19:58:11.000Z","dependencies_parsed_at":"2023-05-13T23:00:21.927Z","dependency_job_id":null,"html_url":"https://github.com/cmungall/basin3d_schema","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmungall%2Fbasin3d_schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmungall%2Fbasin3d_schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmungall%2Fbasin3d_schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmungall%2Fbasin3d_schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmungall","download_url":"https://codeload.github.com/cmungall/basin3d_schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276096,"owners_count":20912287,"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":["environmental-data","exemplar","linkml"],"created_at":"2024-10-08T10:21:33.944Z","updated_at":"2025-04-05T01:41:24.530Z","avatar_url":"https://github.com/cmungall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# basin3d_schema\n\nEXPERIMENTAL rendering of basin3d as [linkml](https://linkml.io/linkml/)\n\n## Website\n\n* [https://cmungall.github.io/basin3d_schema](https://cmungall.github.io/basin3d_schema)\n\nThe above website is entirely generated from the source LinkML yaml files.\n\nThis generates pages for classes, including:\n\n * [Feature](https://cmungall.github.io/basin3d_schema/Feature/)\n\nVocabularies/enums, e.g.\n\n* [StatisticEnum](https://cmungall.github.io/basin3d_schema/StatisticEnum/)\n\nSlots/fields, e.g.\n\n* [observed_property](https://cmungall.github.io/basin3d_schema/observed_property/)\n\n## Repository Structure\n\n* [examples/](examples/) - example data\n* [project/](project/) - project files (generated: do not edit these)\n    * [jsonschema](jsonschema/) - JSON schema, for validating JSON documents\n    * [sqlschema](sqlschema/) - SQL DDL (CREATE TABLE statements)\n    * [jdonld](jsonld/) - JSON-LD Contexts\n    * [shacl](shacl/) - SHACL shape definitions (for RDF validation)\n* [src/](src/) - source files (edit these)\n    * [basin3d_schema](src/basin3d_schema)\n        * [schema](src/basin3d_schema/schema) -- LinkML schema (edit this)\n        * [datamodel](src/basin3d_schema/datamodel) -- Generated pydantic datamodel\n* [tests](tests/) - python tests\n\n## Usage\n\n```bash\npip install basin3d_schema\n```\n\n(^^ may not work if this is a new repo)\n\n### Creating Objects\n\nCreating objects via generated Pydantic model:\n\n```python\nfrom basin3d_schema.datamodel.core import Observation, MonitoringFeature, Coordinate, AbsoluteCoordinate,\n    GeographicCoordinate\n\ngeo_coord = GeographicCoordinate(x=-5, y=20)\nft = FeatureTypeEnum.WATERSHED\nfeat = MonitoringFeature(description=\"test\",\n                         coordinates=Coordinate(absolute=AbsoluteCoordinate(horizontal_position=[geo_coord])))\nobs = Observation(feature_of_interest=feat,\n                  feature_of_interest_type=ft)\nprint(obs.json(exclude_unset=True, indent=True))\n```\n\nGenerates:\n\n```json\n{\n \"feature_of_interest\": {\n  \"description\": \"test\",\n  \"coordinates\": {\n   \"absolute\": {\n    \"horizontal_position\": [\n     {\n      \"x\": -5.0,\n      \"y\": 20.0\n     }\n    ]\n   }\n  }\n }, \n  \"feature_of_interest_type\": \"WATERSHED\"\n}\n```\n\n### Validating Objects\n\nPydantic auto-validates by default\n\nE.g:\n\n```python\nac = AbsoluteCoordinate(horizontal_position=geo_coord)\n```\n\nraises an exception as a list is expected:\n\n```python\npydantic.error_wrappers.ValidationError: 1 validation error for AbsoluteCoordinate\nhorizontal_position\n  value is not a valid list (type=type_error.list)\n\n```\n\nSee [test_models](https://github.com/cmungall/basin3d_schema/blob/main/tests/test_model.py) in the unit tests for\nmore examples\n\n### Serialization/Deserialization\n\nPydantic objects naturally serialize/deserialize to JSON\n\nUsing the LinkML runtime framework it's possible to ser/de from:\n\n- SQL Databases\n- RDF\n- TSVs (with caveats)\n\n### Vocabularies\n\nSee the [generated enums page](https://cmungall.github.io/basin3d_schema/#enumerations)\n\nThe generated Python looks like:\n\n```python\nclass TimeFrequencyEnum(str, Enum):\n    \n    YEAR = \"YEAR\"\n    MONTH = \"MONTH\"\n    DAY = \"DAY\"\n    HOUR = \"HOUR\"\n    MINUTE = \"MINUTE\"\n    SECOND = \"SECOND\"\n```\n\nThe underlying schema is more granular:\n\n```yaml\nenums:\n  TimeFrequencyEnum:\n    permissible_values:\n      YEAR:\n        meaning: UO:0000036 ## year\n        unit:\n          ucum_code: a\n      MONTH:\n        meaning: UO:0000035 ## month\n        unit:\n          ucum_code: mo\n      DAY:\n        meaning: UO:0000033 ## day\n        unit:\n          ucum_code: d\n      HOUR:\n        meaning: UO:0000032 ## hour\n        unit:\n          ucum_code: h\n      MINUTE:\n        meaning: UO:0000031 ## minute\n        unit:\n          ucum_code: min\n      SECOND:\n        meaning: UO:0000010 ## second\n        unit:\n          ucum_code: s\n```\n\nThe additional metadata gives *interoperability hooks*\n\nBut using these is just like any normal Python enum\n\n```python\nTime(aggregation_duration=TimeFrequencyEnum.MONTH)\n```\n\n## Developer Documentation\n\n\u003cdetails\u003e\nUse the `make` command to generate project artefacts:\n\n- `make all`: make everything\n- `make deploy`: deploys site\n\n\u003c/details\u003e\n\n## About\n\nthis project was made with [linkml-project-cookiecutter](https://github.com/linkml/linkml-project-cookiecutter)\n\nMost of the content was autogenerated using semi-automated tools from the basin3 python codebase.\nAny mistakes are my own!\n\nThis is intended mainly for conversation starting purposes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmungall%2Fbasin3d_schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmungall%2Fbasin3d_schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmungall%2Fbasin3d_schema/lists"}