Skip to content

Commit 981dda8

Browse files
committed
WIP: Add more logging for channel_import
1 parent 515336c commit 981dda8

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ src/kolibri: clean
109109
sed -i 's/if name.endswith(".py"):/if name.endswith(".py") or name.endswith(".pyc"):/g' src/kolibri/dist/django/db/migrations/loader.py
110110
# Apply kolibri patches
111111
patch -d src/ -p1 < patches/0001-Add-track-progress-information-to-channelimport.patch
112+
patch -d src/ -p1 < patches/0001-WIP-Add-more-logging-in-channel_import.patch
112113

113114
.PHONY: apps-bundle.zip
114115
apps-bundle.zip:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From f812f6e11517337f7724a77ce745efe87cf53e4c Mon Sep 17 00:00:00 2001
2+
From: Dylan McCall <dylan@endlessos.org>
3+
Date: Wed, 16 Nov 2022 13:49:03 -0800
4+
Subject: [PATCH] WIP: Add more logging in channel_import
5+
6+
---
7+
kolibri/core/content/utils/channel_import.py | 8 +++++++-
8+
1 file changed, 7 insertions(+), 1 deletion(-)
9+
10+
diff --git a/kolibri/core/content/utils/channel_import.py b/kolibri/core/content/utils/channel_import.py
11+
index f61e843482..23cc652b15 100644
12+
--- a/kolibri/core/content/utils/channel_import.py
13+
+++ b/kolibri/core/content/utils/channel_import.py
14+
@@ -655,11 +655,15 @@ class ChannelImport(object):
15+
# keep track of which model is currently being imported
16+
self.current_model_being_imported = model
17+
18+
+ logger.info("ChannelImport table_import: {}".format(model.__name__))
19+
+
20+
if self.destination.engine.name == "postgresql":
21+
result = self.postgres_table_import(model, row_mapper, table_mapper)
22+
elif self.can_use_sqlite_attach_method(model, table_mapper):
23+
+ logger.info("ChannelImport using raw_attached_sqlite_table_import")
24+
result = self.raw_attached_sqlite_table_import(model, table_mapper)
25+
else:
26+
+ logger.warning("ChannelImport using sqlite_table_import")
27+
result = self.sqlite_table_import(model, row_mapper, table_mapper)
28+
29+
self.current_model_being_imported = None
30+
@@ -845,6 +849,7 @@ class ChannelImport(object):
31+
def try_attaching_sqlite_database(self):
32+
# attach the external content database to our primary database so we can directly transfer records en masse
33+
if self.destination.engine.name == "sqlite":
34+
+ logger.info("ChannelImport attached sqlite db")
35+
try:
36+
self.destination.execute(
37+
text(
38+
@@ -852,7 +857,8 @@ class ChannelImport(object):
39+
)
40+
)
41+
self._sqlite_db_attached = True
42+
- except OperationalError:
43+
+ except OperationalError as error:
44+
+ logger.warning("ChannelImport failed to attach sqlite db: {}".format(error))
45+
# silently ignore if we were unable to attach the database; we'll just fall back to other methods
46+
pass
47+
48+
--
49+
2.38.1
50+

0 commit comments

Comments
 (0)