aboutsummaryrefslogtreecommitdiff
path: root/backend/hist_data/enwiki/gen_pageview_data.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2023-02-05 13:55:00 +1100
committerTerry Truong <terry06890@gmail.com>2023-02-05 13:55:00 +1100
commitff638e269d439c853b5182b68ff10777f12597f1 (patch)
tree2cc62068a501884821969b6ebeba3686df8f4044 /backend/hist_data/enwiki/gen_pageview_data.py
parentcc79c17fbc05bddc8b08f2734e721bc241123a4e (diff)
Use relative imports between data generation scriptspackage-imports
Avoids the need for code that modifies sys.path, but requires running of the scripts using 'python -m' with backend/ as cwd. Also expects constants like DB_FILE to be non-relative, due to running from backend/.
Diffstat (limited to 'backend/hist_data/enwiki/gen_pageview_data.py')
-rwxr-xr-xbackend/hist_data/enwiki/gen_pageview_data.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/backend/hist_data/enwiki/gen_pageview_data.py b/backend/hist_data/enwiki/gen_pageview_data.py
index 57d6c7b..2dc6eb7 100755
--- a/backend/hist_data/enwiki/gen_pageview_data.py
+++ b/backend/hist_data/enwiki/gen_pageview_data.py
@@ -22,9 +22,10 @@ from collections import defaultdict
import bz2
import sqlite3
-PAGEVIEW_FILES = glob.glob('./pageviews/pageviews-*-user.bz2')
-DUMP_INDEX_DB = 'dump_index.db'
-DB_FILE = 'pageview_data.db'
+ENWIKI_DIR = os.path.dirname(os.path.realpath(__file__))
+PAGEVIEW_FILES = glob.glob(os.path.join(ENWIKI_DIR, './pageviews/pageviews-*-user.bz2'))
+DUMP_INDEX_DB = os.path.join(ENWIKI_DIR, 'dump_index.db')
+DB_FILE = os.path.join(ENWIKI_DIR, 'pageview_data.db')
def genData(pageviewFiles: list[str], dumpIndexDb: str, dbFile: str) -> None:
if os.path.exists(dbFile):