Skip to main content

django-olympus

[![build-status-image]][build-status] [![coverage-status-image]][codecov] [![pypi-version]][pypi]

Collect data from django models into ElasticSearch.

This Django application provides a OlympusCollector class that is a wrapper for the ElasticSearch API and database (using their official package).

To know more about how to use it, please check the Setup section.

Setup

After adding django-olympus as part of your required packages, add olympus to INSTALLED_APPS in your settings.py.

The following settings are available for customization:

Name Default Description
OLYMPUS_ELASTICSEARCH_URL None This should point to the ElasticSearch server running.
OLYMPUS_ELASTICSEARCH_VERIFY_CERTS None This should tell whether certificates should be verified - only set this to false for local development

Since this application provides a baseline Collector class, this will help you bootstrap data collectors to send information to ElasticSearch. The following section details how to write your own collectors.

Collectors

To create your own collector, in any Django app of your project, extend the OlympusCollector class and implement the collect method to specify all the logic you need.

#myapp/occ.py
from olympus.base import OlympusCollector


class SampleCollector(OlympusCollector):
    index_name = "sample_collector"  # can be anything you'd like.
    index_date_pattern = "%Y.%m.%d"  # can be anything you'd like.
    index_lifecycle_name = "something"  # if you use default lifecycle policies and would like to assign a different one.

    def collect(self):
        self.logger.info(f"started {self.index_name}")  # Base class provides built-in logging.

        data = some_func()  # Some logic to retrieve data, either from API, from Django's Database or whatever.

        yield = {
            "_id": "1",  # _id is mandatory and can be anything, really, as long as it is unique.
            "some": data.attribute,
            "more": data.attribute2,
        }

To keep collectors organized, you might want to create an occ.py file in each app, implementing the collectors. Each app can implement as many collectors as necessary, there is really no restrictions.

olympus API provides a Django command called push_to_es which allows you to run a collector. To run the sample above, ./manage.py push_to_es myapp.SampleCollector would be required.

Apps with collectors must be part of your settings.py file, otherwise collectors are not initialized and not added to the list - hence push_to_es will fail.

Metadata

Release files for django-olympus 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-olympus 0.0.7
File Size Uploaded
django_olympus-0.0.7.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-olympus 0.0.7
File Interpreter ABI Platform
django_olympus-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / django_olympus-0.0.7.tar.gz

Download URL django_olympus-0.0.7.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3461dc283a236c5407043b90827bb3255352e33086a6f9818bebac43e93612f9
BLAKE2b-256 checksum
How to use checksums
a7879662d05fc35491faceab8a2af51fbd863f5b4948fdaa7e9f06d154720946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / django_olympus-0.0.7-py3-none-any.whl

Download URL django_olympus-0.0.7-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f8c520ec6cfd9dc4c26ae168ad2f30e7465f0c8eb438f8f1aa2e29bac8cd4c2
BLAKE2b-256 checksum
How to use checksums
56a0699fcaabd8c59afe3176f466584557589182d3c3b189899b3f2b8866631a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page