Skip to main content

Dynamic Profile Processing Platform

Project description

Dynamic Profile Processing Platform (DP³)

DP3

PyPI version

DP³ is a platform helps to keep a database of information (attributes) about individual entities (designed for IP addresses and other network identifiers, but may be anything), when the data constantly changes in time.

You can read more about how it works in the documentation.

This is a basis of CESNET's "Asset Discovery Classification and Tagging" (ADiCT) project, focused on discovery and classification of network devices, but the platform itself is general and should be usable for any kind of data.

DP³ doesn't do much by itself, it must be supplemented by application-specific modules providing and processing data.

Repository structure

  • dp3 - Python package containing code of the processing core and the API
  • config - default/example configuration
  • install - deployment configuration

See the documentation for more details.

Installation

See the docs for more details.

Installing for application development

Pre-requisites: Python 3.9 or higher, pip (with virtualenv installed), git, Docker and Docker Compose.

Create a virtualenv and install the DP³ platform using:

python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install git+https://github.com/CESNET/dp3.git#egg=dp-cubed

Creating a DP³ application

DP³ comes with a dp3 utility, which is used to create a new DP³ application and run it. To create a new DP³ application we use the setup command. Run:

dp3 setup <application_directory> <your_application_name> 

So for example, to create an application called my_app in the current directory, run:

dp3 setup . my_app

Which produces a template DP3 application directory structure.

Running the Application

To run the application, we first need to setup the other services the platform depends on, such as the MongoDB database, the RabbitMQ message distribution and the Redis database. This can be done using the supplied docker-compose.yml file. Simply run:

docker compose up -d --build

There are two main ways to run the application itself. First is a little more hand-on, and allows easier debugging. There are two main kinds of processes in the application: the API and the worker processes.

To run the API, simply run:

APP_NAME=my_app CONF_DIR=config dp3 api

The starting configuration sets only a single worker process, which you can run using:

dp3 worker my_app config 0     

The second way is to use the docker-compose.app.yml file, which runs the API and the worker processes in separate containers. To run the API, simply run:

docker compose -f docker-compose.app.yml up -d --build

Either way, to test that everything is running properly, you can run:

curl -X 'GET' 'http://localhost:5000/' \
     -H 'Accept: application/json' 

Which should return a JSON response with the following content:

{
   "detail": "It works!"
}

Final note, to simplify the experience of adjusting the app configuration, especially that of the DB entities, we provide the dp3 check command. The command simply loads the configuration and checks that it is valid, but if not, it tries really hard to pinpoint where exactly you went wrong. This can be used as follows:

dp3 check <config_directory>

You are now ready to start developing your application!

Installing for platform development

Pre-requisites: Python 3.9 or higher, pip (with virtualenv installed), git, Docker and Docker Compose.

Pull the repository and install using:

git clone --branch master git@github.com:CESNET/dp3.git dp3 
cd dp3
python3 -m venv venv
source venv/bin/activate  
python -m pip install --upgrade pip  
pip install --editable ".[dev]" 
pre-commit install

Running the dependencies and the platform

The DP³ platform is now installed and ready for development. To run it, we first need to setup the other services the platform depends on, such as the MongoDB database, the RabbitMQ message distribution and the Redis database. This can be done using the supplied docker-compose.yml file. Simply run:

docker compose up -d --build

After the first compose up command, the images for RabbitMQ, MongoDB and Redis will be downloaded, their images will be built according to the configuration and all three services will be started. On subsequent runs, Docker will use the cache, so if the configuration does not change, the download and build steps will not be repeated.

The configuration is taken implicitly from the docker-compose.yml file in the current directory. The docker-compose.yml configuration contains the configuration for the services, as well as a testing setup of the DP³ platform itself. The full configuration is in tests/test_config. The setup includes one worker process and one API process to handle requests. The API process is exposed on port 5000, so you can send requests to it using curl or from your browser:

curl -X 'GET' 'http://localhost:5000/' \
     -H 'Accept: application/json' 
curl -X 'POST' 'http://localhost:5000/datapoints' \
     -H 'Content-Type: application/json' \
     --data '[{"type": "test_entity_type", "id": "abc", "attr": "test_attr_int", "v": 123, "t1": "2023-07-01T12:00:00", "t2": "2023-07-01T13:00:00"}]'

Testing

With the testing platform setup running, we can now run tests. Tests are run using the unittest framework and can be run using:

python -m unittest discover \
       -s tests/test_common \
       -v
CONF_DIR=tests/test_config \
python -m unittest discover \
       -s tests/test_api \
       -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dp_cubed-0.9.0.tar.gz (410.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dp_cubed-0.9.0-py3-none-any.whl (163.4 kB view details)

Uploaded Python 3

File details

Details for the file dp_cubed-0.9.0.tar.gz.

File metadata

  • Download URL: dp_cubed-0.9.0.tar.gz
  • Upload date:
  • Size: 410.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for dp_cubed-0.9.0.tar.gz
Algorithm Hash digest
SHA256 6b60dbb136b894309b909508054ec64b13f237d2dc8c4d18f9542aced85dfbce
MD5 5449ea6314e1b80845c7b20756ae2381
BLAKE2b-256 c277f1fdf5101ff8eb137162668672a35f712ee2dcaa57323fee3e0136ca8dcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for dp_cubed-0.9.0.tar.gz:

Publisher: release.yml on CESNET/dp3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dp_cubed-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: dp_cubed-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 163.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for dp_cubed-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b893850893f362549fa0d284379dc74ffc490c19fbbae965d460086f66d5f75
MD5 cd2c5b3599a31a53ee80fdc9e609527d
BLAKE2b-256 bbab9bcad11b6a01c57416b5700a965d99c03b09b64a561ea2c543b4496e6d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for dp_cubed-0.9.0-py3-none-any.whl:

Publisher: release.yml on CESNET/dp3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page