Metadata-Version: 2.4
Name: base-api-utils
Version: 1.1.128
Summary: Django Rest Framework micro services common utilities
Author-email: Román Gutierrez <roman@tipit.net>, Sebastian Marcet <sebastian@tipit.net>
Project-URL: Homepage, https://github.com/fntechgit/base-api-utils
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: boto3
Requires-Dist: celery
Requires-Dist: Django>=3.2
Requires-Dist: django-celery-results
Requires-Dist: django-model-utils
Requires-Dist: django_filter
Requires-Dist: djangorestframework>=3.15.2
Requires-Dist: drf-spectacular
Requires-Dist: injector
Requires-Dist: oauthlib
Requires-Dist: pika
Requires-Dist: pybreaker
Requires-Dist: requests
Requires-Dist: requests-oauthlib
Provides-Extra: otel
Requires-Dist: opentelemetry-sdk>=1.38.0; extra == "otel"
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.38.0; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-logging; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-django; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-mysqlclient; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-redis; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-requests; extra == "otel"
Requires-Dist: opentelemetry-instrumentation-celery; extra == "otel"
Provides-Extra: dev
Requires-Dist: pytest==9.0.2; extra == "dev"
Requires-Dist: opentelemetry-sdk==1.44.0; extra == "dev"
Requires-Dist: opentelemetry-exporter-otlp-proto-http==1.44.0; extra == "dev"
Requires-Dist: opentelemetry-instrumentation-logging==0.65b0; extra == "dev"
Requires-Dist: opentelemetry-instrumentation-requests==0.65b0; extra == "dev"
Requires-Dist: opentelemetry-instrumentation-celery==0.65b0; extra == "dev"
Dynamic: license-file

# base-api-utils
DRF common utilities

## Virtual Env

````bash
$ python3 -m venv env

$ source env/bin/activate
````

## python setup

````bash
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get -y -f install python3.7 python3-pip python3.7-dev python3.7-venv libpython3.7-dev python3-setuptools
sudo -H pip3 --default-timeout=50 install --upgrade pip
sudo -H pip3 install virtualenv
````

## Install reqs

````
pip install -r requirements.txt
````

## Development dependencies

To install dev dependencies (e.g. `pytest`):

```bash
pip install -e ".[dev]"
```

## Packaging

Create ~/.pypirc:

```bash
[distutils]
index-servers =
    pypi

[pypi]
username = __token__
password = pypi-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

```

````bash
python3 -m pip install --upgrade build
python3 -m build
````
## Uploading 

```bash
python3 -m pip install --upgrade twine
```

### Test Py Pi

```bash
python3 -m twine upload --repository testpypi dist/*
```

## Production PyPi

```bash
python3 -m twine upload dist/*
```

## Install from testPyPi.Org
pip install -i https://test.pypi.org/simple/ base-api-utils --no-deps

## Install from GitHub

pip install git+https://github.com/fntechgit/base-api-utils

# Failed Celery Async Tasks Management

For a deep dive into the technical implementation, CLI usage, and troubleshooting steps, please refer to the dedicated management guide:

**[Management & Recovery Deep Dive: /docs/celery-management.md](./docs/celery-management.md)**

# Celery worker defaults

`base_api_utils.celery_worker.apply_worker_defaults` makes a worker acknowledge a task once it ends, so a task
whose worker dies is delivered again, and bounds each task and pool child:

**[Late acknowledgement, time limits and memory per child: /docs/celery-worker.md](./docs/celery-worker.md)**

# Logging and the OTLP log bridge

`base_api_utils.logging_config.build_logging` builds a service's `settings.LOGGING`, and
`base_api_utils.otel_logging.configure_otel_logging` ships its log records over OTLP:

**[Logging and the OTLP log bridge: /docs/logging.md](./docs/logging.md)**

A credential a service carries in its URLs under a name of its own, or in a path, is declared once
with `base_api_utils.url_credentials.declare_url_credentials`, and both the logs and the traces
redact it: [A service's own URL credentials](./docs/logging.md#a-services-own-url-credentials).

# Traces

`base_api_utils.otel_instrumentation`, `base_api_utils.tracing` and `base_api_utils.otel_celery`
give a service its traces, a root span for jobs and consumers, and the Celery worker hooks:

**[Traces, root spans and the Celery worker hooks: /docs/tracing.md](./docs/tracing.md)**
