Skip to content

Commit

Permalink
refactored logging config
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodolak committed Oct 1, 2021
1 parent 1f82d35 commit 1afff38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.1.0 (2021/09/30)
## 2.1.0 (2021/10/01)

- Updated logging and added `quiet_mode`
- Updated logging and set default log level to INFO
- Added `load_cache` static method to `Response` to load cached responses using cache key

## 2.0.0 (2021/09/11)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Introducing an element of randomness called `jitter` allows us to reduce the com
- `decorr` - decorrelated jitter is similar to `full` jitter but increases the maximum jitter based on the last random value, selecting the length of sleep by the minimum value between `max_sleep` and a random sample between the `base_backoff` and the last sleep value multiplied by 3.

## Caching

### Memory Safety

Memory safety allows us to reduce the amount of RAM used when requesting data, and can be enabled by setting `mem_safe=True` on a search method. This feature should be used if a large amount of data is being requested or if the machine in use has a limited amount of RAM.
Expand Down Expand Up @@ -159,7 +160,6 @@ A user-defined function can be provided using the `filter_fn` parameter for eith
- `checkpoint` (int, optional): Size of interval in batches to print a checkpoint with stats, defaults to 10
- `file_checkpoint` (int, optional): Size of interval in batches to cache responses when using mem_safe, defaults to 20
- `praw` (praw.Reddit, optional): Used to enrich the Pushshift items retrieved with metadata directly from Reddit
- `quiet_mode` (bool, optional): If true, only show set log level to WARN, defaults to INFO when False

### `Response`

Expand Down Expand Up @@ -358,7 +358,6 @@ resp = Response.load_cache(cache_key, cache_dir)

```


# Benchmarks

[Benchmark Notebook](https://github.com/mattpodolak/pmaw/blob/master/examples/benchmark.ipynb)
Expand Down
1 change: 0 additions & 1 deletion pmaw/PushshiftAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def __init__(self, *args, **kwargs):
checkpoint (int, optional) - Size of interval in batches to print a checkpoint with stats, defaults to 10
file_checkpoint (int, optional) - Size of interval in batches to cache responses when using mem_safe, defaults to 20
praw (praw.Reddit, optional) - Used to enrich the Pushshift items retrieved with metadata directly from Reddit
quiet_mode (bool, optional) - If true, only show set log level to WARN, defaults to INFO when False
"""
super().__init__(*args, **kwargs)

Expand Down
7 changes: 2 additions & 5 deletions pmaw/PushshiftAPIBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from pmaw.RateLimit import RateLimit
from pmaw.Request import Request

logging.basicConfig(level = logging.INFO, stream=sys.stdout)
log = logging.getLogger(__name__)


class PushshiftAPIBase(object):
_base_url = 'https://{domain}.pushshift.io/{{endpoint}}'

def __init__(self, num_workers=10, max_sleep=60, rate_limit=60, base_backoff=0.5,
batch_size=None, shards_down_behavior='warn', limit_type='average', jitter=None,
checkpoint=10, file_checkpoint=20, praw=None, quiet_mode=False):
checkpoint=10, file_checkpoint=20, praw=None):
self.num_workers = num_workers
self.domain = 'api'
self.shards_down_behavior = shards_down_behavior
Expand All @@ -28,9 +28,6 @@ def __init__(self, num_workers=10, max_sleep=60, rate_limit=60, base_backoff=0.5
self.file_checkpoint = file_checkpoint
self.praw = praw

log_level = logging.WARN if quiet_mode else logging.INFO
logging.basicConfig(level = log_level, stream=sys.stdout)

if batch_size:
self.batch_size = batch_size
else:
Expand Down

0 comments on commit 1afff38

Please sign in to comment.