openzim / python-scraperlib

Collection of Python code to re-use across Python-based scrapers
GNU General Public License v3.0
19 stars 16 forks source link

Introduce the `config_metadata` #97

Closed FledgeXu closed 1 year ago

FledgeXu commented 1 year ago

As discussed in #96 , this PR introduces config_metada. However, introducing this PR will cause the existing test_noindexlanguage unit test to fail.

FledgeXu commented 1 year ago

@rgaudin I'm a little confused about Counter.

would prevent setting Counter (set by libzim itself)

In the preview discussion, We want to prevent setting Counter. Counter is supposed to be set by libzim isn't it?

rgaudin commented 1 year ago

In the preview discussion, We want to prevent setting Counter. Counter is supposed to be set by libzim isn't it?

Exact, so we should raise an Exception if user tries to set it because it would prevent libzim from setting it and just ignoring it would create confusion. Maybe that should happen in a add_metadata() override…

FledgeXu commented 1 year ago

The reason I didn't add illustration is because I ran into a weird problem with the illustration image here. So I tried to use those code to generate bytes of a empty 48x48 png.

def generate_transparent_png() -> bytes:
    img = Image.new("RGB", (48,48))
    in_memory_io = io.BytesIO()
    img.save(in_memory_io, format="PNG")
    return in_memory_io.getvalue()

However, when I try to set these bytes as the default illustration in self.add_default_illustration, the program just crashed and threw a Segmentation fault. Full report here:

platform darwin -- Python 3.11.2, pytest-7.2.2, pluggy-1.0.0
rootdir: /Users/fledge/Developer/python-scraperlib
collected 26 items

tests/zim/test_zim_creator.py Fatal Python error: Segmentation fault

Current thread 0x00000001f7750140 (most recent call first):
  File "/Users/fledge/Developer/python-scraperlib/src/zimscraperlib/zim/creator.py", line 319 in add_default_illustration
  File "/Users/fledge/Developer/python-scraperlib/src/zimscraperlib/zim/creator.py", line 174 in config_metadata
  File "/Users/fledge/Developer/python-scraperlib/src/zimscraperlib/zim/creator.py", line 184 in config_dev_metadata
  File "/Users/fledge/Developer/python-scraperlib/tests/zim/test_zim_creator.py", line 49 in test_zim_creator
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/python.py", line 195 in pytest_pyfunc_call
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/python.py", line 1789 in runtest
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 167 in pytest_runtest_call
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 260 in <lambda>
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 339 in from_call
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 259 in call_runtest_hook
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 220 in call_and_report
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 131 in runtestprotocol
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/runner.py", line 112 in pytest_runtest_protocol
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/main.py", line 349 in pytest_runtestloop
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/main.py", line 324 in _main
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/main.py", line 270 in wrap_session
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/main.py", line 317 in pytest_cmdline_main
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/config/__init__.py", line 167 in main
  File "/Users/fledge/Developer/python-scraperlib/.env/lib/python3.11/site-packages/_pytest/config/__init__.py", line 190 in console_main
  File "/Users/fledge/Developer/python-scraperlib/.env/bin/pytest", line 8 in <module>

Extension modules: libzim, charset_normalizer.md, PIL._imaging, lxml._elementpath, lxml.etree (total: 5)
zsh: segmentation fault  PYTHONPATH=$(pwd)/src/ pytest -s "$@" tests/zim/test_zim_creator.py
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [97659]
Path:                  /opt/homebrew/*/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               3.11.2 (3.11.2)
Code Type:             ARM-64 (Native)
Parent Process:        zsh [59493]
Responsible:           iTerm2 [7139]
User ID:               501

Date/Time:             2023-03-13 12:04:44.2814 -0400
OS Version:            macOS 13.2.1 (22D68)
Report Version:        12
Anonymous UUID:        E7875846-00A5-B009-7442-D77089D70AC1

Sleep/Wake UUID:       35F91941-0789-4674-9F59-6B0005C0612A

Time Awake Since Boot: 270000 seconds
Time Since Wake:       4082 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000220
Exception Codes:       0x0000000000000001, 0x0000000000000220

VM Region Info: 0x220 is not in any region.  Bytes before following region: 105553518919136
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x19c18e868 __pthread_kill + 8
1   libsystem_pthread.dylib                0x19c1c5cec pthread_kill + 288
2   libsystem_c.dylib                      0x19c0c69cc raise + 32
3   Python                                 0x1050db4a0 faulthandler_fatal_error + 440
4   libsystem_platform.dylib               0x19c1f42a4 _sigtramp + 56
5   libzim.8.dylib                         0x1060f76f0 zim::writer::Creator::addIllustration(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 36
6   libzim.8.dylib                         0x1060f76f0 zim::writer::Creator::addIllustration(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 36
7   libzim.cpython-311-darwin.so           0x105fc8b7c __pyx_pw_6libzim_8_Creator_17add_illustration(_object*, _object*, _object*) + 212
8   Python                                 0x104f73aa8 method_vectorcall_VARARGS_KEYWORDS + 148
9   Python                                 0x10505de58 _PyEval_EvalFrameDefault + 47440
10  Python                                 0x1050634cc _PyEval_Vector + 116
11  Python                                 0x104f686a0 method_vectorcall + 272
12  Python                                 0x104f65a44 _PyVectorcall_Call + 116
13  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
14  Python                                 0x1050634cc _PyEval_Vector + 116
15  Python                                 0x104f65a44 _PyVectorcall_Call + 116
16  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
17  Python                                 0x1050634cc _PyEval_Vector + 116
18  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
19  Python                                 0x1050634cc _PyEval_Vector + 116
20  Python                                 0x104f652d8 _PyObject_FastCallDictTstate + 208
21  Python                                 0x104fdc09c slot_tp_call + 180
22  Python                                 0x104f64fbc _PyObject_MakeTpCall + 128
23  Python                                 0x10505e184 _PyEval_EvalFrameDefault + 48252
24  Python                                 0x1050634cc _PyEval_Vector + 116
25  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
26  Python                                 0x1050634cc _PyEval_Vector + 116
27  Python                                 0x104f652d8 _PyObject_FastCallDictTstate + 208
28  Python                                 0x104fdc09c slot_tp_call + 180
29  Python                                 0x104f65e08 _PyObject_Call + 124
30  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
31  Python                                 0x1050634cc _PyEval_Vector + 116
32  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
33  Python                                 0x1050634cc _PyEval_Vector + 116
34  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
35  Python                                 0x1050634cc _PyEval_Vector + 116
36  Python                                 0x104f652d8 _PyObject_FastCallDictTstate + 208
37  Python                                 0x104fdc09c slot_tp_call + 180
38  Python                                 0x104f64fbc _PyObject_MakeTpCall + 128
39  Python                                 0x10505e184 _PyEval_EvalFrameDefault + 48252
40  Python                                 0x1050634cc _PyEval_Vector + 116
41  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
42  Python                                 0x1050634cc _PyEval_Vector + 116
43  Python                                 0x104f652d8 _PyObject_FastCallDictTstate + 208
44  Python                                 0x104fdc09c slot_tp_call + 180
45  Python                                 0x104f64fbc _PyObject_MakeTpCall + 128
46  Python                                 0x10505e184 _PyEval_EvalFrameDefault + 48252
47  Python                                 0x1050634cc _PyEval_Vector + 116
48  Python                                 0x1050602ac _PyEval_EvalFrameDefault + 56740
49  Python                                 0x1050634cc _PyEval_Vector + 116
50  Python                                 0x104f652d8 _PyObject_FastCallDictTstate + 208
51  Python                                 0x104fdc09c slot_tp_call + 180
52  Python                                 0x104f64fbc _PyObject_MakeTpCall + 128
53  Python                                 0x10505e184 _PyEval_EvalFrameDefault + 48252
54  Python                                 0x105051814 PyEval_EvalCode + 280
55  Python                                 0x1050b3dcc run_eval_code_obj + 84
56  Python                                 0x1050b3d30 run_mod + 112
57  Python                                 0x1050b39d4 pyrun_file + 148
58  Python                                 0x1050b3308 _PyRun_SimpleFileObject + 268
59  Python                                 0x1050b299c _PyRun_AnyFileObject + 232
60  Python                                 0x1050d6734 pymain_run_file_obj + 220
61  Python                                 0x1050d5ebc pymain_run_file + 72
62  Python                                 0x1050d5754 Py_RunMain + 932
63  Python                                 0x1050d6b1c Py_BytesMain + 40
64  dyld                                   0x19be9be50 start + 2544

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000001   x3: 0x0000000000000000
    x4: 0x000000000000006c   x5: 0x000000000000005f   x6: 0x0000600001900420   x7: 0x00006000019003c0
    x8: 0x50d9e15f5baf4a84   x9: 0x50d9e15eacda4bc4  x10: 0xcccccccccccccccd  x11: 0x00000000fffffff6
   x12: 0x000000013008fa53  x13: 0x0000000000000000  x14: 0x0000000000000035  x15: 0x00000000ffffffd1
   x16: 0x0000000000000148  x17: 0x00000001fc5b36d8  x18: 0x0000000000000000  x19: 0x000000000000000b
   x20: 0x00000001f7750140  x21: 0x0000000000000103  x22: 0x00000001f7750220  x23: 0x0000000000000004
   x24: 0x0000000000000001  x25: 0x0000000000000003  x26: 0x0000000000000003  x27: 0x0000000105e82d90
   x28: 0x000000010538a0c8   fp: 0x000000013008fae0   lr: 0x000000019c1c5cec
    sp: 0x000000013008fac0   pc: 0x000000019c18e868 cpsr: 0x40001000
   far: 0x000000010afa41d8  esr: 0x56000080  Address size fault

Binary Images:
       0x19c185000 -        0x19c1befeb libsystem_kernel.dylib (*) <3dcd49b9-b3c5-3d90-be40-a3b807cb9cd7> /usr/lib/system/libsystem_kernel.dylib
       0x19c1bf000 -        0x19c1cbffb libsystem_pthread.dylib (*) <9f3b729a-ed04-3e65-adac-d75ad06ebbdc> /usr/lib/system/libsystem_pthread.dylib
       0x19c085000 -        0x19c105ffb libsystem_c.dylib (*) <14cd841b-0c7b-34a2-a342-cc6796ef9259> /usr/lib/system/libsystem_c.dylib
       0x104eec000 -        0x10523bfff org.python.python (3.11.2, (c) 2001-2023 Python Software Foundation.) <719aa773-8f45-34ec-ad52-baabaf06d424> /opt/homebrew/*/Python.framework/Versions/3.11/Python
       0x19c1f0000 -        0x19c1f7ffb libsystem_platform.dylib (*) <4cf75103-429d-3aae-ba13-2c1f67e47dbb> /usr/lib/system/libsystem_platform.dylib
       0x1060d4000 -        0x106147fff libzim.8.dylib (*) <4700c5c3-3a5c-3a51-adba-a8f0d68fa059> /opt/homebrew/*/libzim.8.dylib
       0x105fa4000 -        0x105fe7fff libzim.cpython-311-darwin.so (*) <35321c0c-10c5-3296-9159-5a6677bbf689> /Users/USER/*/libzim.cpython-311-darwin.so
       0x19be96000 -        0x19bf20ba3 dyld (*) <191e84f1-4b95-39c8-b253-1c1ef56c0fa8> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=919.3M resident=0K(0%) swapped_out_or_unallocated=919.3M(100%)
Writable regions: Total=1.6G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.6G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                           269.2M       38 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         960.0M        8         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
Stack                             16.0M        1 
Stack Guard                         16K        1 
VM_ALLOCATE                       32.0M       33 
__AUTH                             307K       58 
__AUTH_CONST                      3565K      145 
__DATA                            4011K      198 
__DATA_CONST                      5497K      205 
__DATA_DIRTY                       361K       59 
__LINKEDIT                       773.8M       61 
__OBJC_CONST                       289K       36 
__OBJC_RO                         65.5M        1 
__OBJC_RW                         1988K        1 
__TEXT                           145.5M      213 
dyld private memory                256K        1 
mapped file                       29.0M        1 
shared memory                       32K        2 
===========                     =======  ======= 
TOTAL                              2.6G     1069 
TOTAL, minus reserved VM space     1.3G     1069 

-----------
Full Report
-----------

{"app_name":"Python","timestamp":"2023-03-13 12:04:44.00 -0400","app_version":"3.11.2","slice_uuid":"5aad390b-0201-3ba4-8056-d2fd9a79da98","build_version":"3.11.2","platform":1,"bundleID":"org.python.python","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.2.1 (22D68)","roots_installed":0,"name":"Python","incident_id":"F72FB869-5096-4B1E-9026-50A989B9B404"}
{
  "uptime" : 270000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Mac14,5",
  "coalitionID" : 610,
  "osVersion" : {
    "train" : "macOS 13.2.1",
    "build" : "22D68",
    "releaseType" : "User"
  },
  "captureTime" : "2023-03-13 12:04:44.2814 -0400",
  "incident" : "F72FB869-5096-4B1E-9026-50A989B9B404",
  "pid" : 97659,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-03-13 12:04:43.9813 -0400",
  "procStartAbsTime" : 6636426552786,
  "procExitAbsTime" : 6636433749115,
  "procName" : "Python",
  "procPath" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/Resources\/Python.app\/Contents\/MacOS\/Python",
  "bundleInfo" : {"CFBundleShortVersionString":"3.11.2","CFBundleVersion":"3.11.2","CFBundleIdentifier":"org.python.python"},
  "storeInfo" : {"deviceIdentifierForVendor":"8335BDD2-FE3A-5300-9855-F29EFBF5A9A3","thirdParty":true},
  "parentProc" : "zsh",
  "parentPid" : 59493,
  "coalitionName" : "com.googlecode.iterm2",
  "crashReporterKey" : "E7875846-00A5-B009-7442-D77089D70AC1",
  "responsiblePid" : 7139,
  "responsibleProc" : "iTerm2",
  "wakeTime" : 4082,
  "sleepWakeUUID" : "35F91941-0789-4674-9F59-6B0005C0612A",
  "sip" : "enabled",
  "vmRegionInfo" : "0x220 is not in any region.  Bytes before following region: 105553518919136\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "exception" : {"codes":"0x0000000000000001, 0x0000000000000220","rawCodes":[1,544],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000000000220"},
  "vmregioninfo" : "0x220 is not in any region.  Bytes before following region: 105553518919136\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":4025974,"threadState":{"x":[{"value":0},{"value":0},{"value":1},{"value":0},{"value":108},{"value":95},{"value":105553142481952},{"value":105553142481856},{"value":5825935392656804484},{"value":5825935389723610052},{"value":14757395258967641293},{"value":4294967286},{"value":5100862035},{"value":0},{"value":53},{"value":4294967249},{"value":328},{"value":8528803544},{"value":0},{"value":11},{"value":8446607680,"symbolLocation":0,"symbol":"_main_thread"},{"value":259},{"value":8446607904,"symbolLocation":224,"symbol":"_main_thread"},{"value":4},{"value":1},{"value":3},{"value":3},{"value":4394069392},{"value":4382564552,"symbolLocation":166384,"symbol":"_PyRuntime"}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6914071788},"cpsr":{"value":1073745920},"fp":{"value":5100862176},"sp":{"value":5100862144},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6913845352,"matchesCrashFrame":1},"far":{"value":4479140312}},"queue":"com.apple.main-thread","frames":[{"imageOffset":39016,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":0},{"imageOffset":27884,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":1},{"imageOffset":268748,"symbol":"raise","symbolLocation":32,"imageIndex":2},{"imageOffset":2028704,"symbol":"faulthandler_fatal_error","symbolLocation":440,"imageIndex":3},{"imageOffset":17060,"symbol":"_sigtramp","symbolLocation":56,"imageIndex":4},{"imageOffset":145136,"symbol":"zim::writer::Creator::addIllustration(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)","symbolLocation":36,"imageIndex":5},{"imageOffset":145136,"symbol":"zim::writer::Creator::addIllustration(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)","symbolLocation":36,"imageIndex":5},{"imageOffset":150396,"symbol":"__pyx_pw_6libzim_8_Creator_17add_illustration(_object*, _object*, _object*)","symbolLocation":212,"imageIndex":6},{"imageOffset":555688,"symbol":"method_vectorcall_VARARGS_KEYWORDS","symbolLocation":148,"imageIndex":3},{"imageOffset":1515096,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":47440,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":509600,"symbol":"method_vectorcall","symbolLocation":272,"imageIndex":3},{"imageOffset":498244,"symbol":"_PyVectorcall_Call","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":498244,"symbol":"_PyVectorcall_Call","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":496344,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":3},{"imageOffset":983196,"symbol":"slot_tp_call","symbolLocation":180,"imageIndex":3},{"imageOffset":495548,"symbol":"_PyObject_MakeTpCall","symbolLocation":128,"imageIndex":3},{"imageOffset":1515908,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":48252,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":496344,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":3},{"imageOffset":983196,"symbol":"slot_tp_call","symbolLocation":180,"imageIndex":3},{"imageOffset":499208,"symbol":"_PyObject_Call","symbolLocation":124,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":496344,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":3},{"imageOffset":983196,"symbol":"slot_tp_call","symbolLocation":180,"imageIndex":3},{"imageOffset":495548,"symbol":"_PyObject_MakeTpCall","symbolLocation":128,"imageIndex":3},{"imageOffset":1515908,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":48252,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":496344,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":3},{"imageOffset":983196,"symbol":"slot_tp_call","symbolLocation":180,"imageIndex":3},{"imageOffset":495548,"symbol":"_PyObject_MakeTpCall","symbolLocation":128,"imageIndex":3},{"imageOffset":1515908,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":48252,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":1524396,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":56740,"imageIndex":3},{"imageOffset":1537228,"symbol":"_PyEval_Vector","symbolLocation":116,"imageIndex":3},{"imageOffset":496344,"symbol":"_PyObject_FastCallDictTstate","symbolLocation":208,"imageIndex":3},{"imageOffset":983196,"symbol":"slot_tp_call","symbolLocation":180,"imageIndex":3},{"imageOffset":495548,"symbol":"_PyObject_MakeTpCall","symbolLocation":128,"imageIndex":3},{"imageOffset":1515908,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":48252,"imageIndex":3},{"imageOffset":1464340,"symbol":"PyEval_EvalCode","symbolLocation":280,"imageIndex":3},{"imageOffset":1867212,"symbol":"run_eval_code_obj","symbolLocation":84,"imageIndex":3},{"imageOffset":1867056,"symbol":"run_mod","symbolLocation":112,"imageIndex":3},{"imageOffset":1866196,"symbol":"pyrun_file","symbolLocation":148,"imageIndex":3},{"imageOffset":1864456,"symbol":"_PyRun_SimpleFileObject","symbolLocation":268,"imageIndex":3},{"imageOffset":1862044,"symbol":"_PyRun_AnyFileObject","symbolLocation":232,"imageIndex":3},{"imageOffset":2008884,"symbol":"pymain_run_file_obj","symbolLocation":220,"imageIndex":3},{"imageOffset":2006716,"symbol":"pymain_run_file","symbolLocation":72,"imageIndex":3},{"imageOffset":2004820,"symbol":"Py_RunMain","symbolLocation":932,"imageIndex":3},{"imageOffset":2009884,"symbol":"Py_BytesMain","symbolLocation":40,"imageIndex":3},{"imageOffset":24144,"symbol":"start","symbolLocation":2544,"imageIndex":7}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6913806336,
    "size" : 237548,
    "uuid" : "3dcd49b9-b3c5-3d90-be40-a3b807cb9cd7",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6914043904,
    "size" : 53244,
    "uuid" : "9f3b729a-ed04-3e65-adac-d75ad06ebbdc",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6912757760,
    "size" : 528380,
    "uuid" : "14cd841b-0c7b-34a2-a342-cc6796ef9259",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4377722880,
    "CFBundleShortVersionString" : "3.11.2, (c) 2001-2023 Python Software Foundation.",
    "CFBundleIdentifier" : "org.python.python",
    "size" : 3473408,
    "uuid" : "719aa773-8f45-34ec-ad52-baabaf06d424",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/Python",
    "name" : "Python",
    "CFBundleVersion" : "3.11.2"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6914244608,
    "size" : 32764,
    "uuid" : "4cf75103-429d-3aae-ba13-2c1f67e47dbb",
    "path" : "\/usr\/lib\/system\/libsystem_platform.dylib",
    "name" : "libsystem_platform.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4396498944,
    "size" : 475136,
    "uuid" : "4700c5c3-3a5c-3a51-adba-a8f0d68fa059",
    "path" : "\/opt\/homebrew\/*\/libzim.8.dylib",
    "name" : "libzim.8.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4395253760,
    "size" : 278528,
    "uuid" : "35321c0c-10c5-3296-9159-5a6677bbf689",
    "path" : "\/Users\/USER\/*\/libzim.cpython-311-darwin.so",
    "name" : "libzim.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6910730240,
    "size" : 568228,
    "uuid" : "191e84f1-4b95-39c8-b253-1c1ef56c0fa8",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6910083072,
  "size" : 3447455744,
  "uuid" : "835716ae-b363-3187-b065-cf94139bfc85"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=919.3M resident=0K(0%) swapped_out_or_unallocated=919.3M(100%)\nWritable regions: Total=1.6G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.6G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nKernel Alloc Once                   32K        1 \nMALLOC                           269.2M       38 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)         960.0M        8         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nStack                             16.0M        1 \nStack Guard                         16K        1 \nVM_ALLOCATE                       32.0M       33 \n__AUTH                             307K       58 \n__AUTH_CONST                      3565K      145 \n__DATA                            4011K      198 \n__DATA_CONST                      5497K      205 \n__DATA_DIRTY                       361K       59 \n__LINKEDIT                       773.8M       61 \n__OBJC_CONST                       289K       36 \n__OBJC_RO                         65.5M        1 \n__OBJC_RW                         1988K        1 \n__TEXT                           145.5M      213 \ndyld private memory                256K        1 \nmapped file                       29.0M        1 \nshared memory                       32K        2 \n===========                     =======  ======= \nTOTAL                              2.6G     1069 \nTOTAL, minus reserved VM space     1.3G     1069 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "6347054113acce15305b7b82",
      "factorPackIds" : {
        "SIRI_MEMORY_SYNC_CONFIG" : "634705e78e8be655c1316a6e"
      },
      "deploymentId" : 240000005
    },
    {
      "rolloutId" : "5f72dc58705eff005a46b3a9",
      "factorPackIds" : {

      },
      "deploymentId" : 240000015
    }
  ],
  "experiments" : [

  ]
}
}
FledgeXu commented 1 year ago

And I also tried to use a base64 string and decode it to bytes, same problem.

rgaudin commented 1 year ago

And I also tried to use a base64 string and decode it to bytes, same problem.

Don't generate it dynamically. It brings no value but complications.

Blank PNG is as valid as any other illustration ; plus libzim doesn't do any processing so the problem might be elsewhere.

iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA9JREFUeNpi+P//P0CAAQAF/gL+Lc6J7gAAAABJRU5ErkJggg==
rgaudin commented 1 year ago

Keep in mind illustrations must be added after the creator started

FledgeXu commented 1 year ago

i see.

FledgeXu commented 1 year ago

Update:

  1. fix the all the name issues.
  2. check the lengths of Description and LongDescription
  3. check setting Counter
  4. store the mandatory illustration
  5. add_default_illustration would be called after start()
  6. make main_path mandatory in init and call set_mainpath() instead of storing it.
  7. Add the tests to about Counter, Description and LongDescription
  8. All Creator type annotation should be Self now.
FledgeXu commented 1 year ago

you are not testing config_metadata() We want to make sure that passing it all currently documented metadata is OK and that missing some raises.

I'm not sure this part, could you explain more? What's the all currently documented metadata?

rgaudin commented 1 year ago

I'm not sure this part, could you explain more? What's the all currently documented metadata?

All your tests uses the config_dev_metadata(). That's indirectly testing config_metadata but this is a public endpoint, it deserves its own test(s)

FledgeXu commented 1 year ago

Update log:

  1. config_metadata is tested now
  2. remove the set_mainpath
  3. _all_metadata_is_set and _validate_metadata are tested before supre().__enter__() now.
  4. test_noindexlanguage correctly set creator.config_indexing(False, "") now.
  5. using pytest.raises() instead of normal try except now.
  6. remove add_metadata
  7. remove add_default_illustration
rgaudin commented 1 year ago

@FledgeXu, use the Github features next time ; it's easier to review: mark the conversations resolved when they are and re-request a review. This way I know exactly when to review and have a better sense of what's been fixed. For stuff not tracked in conversation, a tick-box list with what's done and what's left to do is useful.

FledgeXu commented 1 year ago

pre-commit needs to be updated to work properly under Python 3.11, and I'll update it in another PR. Because of this bug, I only tried formatting specific files, and it is indeed possible to miss them.

rgaudin commented 1 year ago

pre-commit needs to be updated to work properly under Python 3.11, and I'll update it in another PR. Because of this bug, I only tried formatting specific files, and it is indeed possible to miss them.

Ah OK ; you can probably run black, isort and flake8 on the src folder in the mean time

FledgeXu commented 1 year ago

Since it's gonna be merged, do I need to rebase it?

rgaudin commented 1 year ago

Can you check all conversations and mark them as resolved if OK. You can then rebase ; I think a single commit is OK in this case. I'll do a final review then.

FledgeXu commented 1 year ago

I checked all conversations and mark them as resolved and squashed commits.

FledgeXu commented 1 year ago

@rgaudin Thank you for your efforts to wind up this PR. I learned a lot from your reviews. I really appreciate your helping!