Package with general devops code
Project description
CCDCOE package
This package contains generic re-usable code.
Install the full package:
pip install ccdcoe[all]
Package has several modules which can be installed separately by specifying them as an extra requirement. To install the http_apis module only, specify:
pip install ccdcoe[http_apis]
Or for multiple modules:
pip install ccdcoe[http_apis, loggers]
Adding modules and/or groups
Everything for this package is defined in the pyproject.toml file. Dependencies are managed by poetry and grouped in, you guessed it, groups. Every poetry group can be installed as an extra using pip.
Extra extras or group on group/extra dependencies can also be defined in the [tool.ccdcoe.group.dependencies] section. Everything defined here will also become an extra if no group already exists. You can use everything defined here as dependency for another group, order does not matter.
example:
[tool.ccdcoe.group.dependencies]
my_awesome_extra = ["my_awesome_group", "my_other_group"]
my_awesome_group = ["my_logging_group"]
[tool.poetry.group.my_awesome_group.dependencies]
<dependency here>
[tool.poetry.group.my_other_group.dependencies]
<dependency here>
[tool.poetry.group.my_logging_group.dependencies]
<dependency here>
Using this example the following extras exist with the correct dependencies:
pip install ccdcoe[all]
pip install ccdcoe[my-awesome-extra]
pip install ccdcoe[my-awesome-group]
pip install ccdcoe[my-other-group]
pip install ccdcoe[my-logging-group]
Modules
The following modules are available in the ccdcoe package:
- http_apis
- loggers
- dumpers
- deployments
- cli
- redis_cache
- flask_managers
- flask_middleware
- flask_plugins
- auth
- sso
- plugins
- sql_migrations
HTTP apis
Baseclass for http api communication is present under ccdcoe.http_apis.base_class.api_base_class.ApiBaseClass
Loggers
There are three loggers provided:
- ConsoleLogger (ccdcoe.loggers.app_logger.ConsoleLogger)
- AppLogger (ccdcoe.loggers.app_logger.AppLogger)
- GunicornLogger (ccdcoe.loggers.app_logger.GunicornLogger)
The ConsoleLogger is intended as a loggerClass for cli applications.
The AppLogger is intended to be used as a loggerClass to be used for the standard python logging module.
import logging
from ccdcoe.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 ccdcoe.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.
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 ccdcoe.sql_migrations.flask_sql_migrate -a /path/to/script_with_flask_app.py -i
python3 -m ccdcoe.sql_migrations.flask_sql_migrate -a /path/to/script_with_flask_app.py -m
python3 -m ccdcoe.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 ccdcoe.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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ccdcoe-0.0.19.tar.gz.
File metadata
- Download URL: ccdcoe-0.0.19.tar.gz
- Upload date:
- Size: 96.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a70e2be26749156c0289358e20b64991572ce122d7ca0c45de7d0728e3e9ea29
|
|
| MD5 |
d45a14b6a0b380439fa0d17174217da1
|
|
| BLAKE2b-256 |
3341420a7c2b97cd3bfbdc3e793c1e40db3087f83da6a822abc015d40c427bfc
|
Provenance
The following attestation bundles were made for ccdcoe-0.0.19.tar.gz:
Publisher:
package_to_pypi.yaml on ccdcoe/ccdcoe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ccdcoe-0.0.19.tar.gz -
Subject digest:
a70e2be26749156c0289358e20b64991572ce122d7ca0c45de7d0728e3e9ea29 - Sigstore transparency entry: 571033764
- Sigstore integration time:
-
Permalink:
ccdcoe/ccdcoe@6260ee06d9f3357d91f0fdd5c1c7375a9b8f67dc -
Branch / Tag:
refs/tags/v0.0.19 - Owner: https://github.com/ccdcoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package_to_pypi.yaml@6260ee06d9f3357d91f0fdd5c1c7375a9b8f67dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file ccdcoe-0.0.19-py3-none-any.whl.
File metadata
- Download URL: ccdcoe-0.0.19-py3-none-any.whl
- Upload date:
- Size: 116.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15db55d66c2c4d66bf26e0f1480b8e8ea88d1a1056089490e763848712e96b23
|
|
| MD5 |
dc76a8737a24a5599505f4c6d9a08f33
|
|
| BLAKE2b-256 |
b93f6a0393970a5ea95a0f294a18f8307cdf4298920a64e57ff55365d1042cc2
|
Provenance
The following attestation bundles were made for ccdcoe-0.0.19-py3-none-any.whl:
Publisher:
package_to_pypi.yaml on ccdcoe/ccdcoe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ccdcoe-0.0.19-py3-none-any.whl -
Subject digest:
15db55d66c2c4d66bf26e0f1480b8e8ea88d1a1056089490e763848712e96b23 - Sigstore transparency entry: 571033773
- Sigstore integration time:
-
Permalink:
ccdcoe/ccdcoe@6260ee06d9f3357d91f0fdd5c1c7375a9b8f67dc -
Branch / Tag:
refs/tags/v0.0.19 - Owner: https://github.com/ccdcoe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package_to_pypi.yaml@6260ee06d9f3357d91f0fdd5c1c7375a9b8f67dc -
Trigger Event:
push
-
Statement type: