stellaspark-utils


Namestellaspark-utils JSON
Version 2.4 PyPI version JSON
download
home_pagehttps://github.com/StellaSpark/stellaspark_utils
SummaryA collection of python utilities for StellaSpark Nexus Digital Twin
upload_time2025-02-11 14:59:42
maintainerStellaSpark
docs_urlNone
authorStellaSpark
requires_python<=3.12.9,>=3.7
licenseMIT
keywords stellaspark nexus utils calculation python
VCS
bugtrack_url
requirements pytz unidecode sqlalchemy psycopg2-binary
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [Nexus Digital Twin]:https://www.stellaspark.com/ 
[Pypi account]:https://pypi.org/account/register/


## Description
A collection of python utilities for StellaSpark [Nexus Digital Twin] technology. 
Ready to use for 3.7 >= python <= 3.12.9.


## Usage

```
from stellaspark_utils.db import get_indexes, DatabaseManager
from stellaspark_utils.text import parse_time_placeholders

# DatabaseManager is a wrapper around a SQLAlchemy engine to set working memomry and pool_size the DRY way.

# Example 1 instance with argument 'db_url'
db_url = "postgres://<user>:<password>@<host>:<port>/<name>"
db_manager = DatabaseManager(db_url=db_url, max_mb_mem_per_db_worker=64, engine_pool_size=2)

# Example 2 instance with argument 'db_settings'
db_settings = {"USER":"<user>", "PASSWORD":"<password>", "HOST":"<host>", "PORT":"<port>", "NAME":"<name>"}
db_manager = DatabaseManager(db_settings=db_settings, max_mb_mem_per_db_worker=64, engine_pool_size=2)

# This sql transaction is limited by working memory (max_mb_mem_per_db_worker):
result = db_manager.execute("<sql_query>").all()

# This is also limited by working memory:
with db_manager.get_connection() as connection:
    result = connection.execute("<sql_query>").all()

# This sql transaction is NOT limited by working memory, so please do not use.
result = db_manager.engine.execute("<sql_query>").all()
```


## Development

### Build using command line
```
cd <project_root>
docker-compose build stellaspark_utils
```

### Build and Run/debug using VS Code
1. Open this directory in VS Code
2. Or in 'Remote Explorer' (left top screen) choose 'New Dev Container'. Or click 'Open a Remote Window (left bottom screen) and then choose 'Reopen in Container'
3. Now edit 'run_helper_id' in main.py then run the code

### Autoformat code:
```
cd <project_root>
make_nice
```

### Test
```
cd <project_root>
pytest
```

##### Test coverage (release 2.4)
```
---------- coverage: platform linux, python 3.12.9-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
setup.py                       10     10     0%
stellaspark_utils/db.py       195    133    32%
stellaspark_utils/text.py     110     87    21%
-----------------------------------------------
TOTAL                         315    230    27%
```

### Release 

##### Preparation
1. Create a [Pypi account] and after registering, make sure your account has a pypi token
2. Update version in setup.py
3. Update the CHANGES.rst with a change message and release date of today
4. Optionally, autoformat code (see above)
5. Push changes to GitHub (preferably in a branch 'release_<x>_<y>')

##### Release manually
```
cd <project_root>
rmdir /s /q "dist"                                      # Remove dist dir (to avoid uploading old distributions)                       
pipenv shell                                            # Activate pipenv environnment (see 'Create an environment' above)
pip install twine                                       # Install twine (to upload package to pypi)
python setup.py sdist                                   # Create distribution (with a '.tar.gz' in it)
twine check dist/*                                      # Validate all distibutions in stellaspark_utils/dist
twine upload dist/*                                     # Upload distribution to pypi.org
# You will be prompted for a username and password: 
# - for the username, use __token__ (yes literally '__token__')
# - for the password, use the pypi token value, including the 'pypi-' prefix
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/StellaSpark/stellaspark_utils",
    "name": "stellaspark-utils",
    "maintainer": "StellaSpark",
    "docs_url": null,
    "requires_python": "<=3.12.9,>=3.7",
    "maintainer_email": "support@stellaspark.com",
    "keywords": "stellaspark, nexus, utils, calculation, python",
    "author": "StellaSpark",
    "author_email": "support@stellaspark.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/8a/56a58a41d26f506c61ef26fd103c0390577e3e5d5276fb1455052be33dae/stellaspark_utils-2.4.tar.gz",
    "platform": null,
    "description": "[Nexus Digital Twin]:https://www.stellaspark.com/ \r\n[Pypi account]:https://pypi.org/account/register/\r\n\r\n\r\n## Description\r\nA collection of python utilities for StellaSpark [Nexus Digital Twin] technology. \r\nReady to use for 3.7 >= python <= 3.12.9.\r\n\r\n\r\n## Usage\r\n\r\n```\r\nfrom stellaspark_utils.db import get_indexes, DatabaseManager\r\nfrom stellaspark_utils.text import parse_time_placeholders\r\n\r\n# DatabaseManager is a wrapper around a SQLAlchemy engine to set working memomry and pool_size the DRY way.\r\n\r\n# Example 1 instance with argument 'db_url'\r\ndb_url = \"postgres://<user>:<password>@<host>:<port>/<name>\"\r\ndb_manager = DatabaseManager(db_url=db_url, max_mb_mem_per_db_worker=64, engine_pool_size=2)\r\n\r\n# Example 2 instance with argument 'db_settings'\r\ndb_settings = {\"USER\":\"<user>\", \"PASSWORD\":\"<password>\", \"HOST\":\"<host>\", \"PORT\":\"<port>\", \"NAME\":\"<name>\"}\r\ndb_manager = DatabaseManager(db_settings=db_settings, max_mb_mem_per_db_worker=64, engine_pool_size=2)\r\n\r\n# This sql transaction is limited by working memory (max_mb_mem_per_db_worker):\r\nresult = db_manager.execute(\"<sql_query>\").all()\r\n\r\n# This is also limited by working memory:\r\nwith db_manager.get_connection() as connection:\r\n    result = connection.execute(\"<sql_query>\").all()\r\n\r\n# This sql transaction is NOT limited by working memory, so please do not use.\r\nresult = db_manager.engine.execute(\"<sql_query>\").all()\r\n```\r\n\r\n\r\n## Development\r\n\r\n### Build using command line\r\n```\r\ncd <project_root>\r\ndocker-compose build stellaspark_utils\r\n```\r\n\r\n### Build and Run/debug using VS Code\r\n1. Open this directory in VS Code\r\n2. Or in 'Remote Explorer' (left top screen) choose 'New Dev Container'. Or click 'Open a Remote Window (left bottom screen) and then choose 'Reopen in Container'\r\n3. Now edit 'run_helper_id' in main.py then run the code\r\n\r\n### Autoformat code:\r\n```\r\ncd <project_root>\r\nmake_nice\r\n```\r\n\r\n### Test\r\n```\r\ncd <project_root>\r\npytest\r\n```\r\n\r\n##### Test coverage (release 2.4)\r\n```\r\n---------- coverage: platform linux, python 3.12.9-final-0 -----------\r\nName                        Stmts   Miss  Cover\r\n-----------------------------------------------\r\nsetup.py                       10     10     0%\r\nstellaspark_utils/db.py       195    133    32%\r\nstellaspark_utils/text.py     110     87    21%\r\n-----------------------------------------------\r\nTOTAL                         315    230    27%\r\n```\r\n\r\n### Release \r\n\r\n##### Preparation\r\n1. Create a [Pypi account] and after registering, make sure your account has a pypi token\r\n2. Update version in setup.py\r\n3. Update the CHANGES.rst with a change message and release date of today\r\n4. Optionally, autoformat code (see above)\r\n5. Push changes to GitHub (preferably in a branch 'release_<x>_<y>')\r\n\r\n##### Release manually\r\n```\r\ncd <project_root>\r\nrmdir /s /q \"dist\"                                      # Remove dist dir (to avoid uploading old distributions)                       \r\npipenv shell                                            # Activate pipenv environnment (see 'Create an environment' above)\r\npip install twine                                       # Install twine (to upload package to pypi)\r\npython setup.py sdist                                   # Create distribution (with a '.tar.gz' in it)\r\ntwine check dist/*                                      # Validate all distibutions in stellaspark_utils/dist\r\ntwine upload dist/*                                     # Upload distribution to pypi.org\r\n# You will be prompted for a username and password: \r\n# - for the username, use __token__ (yes literally '__token__')\r\n# - for the password, use the pypi token value, including the 'pypi-' prefix\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A collection of python utilities for StellaSpark Nexus Digital Twin",
    "version": "2.4",
    "project_urls": {
        "Download": "https://github.com/StellaSpark/stellaspark_utils/archive/v2.4.tar.gz",
        "Homepage": "https://github.com/StellaSpark/stellaspark_utils"
    },
    "split_keywords": [
        "stellaspark",
        " nexus",
        " utils",
        " calculation",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f08a56a58a41d26f506c61ef26fd103c0390577e3e5d5276fb1455052be33dae",
                "md5": "e5c36ee657546977d350cebf51eeaec6",
                "sha256": "5ff93c4588d952bb42059b36b661a201d04d2b9f9674f78c996c32e42c5383f2"
            },
            "downloads": -1,
            "filename": "stellaspark_utils-2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e5c36ee657546977d350cebf51eeaec6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<=3.12.9,>=3.7",
            "size": 14338,
            "upload_time": "2025-02-11T14:59:42",
            "upload_time_iso_8601": "2025-02-11T14:59:42.891302Z",
            "url": "https://files.pythonhosted.org/packages/f0/8a/56a58a41d26f506c61ef26fd103c0390577e3e5d5276fb1455052be33dae/stellaspark_utils-2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-11 14:59:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "StellaSpark",
    "github_project": "stellaspark_utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pytz",
            "specs": []
        },
        {
            "name": "unidecode",
            "specs": []
        },
        {
            "name": "sqlalchemy",
            "specs": [
                [
                    "<",
                    "2.0"
                ]
            ]
        },
        {
            "name": "psycopg2-binary",
            "specs": []
        }
    ],
    "lcname": "stellaspark-utils"
}
        
Elapsed time: 0.57334s