ispyb-models-pyispyb


Nameispyb-models-pyispyb JSON
Version 1.2.6 PyPI version JSON
download
home_pagehttps://github.com/hormiai76/ispyb-models
SummarySQLAlchemy ORM models for the ISPyB database
upload_time2024-11-27 14:10:56
maintainerNone
docs_urlNone
authorISPyB
requires_python>=3.6
licenseApache License, Version 2.0
keywords ispyb database sqlalchemy
VCS
bugtrack_url
requirements sqlalchemy mysql-connector-python pytest black sqlacodegen
Travis-CI No Travis.
coveralls test coverage No coveralls.
            This provides a set of [SQLAlchemy](https://www.sqlalchemy.org/) ORM models for the [ISPyB database](https://github.com/ispyb/ispyb-database/).

## Installation

Install from pypi [ispyb-models](https://pypi.org/project/ispyb-models):

```bash
pip install ispyb-models
```

## Basic Usage

```python
from ispyb import models

dataCollection = models.DataCollection(
    ...
)

ses.add(dataCollection)
ses.commit()

...

datacollections = (
    ses.query(
        models.DataCollection
    ).filter(models.DataCollection.dataCollectionId == 1)
    ).first()
)
```

## Generate a new version

To update the models you need to run the workflow `Update Models` through GitHub Actions panel.
This 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:

-   Make sure py-ispyb tests still pass with these new models
-   Update `HISTORY.md` to reflect the changes
-   Bump version number with `bump2version`

### ⚠️ Do not edit the output file yourself

**The resulting `_auto_db_schema.py` should not be edited** (other than automatic
formatting with `black` or sorting of imports with `isort`). All models are imported
into and accessed via the `__init__.py`. Any modifications, e.g. injecting additional
relationships between models should be done here.

### ⚠️ _[for local test]_ Manually update the DB schema

Checkout the specific tag for a given `ispyb-database` version:

```bash
$ git clone -b v1.18.1 https://github.com/ispyb/ispyb-database.git
$ # or, if you have an existing copy of the repository:
$ git checkout v1.18.1
```

Apply the schema patch in `patches/circular_references.patch` to avoid circular foreign key references:

```bash
$ patch -p1 < ispyb-models/patches/circular_references.patch
```

Then run the `ispyb-database` `build.sh` script to generate the database:

```bash
$ sh build.sh
```

Generate the models with [sqlacodegen](https://pypi.org/project/sqlacodegen/)
in `src/ispyb/models/`:

```bash
. generate_models.sh
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hormiai76/ispyb-models",
    "name": "ispyb-models-pyispyb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "ISPyB, database, SQLAlchemy",
    "author": "ISPyB",
    "author_email": "py-ispyb-dev@esrf.fr",
    "download_url": "https://files.pythonhosted.org/packages/88/52/cbfa1935b70e955744c83b170dedabcb8db9867a1dd385e662f76895ec1e/ispyb-models-pyispyb-1.2.6.tar.gz",
    "platform": null,
    "description": "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### \u26a0\ufe0f 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### \u26a0\ufe0f _[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 < 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",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "SQLAlchemy ORM models for the ISPyB database",
    "version": "1.2.6",
    "project_urls": {
        "Homepage": "https://github.com/hormiai76/ispyb-models"
    },
    "split_keywords": [
        "ispyb",
        " database",
        " sqlalchemy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2df25077af0c68220f9abb4eb4f4d01d879e19ae2c2d7456bff991d36d983b5b",
                "md5": "b2bd77617ff8d9c07c879b04a8613241",
                "sha256": "740d02c30cabda77987d6dc43185f050fab9f3b3b82670ae13187e19902114a8"
            },
            "downloads": -1,
            "filename": "ispyb_models_pyispyb-1.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b2bd77617ff8d9c07c879b04a8613241",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 36788,
            "upload_time": "2024-11-27T14:10:55",
            "upload_time_iso_8601": "2024-11-27T14:10:55.524282Z",
            "url": "https://files.pythonhosted.org/packages/2d/f2/5077af0c68220f9abb4eb4f4d01d879e19ae2c2d7456bff991d36d983b5b/ispyb_models_pyispyb-1.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8852cbfa1935b70e955744c83b170dedabcb8db9867a1dd385e662f76895ec1e",
                "md5": "86a0f203936d9ca4d2d23e47ecbb8813",
                "sha256": "310cf200399f084fde16e4477dc814454124955ce23a49978a7d456c60b6eaf4"
            },
            "downloads": -1,
            "filename": "ispyb-models-pyispyb-1.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "86a0f203936d9ca4d2d23e47ecbb8813",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 37278,
            "upload_time": "2024-11-27T14:10:56",
            "upload_time_iso_8601": "2024-11-27T14:10:56.577012Z",
            "url": "https://files.pythonhosted.org/packages/88/52/cbfa1935b70e955744c83b170dedabcb8db9867a1dd385e662f76895ec1e/ispyb-models-pyispyb-1.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-27 14:10:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hormiai76",
    "github_project": "ispyb-models",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "sqlalchemy",
            "specs": []
        },
        {
            "name": "mysql-connector-python",
            "specs": [
                [
                    "==",
                    "8.0.29"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "black",
            "specs": []
        },
        {
            "name": "sqlacodegen",
            "specs": []
        }
    ],
    "lcname": "ispyb-models-pyispyb"
}
        
Elapsed time: 0.76069s