Skip to content

Commit

Permalink
Fix pywikibot droppings (#2924)
Browse files Browse the repository at this point in the history
* make pywikibot store its working files in a system provided temp directory

* move the config setting around
  • Loading branch information
rkuo-danswer authored Oct 27, 2024
1 parent 23988f8 commit 827518e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
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
3 changes: 3 additions & 0 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,6 +10,8 @@

from danswer.connectors.mediawiki import wiki

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


@pytest.fixture
def site() -> pywikibot.Site:
Expand Down
Empty file removed backend/throttle.ctrl
Empty file.

0 comments on commit 827518e

Please sign in to comment.