Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ Flags are used to enable/disable certain features. They are set to `1` to enable

Configuration flags are used to enable/disable certain configurations.

| Flag | Description |
|--------------|------------------------------------|
| `POST_TO_DISCORD_FLAG` | Enables posting errors to discord. |
| Flag | Description |
|--------------|--------------------------------------|
| `POST_TO_DISCORD_FLAG` | Enables posting errors to discord. |
| `PROGRESS_BAR_FLAG` | Enables progress bars on some tasks. |


## Task Flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from src.db.models.impl.url.internet_archives.probe.pydantic import URLInternetArchiveMetadataPydantic
from src.external.internet_archives.client import InternetArchivesClient
from src.external.internet_archives.models.ia_url_mapping import InternetArchivesURLMapping
from src.util.progress_bar import get_progress_bar_disabled
from src.util.url_mapper import URLMapper


Expand Down Expand Up @@ -81,7 +82,8 @@ async def _search_for_internet_archive_links(self, urls: list[str]) -> list[Inte
self.ia_client.search_for_url_snapshot(url)
for url in urls
],
timeout=60 * 10 # 10 minutes
timeout=60 * 10, # 10 minutes
disable=get_progress_bar_disabled()
)

async def _add_ia_metadata_to_db(
Expand Down
4 changes: 3 additions & 1 deletion src/external/url_request/probe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from src.external.url_request.probe.convert import convert_client_response_to_probe_response, convert_to_error_response
from src.external.url_request.probe.models.wrapper import URLProbeResponseOuterWrapper
from src.util.progress_bar import get_progress_bar_disabled


class URLProbeManager:
Expand All @@ -22,7 +23,8 @@ def __init__(
async def probe_urls(self, urls: list[str]) -> list[URLProbeResponseOuterWrapper]:
return await tqdm_asyncio.gather(
*[self._probe(url) for url in urls],
timeout=60 * 10 # 10 minutes
timeout=60 * 10, # 10 minutes,
disable=get_progress_bar_disabled()
)

async def _probe(self, url: str) -> URLProbeResponseOuterWrapper:
Expand Down
8 changes: 8 additions & 0 deletions src/util/progress_bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Check warning on line 1 in src/util/progress_bar.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/util/progress_bar.py#L1 <100>

Missing docstring in public module
Raw output
./src/util/progress_bar.py:1:1: D100 Missing docstring in public module
from environs import Env

def get_progress_bar_disabled() -> bool:

Check warning on line 4 in src/util/progress_bar.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/util/progress_bar.py#L4 <103>

Missing docstring in public function
Raw output
./src/util/progress_bar.py:4:1: D103 Missing docstring in public function
env = Env()
env.read_env()
enabled: bool = env.bool("PROGRESS_BAR_FLAG", True)
return not enabled