From 0bf48f5f80672b5562a168ed71bdbfee5f0529f7 Mon Sep 17 00:00:00 2001 From: JM Vazquez Date: Sat, 17 Sep 2022 14:21:38 +0200 Subject: [PATCH] Release 0.1.9 (#11) --- CHANGELOG.md | 6 ++++++ README.md | 7 +++++-- docs/index.rst | 9 +++++---- docs/mongo.rst | 2 +- progress_updater/updater.py | 40 +++++++++++-------------------------- pyproject.toml | 2 +- 6 files changed, 30 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2e8c4..0deb4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ===================== +0.1.9 (2022-09-17) +------------------- + +- Documentation. + + 0.1.8 (2022-09-17) ------------------- diff --git a/README.md b/README.md index c330098..4fbd2fe 100644 --- a/README.md +++ b/README.md @@ -66,24 +66,27 @@ The available backends to store logs are **Mongo**, **Redis** and **SQL**. Please read the [docs](https://progress-updater.readthedocs.io/en/latest/) for further information. -Environment variables ------------------------ +Setting your backend with environment variables +-------------------------------------------------- You can set your backend by defining env vars. The `PU__` prefix indicates that it belongs to `ProgressUpdater`. ```shell # SQL PU__SQL_DSN='postgresql+psycopg2://user:pass@postgres:5432/db' PU__SQL_TABLE='logs' +... # Redis PU__REDIS_HOST='redis' PU__REDIS_DB='1' PU__REDIS_PASSWORD='pass' +... # Mongo PU__MONGO_CONNECTION='mongodb://user:pass@mongo:27017' PU__MONGO_DB='db' PU__MONGO_COLLECTION='logs' +... ``` And then when creating a `ProgressUpdater` object, the backend will be diff --git a/docs/index.rst b/docs/index.rst index 8c3fb55..b60ddd2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -62,25 +62,26 @@ The output is:: Backends ------------------- The available backends to store logs are **Mongo**, **Redis** and **SQL**. -Please read the [docs](https://progress-updater.readthedocs.io/en/latest/) -for further information. -Environment variables ------------------------ +Setting your backend with environment variables +--------------------------------------------------- You can set your backend by defining env vars. The `PU__` prefix indicates that it belongs to `ProgressUpdater`:: # SQL PU__SQL_DSN='postgresql+psycopg2://user:pass@postgres:5432/db' PU__SQL_TABLE='logs' + ... # Redis PU__REDIS_HOST='redis' PU__REDIS_DB='1' PU__REDIS_PASSWORD='pass' + ... # Mongo PU__MONGO_CONNECTION='mongodb://user:pass@mongo:27017' PU__MONGO_DB='db' PU__MONGO_COLLECTION='logs' + ... And then when creating a `ProgressUpdater` object, the backend will be diff --git a/docs/mongo.rst b/docs/mongo.rst index 8e824f2..27d5d14 100644 --- a/docs/mongo.rst +++ b/docs/mongo.rst @@ -16,4 +16,4 @@ Mongo Backend .. automodule:: progress_updater.backends.mongo :members: MongoLog - :exclude-members: mongo_collection, backend + :exclude-members: mongo_collection diff --git a/progress_updater/updater.py b/progress_updater/updater.py index a7efc62..f230ad4 100644 --- a/progress_updater/updater.py +++ b/progress_updater/updater.py @@ -14,8 +14,14 @@ class ProgressUpdater: Example: >>> from progress_updater import ProgressUpdater + >>> from progress_updater.backends import MongoSettings >>> - >>> updater = ProgressUpdater(task_name="My Task") + >>> settings = MongoSettings( + >>> mongo_connection="mongodb://user:pass@mongo:27017", + >>> mongo_db="db", + >>> mongo_collection="logs", + >>> ) + >>> updater = ProgressUpdater(task_name="My Task", settings=settings) >>> >>> with updater(block_name="First part") as updater: >>> # doing things @@ -31,32 +37,14 @@ class ProgressUpdater: **Backends** - There are three backends available to save our logs. - - 1. **Mongo**. `MongoSettings`. Parameters are: - - mongo_connection: str. Connection string - - mongo_db:m str. DB Name - - mongo_collection: str. Collection name. - - mongo_extras: dict. See extra arguments in Pymongo. - - 2. **Redis**. `RedisSettings`. Parameters are: - - sql_dsn: str. SQLAlchemy connection string. - - sql_table:m str. SQL Table Name. - - sql_extras: dict. See extra arguments for SQLAlchemy. - - 3. **SQL**. `SQLSettings`. Parameters are: - - redis_host. str. - - redis_port. int. - - redis_db. int. - - redis_password. str. - - redis_extras. dict. + There are three backends available to save our logs, + **Mongo**, **Redis** and **SQL**. **Settings.** - Different ways to pass settings to the `ProgressUpdater` with - priority order. + Different ways to pass settings to the `ProgressUpdater`. **1. Passing settings** as parameters when creating a `ProgressUpdater` - object: + object like in the above example: >>> from progress_updater import ProgressUpdater >>> from progress_updater import ProgressUpdater @@ -76,11 +64,7 @@ class ProgressUpdater: >>> redis_settings = RedisSettings( >>> redis_host="redis", redis_password="pass" >>> ) - >>> - >>> updater = ProgressUpdater( - >>> task_name="My Task", - >>> settings=mongo_settings - >>> ) + **2. Environment variables**. Set you setting parameters in your environment. The `PU__` prefix indicates that belongs to the diff --git a/pyproject.toml b/pyproject.toml index 012b44a..ca0f372 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "progress_updater" -version = "0.1.8" +version = "0.1.9" description = "Progress Updater" readme = "README.md" license = "LICENSE"