Package with general devops code
Project description
NLDCSC package
This package contains generic re-usable code.
Install the full package:
pip install nldcsc[all]
Package has several modules which can be installed separately by specifying them as an extra requirement. To install the loggers module only, specify:
pip install nldcsc[loggers]
Or for multiple modules:
pip install nldcsc[loggers, flask_managers]
Modules
The following modules are available in the nldcsc package:
- auth
- datatables
- flask_managers
- flask_middleware
- flask_plugins
- http_apis
- loggers
- sql_migrations
Loggers
There are two loggers provided:
- AppLogger (nldcsc.loggers.app_logger.AppLogger)
- GunicornLogger (nldcsc.loggers.app_logger.GunicornLogger)
The AppLogger is intended to be used as a loggerClass to be used for the standard python logging module.
import logging
from nldcsc.loggers.app_logger import AppLogger
logging.setLoggerClass(AppLogger)
mylogger = logging.getLogger(__name__)
The 'mylogger' instance has all the proper formatting and handlers (according to the desired config) to log messages.
The Gunicorn logger is intended to be used for as a loggerClass for the gunicorn webserver; it enables the FlaskAppManager to set the necessary formatting and handles according to the AppLogger specs and a custom format for the gunicorn access logging.
Flask app manager
The FlaskAppManager is intended to be used to 'run' flask applications in both test, development as in production environments.
from YADA import app
from nldcsc.flask_managers.flask_app_manager import FlaskAppManager
fam = FlaskAppManager(version="1.0", app=app)
fam.run()
Depending on the configuration the FlaskAppManager uses a werkzeug (DEBUG == True) or a gunicorn webserver. TLS could be set for both webservers iaw the module specific README.md.
HTTP apis
Baseclass for http api communication is present under nldcsc.http_apis.base_class.api_base_class.ApiBaseClass
SQL Migrations
The sql migrations can be used to facilitate migration between different versions of sql models / versions. It relies on flask migrate to perform the different migrations. It has a CLI as well as an python class based API.
Check the command line help
python3 -m nldcsc.sql_migrations.flask_sql_migrate -a /path/to/script_with_flask_app.py -i
python3 -m nldcsc.sql_migrations.flask_sql_migrate -a /path/to/script_with_flask_app.py -m
python3 -m nldcsc.sql_migrations.flask_sql_migrate -a /path/to/script_with_flask_app.py -u
Or initiate the FlaskSqlMigrate as a class and initiate the migration process from there:
from nldcsc.sql_migrations.flask_sql_migrate import FlaskSqlMigrate
fsm = FlaskSqlMigrate(app_ref="/path/to/script_with_flask_app.py")
fsm.db_init()
fsm.db_migrate()
fsm.db_update()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nldcsc-0.2.47.tar.gz
.
File metadata
- Download URL: nldcsc-0.2.47.tar.gz
- Upload date:
- Size: 74.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8055f6130182f5cf6347a35c6346ec316f54eec8045bbab970ccd403dfbd1263 |
|
MD5 | ed27b3c033ef2b3e01644cc56c088ef7 |
|
BLAKE2b-256 | 7ef5a4f0f73a667236566aea89f03be8ab951f2d7fde9acbf89227ff727db858 |
Provenance
The following attestation bundles were made for nldcsc-0.2.47.tar.gz
:
Publisher:
package_to_pypi.yaml
on NLDCSC/nldcsc
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
nldcsc-0.2.47.tar.gz
- Subject digest:
8055f6130182f5cf6347a35c6346ec316f54eec8045bbab970ccd403dfbd1263
- Sigstore transparency entry: 145844265
- Sigstore integration time:
- Predicate type:
File details
Details for the file nldcsc-0.2.47-py3-none-any.whl
.
File metadata
- Download URL: nldcsc-0.2.47-py3-none-any.whl
- Upload date:
- Size: 86.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 987f38f3ebd51a1e38da2e771ba72435d2f19494a6ca45257fe18df221ccdc12 |
|
MD5 | f8fcf87ead0f6a3b1d53c84a7dae1695 |
|
BLAKE2b-256 | 9ecb386589f0ec5cc3845d6d622bfa17c946ad9b639ebcb47dfeb0c26d8f3029 |
Provenance
The following attestation bundles were made for nldcsc-0.2.47-py3-none-any.whl
:
Publisher:
package_to_pypi.yaml
on NLDCSC/nldcsc
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
nldcsc-0.2.47-py3-none-any.whl
- Subject digest:
987f38f3ebd51a1e38da2e771ba72435d2f19494a6ca45257fe18df221ccdc12
- Sigstore transparency entry: 145844269
- Sigstore integration time:
- Predicate type: