Skip to content

Commit

Permalink
chore: populate max_retries to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisborn committed May 22, 2024
1 parent 377bc2c commit 48eec7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
14 changes: 9 additions & 5 deletions paperscraper/get_dumps/biorxiv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dump bioRxiv data in JSONL format."""

import json
import os
from datetime import datetime
Expand All @@ -20,22 +21,25 @@ def biorxiv(
begin_date: Optional[str] = None,
end_date: Optional[str] = None,
save_path: str = save_path,
max_retries: int = 10,
):
"""Fetches papers from biorxiv based on time range, i.e., begin_date and end_date.
If the begin_date and end_date are not provided, papers will be fetched from biorxiv
from the launch date of biorxiv until the current date. The fetched papers will be
stored in jsonl format in save_path.
Args:
begin_date (str, optional): begin date expressed as YYYY-MM-DD.
Defaults to None, i.e., earliest possible.
end_date (str, optional): end date expressed as YYYY-MM-DD.
Defaults to None, i.e., today.
save_path (str, optional): Path where the dump is stored.
Defaults to save_path.
begin_date (Optional[str], optional): begin date expressed as YYYY-MM-DD.
Defaults to None.
end_date (Optional[str], optional): end date expressed as YYYY-MM-DD.
Defaults to None.
max_retries (int, optional): Number of retries when API shows connection issues.
Defaults to 10.
"""
# create API client
api = BioRxivApi()
api = BioRxivApi(max_retries=max_retries)

# dump all papers
with open(save_path, "w") as fp:
Expand Down
11 changes: 6 additions & 5 deletions paperscraper/get_dumps/chemrxiv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dump chemRxiv data in JSONL format."""

import logging
import os
import sys
Expand Down Expand Up @@ -28,11 +29,11 @@ def chemrxiv(
stored in jsonl format in save_path.
Args:
begin_date (Optional[str]): begin date expressed as YYYY-MM-DD.
Defaults to None.
end_date (Optional[str]): end date expressed as YYYY-MM-DD.
Defaults to None.
save_path (str): Path where the dump is stored.
begin_date (str, optional): begin date expressed as YYYY-MM-DD.
Defaults to None, i.e., earliest possible.
end_date (str, optional): end date expressed as YYYY-MM-DD.
Defaults to None, i.e., today.
save_path (str, optional): Path where the dump is stored.
Defaults to save_path.
"""

Expand Down
14 changes: 9 additions & 5 deletions paperscraper/get_dumps/medrxiv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dump medrxiv data in JSONL format."""

import json
import os
from datetime import datetime
Expand All @@ -18,22 +19,25 @@ def medrxiv(
begin_date: Optional[str] = None,
end_date: Optional[str] = None,
save_path: str = save_path,
max_retries: int = 10,
):
"""Fetches papers from medrxiv based on time range, i.e., begin_date and end_date.
If the begin_date and end_date are not provided, then papers will be fetched from
medrxiv starting from the launch date of medrxiv until current date. The fetched
papers will be stored in jsonl format in save_path.
Args:
begin_date (str, optional): begin date expressed as YYYY-MM-DD.
Defaults to None, i.e., earliest possible.
end_date (str, optional): end date expressed as YYYY-MM-DD.
Defaults to None, i.e., today.
save_path (str, optional): Path where the dump is stored.
Defaults to save_path.
begin_date (Optional[str], optional): begin date expressed as YYYY-MM-DD.
Defaults to None.
end_date (Optional[str], optional): end date expressed as YYYY-MM-DD.
Defaults to None.
max_retries (int, optional): Number of retries when API shows connection issues.
Defaults to 10.
"""
# create API client
api = MedRxivApi()
api = MedRxivApi(max_retries=max_retries)
# dump all papers
with open(save_path, "w") as fp:
for index, paper in enumerate(
Expand Down

0 comments on commit 48eec7c

Please sign in to comment.