Skip to main content

Domination

Real-time application made to monitor and dominate Humans.

From the rating of every human (from 1 to 100) sent to the kafka topic dominate, we detect, in real time, which type they are:

  • Sha if its rating is a multiple of 3
  • Dow if its rating is a multiple of 5
  • ShaDow if its rating is a multiple of 3 and 5
  • Incompatible if none of the above.

Using a new kafka topic shadow, we make the result available to a clickhouse table named shadow.

System Design

+----------------+               +-------------+            +------------------+
|  domination    |               |  dominate   |            | domination       |
+----------------+               +-------------+            +------------------+
| python         | +-----------> |             | +--------> | python           |
| Faust producer |               | Kafka topic |            | Faust agent      |
| HumanRatings   |               |             |            | HumanCategorized |
+----------------+               +-------------+            +------------------+
                                                                      +
      +---------------------------------------------------------------+
      v
+----------------+           +-------------------+           +-------------------+
|  shadow        |           | shadow_stream     |           |  shadow_consumer  |
+----------------+           +-------------------+           +-------------------+
|                | +------>  | clickhouse table  | +------>  | clickhouse table  |
|  Kafka topic   |           | encapsulate topic |           | materialized view |
+----------------+           +-------------------+           +-------------------+
                                                                      +
      +---------------------------------------------------------------+
      v
+-------------------+
|  shadow           |
+-------------------+
| clickhouse table  |
| store rows        |
+-------------------+

Structure of Kafka messages:

  • topic dominate: {"rating": <integer>, "unique_id": "<string>"}

  • topic shadow: {"type": <integer>, "unique_id": "<string>", "emit_timestamp": <datetime>}

Usage

Requirements

  • Python >= 3.6
  • docker-compose

Start domination

git clone https://github.com/AzemaBaptiste/domination.git && cd domination
virtualenv -p python3.8 venv && source venv/bin/activate
pip install domination
docker-compose up -d
./create_clickhouse_tables.sh

domination worker -l info

Explore data in a new terminal

docker exec -it clickhouse bin/bash -c "clickhouse-client --multiline"
   > SELECT COUNT(type) AS COUNT, type FROM shadow 
     GROUP BY type ORDER BY (COUNT) DESC LIMIT 10;

Stop domination

Ctrl + C (stop faust app)
docker-compose down

Run The Algorithm

You can also run The Algorithm as a standalone. It will print the type of every human rated from 1 to 1337.

python the_algorithm.py 

Development

# Install
virtualenv -p python3.8 venv
source venv/bin/activate
pip install -r requirements.txt
make install

# Build
make test # coverage tests
make linter # runs pylint
make build

Explore data

Open CLI of the clickhouse client

docker exec -it clickhouse bin/bash -c "clickhouse-client --multiline"

Description of clickhouse tables

shadow_stream: consumer of the kafka topic
CREATE TABLE IF NOT EXISTS shadow_stream
(
    `type` String,
    `unique_id` String,
    `emit_timestamp` DateTime
) ENGINE = Kafka()
  SETTINGS
    kafka_broker_list = 'kafka:29092',
    kafka_topic_list = 'shadow',
    kafka_group_name = 'shadow-group',
    kafka_format = 'JSONEachRow',
    kafka_skip_broken_messages = 1;
shadow: final table
CREATE TABLE shadow as shadow_stream
ENGINE = MergeTree()
PARTITION BY toYYYYMM(emit_timestamp)
ORDER BY type;
shadow_consumer: materialized view feeding the final table with the consumer table
CREATE MATERIALIZED VIEW shadow_consumer 
TO shadow
AS SELECT * FROM shadow_stream;

References

TODO

  • deploy package to pypi using github actions

Metadata

Release files for domination 1.2

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

Source distribution (sdist)

Source distribution for domination 1.2
File Size Uploaded Provenance Actions
domination-1.2.tar.gz 4.6 kB Without provenance Details for domination-1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for domination 1.2
File Interpreter ABI Platform Actions
domination-1.2-py3.8.egg Legacy Egg format - - Details for domination-1.2-py3.8.egg

Total release size: 12.6 kB

Release files / domination-1.2.tar.gz

Download URL domination-1.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7f7ccb098b27abdedb31ee57a62e3ba31b26e9e20cc551d14244e865ec6e7ef6
BLAKE2b-256 checksum
How to use checksums
f564fbbbf6fa56f37bc02f53b01e3d9be3280bb77de006a646531554a6b94eeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Release files / domination-1.2-py3.8.egg

Download URL domination-1.2-py3.8.egg
Size 8.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
59d4f3b797d0b7ad3bb0c866ec9432b0287b74b80988aa7b6bcc57201a70561e
BLAKE2b-256 checksum
How to use checksums
4d837ee47be3872f83438f4fb42c51e71bddce6cdd8918af785c6ca036dfd230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

Security for domination 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

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