{"id":21848974,"url":"https://github.com/ispyb/ispyb-models","last_synced_at":"2025-04-14T14:42:14.057Z","repository":{"id":45736061,"uuid":"513509275","full_name":"ispyb/ispyb-models","owner":"ispyb","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-24T09:36:28.000Z","size":133,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-04T12:04:21.513Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ispyb.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-13T12:18:02.000Z","updated_at":"2023-12-19T13:37:47.000Z","dependencies_parsed_at":"2023-02-13T19:47:43.003Z","dependency_job_id":null,"html_url":"https://github.com/ispyb/ispyb-models","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ispyb%2Fispyb-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ispyb","download_url":"https://codeload.github.com/ispyb/ispyb-models/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248898573,"owners_count":21179796,"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":[],"created_at":"2024-11-28T00:09:49.261Z","updated_at":"2025-04-14T14:42:14.035Z","avatar_url":"https://github.com/ispyb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This provides a set of [SQLAlchemy](https://www.sqlalchemy.org/) ORM models for the [ISPyB database](https://github.com/ispyb/ispyb-database/).\n\n## Installation\n\nInstall from pypi [ispyb-models](https://pypi.org/project/ispyb-models):\n\n```bash\npip install ispyb-models\n```\n\n## Basic Usage\n\n```python\nfrom ispyb import models\n\ndataCollection = models.DataCollection(\n    ...\n)\n\nses.add(dataCollection)\nses.commit()\n\n...\n\ndatacollections = (\n    ses.query(\n        models.DataCollection\n    ).filter(models.DataCollection.dataCollectionId == 1)\n    ).first()\n)\n```\n\n## Generate a new version\n\nTo update the models you need to run the workflow `Update Models` through GitHub Actions panel.\nThis will create a new branch with models matching the latest DB release and create a pull request for merge this branch into main. Before merging there are some things you need to do:\n\n-   Make sure py-ispyb tests still pass with these new models\n-   Update `HISTORY.md` to reflect the changes\n-   Bump version number with `bump2version`\n\n### ⚠️ Do not edit the output file yourself\n\n**The resulting `_auto_db_schema.py` should not be edited** (other than automatic\nformatting with `black` or sorting of imports with `isort`). All models are imported\ninto and accessed via the `__init__.py`. Any modifications, e.g. injecting additional\nrelationships between models should be done here.\n\n### ⚠️ _[for local test]_ Manually update the DB schema\n\nCheckout the specific tag for a given `ispyb-database` version:\n\n```bash\n$ git clone -b v1.18.1 https://github.com/ispyb/ispyb-database.git\n$ # or, if you have an existing copy of the repository:\n$ git checkout v1.18.1\n```\n\nApply the schema patch in `patches/circular_references.patch` to avoid circular foreign key references:\n\n```bash\n$ patch -p1 \u003c ispyb-models/patches/circular_references.patch\n```\n\nThen run the `ispyb-database` `build.sh` script to generate the database:\n\n```bash\n$ sh build.sh\n```\n\nGenerate the models with [sqlacodegen](https://pypi.org/project/sqlacodegen/)\nin `src/ispyb/models/`:\n\n```bash\n. generate_models.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispyb%2Fispyb-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fispyb%2Fispyb-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispyb%2Fispyb-models/lists"}