dictrack is a powerful dictionary tracking tool designed for condition-based monitoring and management. At its core, dictrack allows developers to easily track and handle dynamic data using flexible components such as conditions, targets, and limiters. It supports various data sources (e.g., Redis, MongoDB) and offers advanced mechanisms for data caching and persistence.
- Multi-Target Support: Track multiple targets simultaneously with customizable logic.
- Condition-Based Filtering: Easily define conditions like key existence, value comparisons, or custom rules.
- Flexible Limiting: Use built-in limiters such as
CountLimiterorTimeLimiterto control task execution. - Data Caching & Persistence: Integrate
Redisfor caching andMongoDBfor long-term storage. - Event System: Includes events like
LIMITED,STAGE_COMPLETED, andALL_COMPLETEDfor fine-grained tracking. - Extensible Design: Add custom conditions, targets, or limiters to adapt to unique requirements.
- Python 2 & 3 Compatibility: Seamlessly supports both Python 2.7 and 3.7+ environments.
Install the latest version of dictrack via pip:
pip install dictrackIf you need additional components, you can install dictrack with optional dependencies:
pip install dictrack[redis]pip install dictrack[mongodb]pip install dictrack[gevent]pip install dictrack[memory]Here’s a simple example to get you started:
from dictrack.conditions.keys import KeyValueEQ
from dictrack.data_caches.redis import RedisDataCache
from dictrack.data_stores.mongodb import MongoDBDataStore
from dictrack.manager import TrackingManager
from dictrack.trackers.numerics.count import CountTracker
# Initialize tracker manager
manager = TrackingManager(
RedisDataCache(host="redis"),
MongoDBDataStore(host="mongodb"),
)
# Add a tracker with conditions
tracker = CountTracker(
name="Demo-1",
conditions=[KeyValueEQ(key="status", value="active")],
target=10,
)
group_id = "Robot001"
manager.add_tracker(group_id=group_id, tracker=tracker)
# Feed data into the manager
data = {"id": 1, "status": "active"}
# Process data based on the condition
manager.track(group_id=group_id, data=data)
# Check results
print(manager.get_trackers(group_id=group_id, name="Demo-1"))
>>>[<CountTracker (target=10 conditions=set([<KeyValueEQ (key=status operator=eq value=active)>]) limiters=set([]) group_id=Robot001 name=Demo-1 progress=1)>]To build the documentation locally, you can use the provided script:
-
Ensure you have the required dependencies installed:
pip install .[docs]
-
Run the documentation build script:
./docs.sh
This script will:
- Install the package in editable mode.
- Generate API documentation source files using
sphinx-apidoc. - Build the HTML documentation using Sphinx.
- Start a local server to preview the documentation at
http://localhost:8000.
The documentation is built using Sphinx and hosted on Read the Docs.
This project is licensed under the MIT License.
2.1.5 - 2025-08-06
- fix: Return tracker as a single-item list for consistency (#43)
2.1.4 - 2025-08-02
- feat: add KeyValueInList and related classes for list-based checks (#40)
- feat: filter out None values during tracker deserialization process (#41)
2.1.3 - 2025-05-19
- feat: validate count limits and improve reset logic for limiters (#38)
2.1.2 - 2025-05-14
- fix: python 2 syntax issue (#36)
2.1.1 - 2025-05-09
- perf: enhance
CountLimiter__repr__output (#34)
- fix: correct reset logic and parameter handling (#33)
2.1.0 - 2025-05-08
- Improve reset flow (#31)
2.0.10 - 2025-02-17
- Fixed tuple nesting issue in type validation (#29)
2.0.9 - 2025-02-13
- Fixed stale data check failure in Python 3 (#27)
2.0.8 - 2025-02-11
- Tracker now supports modifying progress (#25)
2.0.7 - 2025-01-20
- Tracker now support adding new targets (#23)
2.0.6 - 2025-01-08
- Fixed misuse of
timedelta.secondsinTimeLimiter(#21)
YANKED 2.0.5 - 2025-01-06
TimeLimitercomponent does not function as expected
- Enhanced compatibility with older
redis-pyversions (#19)
- Fixed misuse of
timedelta.secondsinTimeLimiter(#17)
YANKED 2.0.4 - 2024-12-14
TimeLimitercomponent does not function as expected
- Modified
pymongoversion restriction from >=4.10.1 to >=3.0 in Python3.7+
YANKED 2.0.3 - 2024-12-14
TimeLimitercomponent does not function as expected
- Added new condition components:
KeyValueContainedKeyValueNotContainedKeyNotExistsKeyValueNE
- Added
pytestunit test code for conditions and limiters
- Modified
pre_track()andpost_track()param name, frompre_track/post_tracktopre_tracker/post_trackerinCountLimiterandTimeLimiter.
- Fixed
CountLimiterthatlimiteddid not work correctly
YANKED 2.0.2 - 2024-11-19
TimeLimitercomponent does not function as expected
- Fixed
MongoDBDataStoreflush process, usingdelete_many()instead ofdrop()
YANKED 2.0.1 - 2024-11-14
TimeLimitercomponent does not function as expected
- Added new parameter
strictthat performs strict type for data cache and data store.
YANKED 2.0.0 - 2024-11-08
TimeLimitercomponent does not function as expected
BRAND NEW data system, adding data cache & data store, data cache for tracking, data store for permanently storing
- Added data cache components
RedisDataCacheMemoryDataCache
- Added data store component
MongoDBDataStore
- Added limiter components
CountLimiterTimeLimiter
- Tracker now support multi-targets and loop forever mode
- Added new event
LIMITED/STAGE_COMPLETED/ALL_COMPLETED
1.1.0 - 2024-10-27
- Added MIT License
- Fixed
RedisDataStorenot working caused from missing pipeline execution
RedisDataStore component does not function as expected
Build failure for Python 2.7