Skip to main content

kabaret.flow_entities

A kabaret.flow extension providing searchable large collections of entities, stored in a mongodb.

Create your Entities

Entities are a queryable collection of objects.

In order to define an entity, you must inherit the Entity class and add some Property in it:

from kabaret.flow_entities.entities import Entity, Property

class Asset(Entity):

    asset_type = Property()
    asset_family = Property()
    
    status = Property()

You can also add classic relations like Param and Child and build a whole branch inside your entity. But keep in mind that the Propery relations will be the only ones usable in your queries.

Once you have an Entity defined, you must use it in an EntityCollection:

from kabaret.flow_entities.entities import EntityCollection, CreateEntitiesAction, DeleteEntitiesAction

class Assets(EntityCollection):

    # Those actions are provided for convenience,
    # you will probably want to define your owns:
    create_assets = flow.Child(CreateEntitiesAction)
    delete_assets = flow.Child(DeleteEntitiesAction)

    @classmethod
    def mapped_type(cls):
        # This tells which entity is show in 
        # this collection:
        return Asset

When using the Assets collection in your flow, the users will see a table with "Asset Type", "Asset Family" and "Status" columns.

This table is more efficient than a kabaret.flow.Map and can retrieve thousands of items in a fraction of seconds.

Still, the EntityCollection class inherits kabaret.flow.DynamicMap so you can use all the classic customization points (columns(), _fill_row_style(), etc...).

Filter your Entities

The EntityCollection.query_filter() method can be overidden to return a mongodb filter and restrict the list of displayed entities. You can for example decide to show only the Assets with a "WIP" status:

class Assets(EntityCollection):

    create_assets = flow.Child(CreateEntitiesAction)
    delete_assets = flow.Child(DeleteEntitiesAction)

    @classmethod
    def mapped_type(cls):
        return Asset

    def query_filter(self):
        """
        Listing only assets with a WIP status
        """ 
        return {"status": "WIP"}

Now you can add some Action and Param on your collection to control the returned value of query_filter().

Note that only the Property relations of your entity can be used in the filter !

The query filter must be a valid argument for a mongodb collection.find() call. Here is some documentation about it: https://docs.mongodb.com/manual/tutorial/query-documents/

Multiple Entity Views

The EntityCollection.collection_name() method can be overidden to point to another entity collection. This is usefull if you want to display some entities with a different query filter in different place of your flow.

Here is an example of showing only unfinished tasks assigned to the current user from a collection of tasks managed in an admin section of the project:

class MyTodo(EntityCollection):

    @classmethod
    def mapped_type(cls):
        # be sure to match the source
        # collection here:
        return AwesomeTask

    def collection_name(self):
        return self.root().project().admin.all_tasks.collection_name()
    
    def query_filter(self):
        return {
            "assignee": getpass.getuser(), 
            "status": {"$in": ["NYS", "WIP"]},
        }

MongoDB Connection

The entities are stored as documents in collections of a mongodb.

In order for your EntityCollection to connect to the database, you must add an EntityStore somewhere in your project and implement a get_entity_store() method on your project's root.

A classic aproach is to use an admin group in your project:

from kabaret.flow_entities.store import EntityStore

class Admin(flow.Object):

    entity_store = flow.Child(EntityStore)
    
class AwesomePipeline(flow.Object):

    admin = flow.Child(Admin)

    def get_entity_store(self):
        return self.admin.entity_store

The EntityStore has an uri param that you will need to set before showing or creating entity. The default value connects to a local mongodb database using the default port and options. Contact your beloved IT support team and ask them the value to use for production.

Here is a detailed documentation of the URI syntaxe: https://docs.mongodb.com/manual/reference/connection-string/

Demo

See kabaret.flow_entities.demo for more demo code.

Create a project with the type kabaret.flow_entities.demo.EntitiesDemo to see it in action.

Metadata

Release files for kabaret.flow_entities 1.1.1

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

Source distribution (sdist)

Source distribution for kabaret.flow_entities 1.1.1
File Size Uploaded Provenance Actions
kabaret_flow_entities-1.1.1.tar.gz 11.4 kB Without provenance Details for kabaret_flow_entities-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kabaret.flow_entities 1.1.1
File Interpreter ABI Platform Actions
kabaret_flow_entities-1.1.1-py3-none-any.whl Python 3 none any Details for kabaret_flow_entities-1.1.1-py3-none-any.whl

Total release size: 21.8 kB

Release files / kabaret_flow_entities-1.1.1.tar.gz

Download URL kabaret_flow_entities-1.1.1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5d9b187baaba7f9ff8aeb00d7629d72b67f7f925c571496414557ef28808dc98
BLAKE2b-256 checksum
How to use checksums
8cf5a2575f493ed1b4c8df3ca962e167432fb035c0a4a5a9724c279551510af1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kabaret_flow_entities-1.1.1-py3-none-any.whl

Download URL kabaret_flow_entities-1.1.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34695440220191b57c95dd75a35d4de6ef9478a46012fd84ece359e615711c36
BLAKE2b-256 checksum
How to use checksums
54d0c2ed9df9c64518838d590c8d4e8b33f8ed875f28ac9a36a8191c23127981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kabaret.flow_entities 1.1.1

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.

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