8000 fix: ignore unpicklable hooks by ankush · Pull Request #18902 · frappe/frappe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: ignore unpicklable hooks #18902

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

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

ankush
Copy link
Member
@ankush ankush commented Nov 16, 2022

If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/f
8000
rappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 552, in migrate
    SiteMigration(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 172, in run
    self.setUp()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 74, in setUp
    clear_global_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 102, in clear_global_cache
    clear_website_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/utils.py", line 387, in clear_website_cache
    clear_cache(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/utils.py", line 370, in clear_cache
    frappe.clear_cache("Guest")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 872, in clear_cache
    frappe.cache_manager.clear_user_cache(user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 78, in clear_user_cache
    clear_notifications(user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 143, in clear_notifications
    config = get_notification_config()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 236, in get_notification_config
    return frappe.cache().hget("notification_config", user, _get)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 201, in hget
    value = generator()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/notifications.py", line 214, in _get
    subscribed_documents = get_subscribed_documents()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/doctype/notification_settings/notification_settings.py", line 68, in get_subscribed_documents
    if frappe.db.exists("Notification Settings", frappe.session.user):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 1091, in exists
    return self.get_value(dt, dn, ignore=True, cache=cache)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 495, in get_value
    result = self.get_values(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 592, in get_values
    out = self._get_values_from_table(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 809, in _get_values_from_table
    query = frappe.qb.engine.get_query(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/query.py", line 513, in get_query
    criterion = self.build_conditions(table, filters, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/query.py", line 369, in build_conditions
    criterion = self.dict_query(filters=filters, table=table, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/query.py", line 328, in dict_query
    _operator = self.OPERATOR_MAP["="]
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/query.py", line 194, in OPERATOR_MAP
    if frappe.get_hooks("filters_config"):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1472, in get_hooks
    hooks = _dict(cache().get_value("app_hooks", _load_app_hooks))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 82, in get_value
    self.set_value(original_key, val, user=user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 50, in set_value
    self.set(key, pickle.dumps(val))
TypeError: cannot pickle 'module' object

If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py
@ankush ankush requested review from a team and shariquerik and removed request for a team November 16, 2022 16:13
@github-actions github-actions bot added the add-test-cases Add test case to validate fix or enhancement label Nov 16, 2022
@ankush ankush removed the add-test-cases Add test case to validate fix or enhancement label Nov 16, 2022
@ankush ankush added the defer backport Backports for some PR are deferred for a week or two to test them properly before releasing label Nov 16, 2022
@codecov
Copy link
codecov bot commented Nov 16, 2022

Codecov Report

Merging #18902 (7d05ced) into develop (7063357) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #18902      +/-   ##
===========================================
+ Coverage    63.45%   63.53%   +0.07%     
===========================================
  Files          750      750              
  Lines        67551    67759     +208     
  Branches      6018     6018              
===========================================
+ Hits         42865    43048     +183     
- Misses       21225    21250      +25     
  Partials      3461     
10000
3461              
Flag Coverage Δ
server-mariadb 67.29% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ankush
Copy link
Member Author
ankush commented Nov 17, 2022

why is this failing on postgres 🥴

Edit: unrelated, failing elsewhere too; needs investigation.

@ankush ankush merged commit c658d8c into frappe:develop Nov 17, 2022
@ankush ankush deleted the fix/ignore_unpicklable_hooks branch November 17, 2022 06:20
@ankush ankush added backport version-14-hotfix backport to version 14 and removed defer backport Backports for some PR are deferred for a week or two to test them properly before releasing labels Nov 17, 2022
mergify bot pushed a commit that referenced this pull request Nov 17, 2022
If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py

(cherry picked from commit c658d8c)
ankush added a commit that referenced this pull request Nov 17, 2022
If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py

(cherry picked from commit c658d8c)

Co-authored-by: Ankush Menat <ankush@frappe.io>
frappe-pr-bot pushed a commit that referenced this pull request Nov 22, 2022
# [14.16.0](v14.15.0...v14.16.0) (2022-11-22)

### Bug Fixes

* added phone field in webform ([c47b88c](c47b88c))
* Auto-add all users to website room ([bf4fdca](bf4fdca))
* check permission  in discussions component ([#18903](#18903)) ([6a47669](6a47669))
* **desk:** maintain realtime & cached data consistency ([117f1f7](117f1f7))
* dont convert row format if not required ([#18900](#18900)) ([#18901](#18901)) ([9394677](9394677))
* **file:** attached_to_name can be an integer ([#18909](#18909)) ([#18911](#18911)) ([3b112e1](3b112e1))
* **file:** set fieldname to table fieldname ([14b6017](14b6017))
* **File:** validate `attached_to_*` when saving ([#18882](#18882)) ([5fe9f3c](5fe9f3c))
* Force integer type in request.max_content_length (backport [#18904](#18904)) ([#18931](#18931)) ([5e13b08](5e13b08))
* get_title must return string ([#18926](#18926)) ([#18935](#18935)) ([8d6f23c](8d6f23c))
* grid column indicators not working ([e2a1274](e2a1274))
* ignore unpicklable hooks ([#18902](#18902)) ([#18932](#18932)) ([bb660a1](bb660a1))
* only get fields which is not already in webform fields table ([380dc06](380dc06))
* **recorder:** Publish update only to Administrator ([1c09bee](1c09bee))
* Restrict socket data to respective users after commit ([efe4d2d](efe4d2d))
* show fields without labels in print format builder ([#18939](#18939)) ([#18955](#18955)) ([0e384d8](0e384d8))
* **socketio:** Re-try thrice before trying to reconnect ([1c72d92](1c72d92))
* **socketio:** Revert irrelevant & unused changes ([62f5e67](62f5e67))
* **socketio:** Scoping & hoisting bugs ([0a1fdbb](0a1fdbb))
* succinct version ([85e0d85](85e0d85))
* update-password api call ([#18943](#18943)) ([#18953](#18953)) ([4eeeccd](4eeeccd))

### Features

* {site}:website room open to all users ([965a814](965a814))
* **minor:** redirect after login from NotPermittedPage ([#18946](#18946)) ([#18956](#18956)) ([2ea12db](2ea12db))

### Performance Improvements

* dont fetch meta unless required ([#18907](#18907)) ([#18908](#18908)) ([02dae2d](02dae2d))
* **socketio:** get_site_name ([422882c](422882c))
stephenBDT pushed a commit to alias/frappe that referenced this pull request Nov 30, 2022
If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py

(cherry picked from commit c658d8c)

Co-authored-by: Ankush Menat <ankush@frappe.io>
stephenBDT pushed a commit to alias/frappe that referenced this pull request Nov 30, 2022
# [14.16.0](frappe/frappe@v14.15.0...v14.16.0) (2022-11-22)

### Bug Fixes

* added phone field in webform ([c47b88c](frappe@c47b88c))
* Auto-add all users to website room ([bf4fdca](frappe@bf4fdca))
* check permission  in discussions component ([frappe#18903](frappe#18903)) ([6a47669](frappe@6a47669))
* **desk:** maintain realtime & cached data consistency ([117f1f7](frappe@117f1f7))
* dont convert row format if not required ([frappe#18900](frappe#18900)) ([frappe#18901](frappe#18901)) ([9394677](frappe@9394677))
* **file:** attached_to_name can be an integer ([frappe#18909](frappe#18909)) ([frappe#18911](frappe#18911)) ([3b112e1](frappe@3b112e1))
* **file:** set fieldname to table fieldname ([14b6017](frappe@14b6017))
* **File:** validate `attached_to_*` when saving ([frappe#18882](frappe#18882)) ([5fe9f3c](frappe@5fe9f3c))
* Force integer type in request.max_content_length (backport [frappe#18904](frappe#18904)) ([frappe#18931](frappe#18931)) ([5e13b08](frappe@5e13b08))
* get_title must return string ([frappe#18926](frappe#18926)) ([frappe#18935](frappe#18935)) ([8d6f23c](frappe@8d6f23c))
* grid column indicators not working ([e2a1274](frappe@e2a1274))
* ignore unpicklable hooks ([frappe#18902](frappe#18902)) ([frappe#18932](frappe#18932)) ([bb660a1](frappe@bb660a1))
* only get fields which is not already in webform fields table ([380dc06](frappe@380dc06))
* **recorder:** Publish update only to Administrator ([1c09bee](frappe@1c09bee))
* Restrict socket data to respective users after commit ([efe4d2d](frappe@efe4d2d))
* show fields without labels in print format builder ([frappe#18939](frappe#18939)) ([frappe#18955](frappe#18955)) ([0e384d8](frappe@0e384d8))
* **socketio:** Re-try thrice before trying to reconnect ([1c72d92](frappe@1c72d92))
* **socketio:** Revert irrelevant & unused changes ([62f5e67](frappe@62f5e67))
* **socketio:** Scoping & hoisting bugs ([0a1fdbb](frappe@0a1fdbb))
* succinct version ([85e0d85](frappe@85e0d85))
* update-password api call ([frappe#18943](frappe#18943)) ([frappe#18953](frappe#18953)) ([4eeeccd](frappe@4eeeccd))

### Features

* {site}:website room open to all users ([965a814](frappe@965a814))
* **minor:** redirect after login from NotPermittedPage ([frappe#18946](frappe#18946)) ([frappe#18956](frappe#18956)) ([2ea12db](frappe@2ea12db))

### Performance Improvements

* dont fetch meta unless required ([frappe#18907](frappe#18907)) ([frappe#18908](frappe#18908)) ([02dae2d](frappe@02dae2d))
* **socketio:** get_site_name ([422882c](frappe@422882c))
stephenBDT pushed a commit to alias/frappe that referenced this pull request Dec 1, 2022
If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.

This PR ignores unpicklable members of hooks.py

(cherry picked from commit c658d8c)

Co-authored-by: Ankush Menat <ankush@frappe.io>
stephenBDT pushed a commit to alias/frappe that referenced this pull request Dec 1, 2022
# [14.16.0](frappe/frappe@v14.15.0...v14.16.0) (2022-11-22)

### Bug Fixes

* added phone field in webform ([c47b88c](frappe@c47b88c))
* Auto-add all users to website room ([bf4fdca](frappe@bf4fdca))
* check permission  in discussions component ([frappe#18903](frappe#18903)) ([6a47669](frappe@6a47669))
* **desk:** maintain realtime & cached data consistency ([117f1f7](frappe@117f1f7))
* dont convert row format if not required ([frappe#18900](frappe#18900)) ([frappe#18901](frappe#18901)) ([9394677](frappe@9394677))
* **file:** attached_to_name can be an integer ([frappe#18909](frappe#18909)) ([frappe#18911](frappe#18911)) ([3b112e1](frappe@3b112e1))
* **file:** set fieldname to table fieldname ([14b6017](frappe@14b6017))
* **File:** validate `attached_to_*` when saving ([frappe#18882](frappe#18882)) ([5fe9f3c](frappe@5fe9f3c))
* Force integer type in request.max_content_length (backport [frappe#18904](frappe#18904)) ([frappe#18931](frappe#18931)) ([5e13b08](frappe@5e13b08))
* get_title must return string ([frappe#18926](frappe#18926)) ([frappe#18935](frappe#18935)) ([8d6f23c](frappe@8d6f23c))
* grid column indicators not working ([e2a1274](frappe@e2a1274))
* ignore unpicklable hooks ([frappe#18902](frappe#18902)) ([frappe#18932](frappe#18932)) ([bb660a1](frappe@bb660a1))
* only get fields which is not already in webform fields table ([380dc06](frappe@380dc06))
* **recorder:** Publish update only to Administrator ([1c09bee](frappe@1c09bee))
* Restrict socket data to respective users after commit ([efe4d2d](frappe@efe4d2d))
* show fields without labels in print format builder ([frappe#18939](frappe#18939)) ([frappe#18955](frappe#18955)) ([0e384d8](frappe@0e384d8))
* **socketio:** Re-try thrice before trying to reconnect ([1c72d92](frappe@1c72d92))
* **socketio:** Revert irrelevant & unused changes ([62f5e67](frappe@62f5e67))
* **socketio:** Scoping & hoisting bugs ([0a1fdbb](frappe@0a1fdbb))
* succinct version ([85e0d85](frappe@85e0d85))
* update-password api call ([frappe#18943](frappe#18943)) ([frappe#18953](frappe#18953)) ([4eeeccd](frappe@4eeeccd))

### Features

* {site}:website room open to all users ([965a814](frappe@965a814))
* **minor:** redirect after login from NotPermittedPage ([frappe#18946](frappe#18946)) ([frappe#18956](frappe#18956)) ([2ea12db
77A5
](frappe@2ea12db))

### Performance Improvements

* dont fetch meta unless required ([frappe#18907](frappe#18907)) ([frappe#18908](frappe#18908)) ([02dae2d](frappe@02dae2d))
* **socketio:** get_site_name ([422882c](frappe@422882c))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0