Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pywikibot droppings #2924

Merged
merged 3 commits into from
Nov 1, 2024
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
3 changes: 3 additions & 0 deletions backend/danswer/connectors/mediawiki/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import builtins
import functools
import itertools
import tempfile
from typing import Any
from unittest import mock
from urllib.parse import urlparse
Expand All @@ -18,6 +19,8 @@

logger = setup_logger()

pywikibot.config.base_dir = tempfile.TemporaryDirectory().name


@mock.patch.object(
builtins, "print", lambda *args: logger.info("\t".join(map(str, args)))
Expand Down
4 changes: 3 additions & 1 deletion backend/danswer/connectors/mediawiki/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import itertools
import tempfile
from collections.abc import Generator
from collections.abc import Iterator
from typing import Any
Expand All @@ -25,6 +26,8 @@

logger = setup_logger()

pywikibot.config.base_dir = tempfile.TemporaryDirectory().name


def pywikibot_timestamp_to_utc_datetime(
timestamp: pywikibot.time.Timestamp,
Expand Down Expand Up @@ -121,7 +124,6 @@ def __init__(
self.batch_size = batch_size

# short names can only have ascii letters and digits

self.family = family_class_dispatch(hostname, "WikipediaConnector")()
self.site = pywikibot.Site(fam=self.family, code=language_code)
self.categories = [
Expand Down
6 changes: 4 additions & 2 deletions backend/tests/unit/danswer/connectors/mediawiki/test_wiki.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import datetime
import tempfile
from collections.abc import Iterable

import pytest
Expand All @@ -9,15 +10,16 @@

from danswer.connectors.mediawiki import wiki

# These tests are disabled for now
# Some of these tests are disabled for now due to flakiness with wikipedia as the backend

pywikibot.config.base_dir = tempfile.TemporaryDirectory().name


@pytest.fixture
def site() -> pywikibot.Site:
return pywikibot.Site("en", "wikipedia")


@pytest.mark.skip(reason="Test disabled")
def test_pywikibot_timestamp_to_utc_datetime() -> None:
timestamp_without_tzinfo = pywikibot.Timestamp(2023, 12, 27, 15, 38, 49)
timestamp_min_timezone = timestamp_without_tzinfo.astimezone(datetime.timezone.min)
Expand Down
Empty file removed backend/throttle.ctrl
Empty file.
Loading