Skip to content
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

perf: timeout for auto material request through reorder level #39659

Conversation

rohitwaghchaure
Copy link
Collaborator

@rohitwaghchaure rohitwaghchaure commented Jan 31, 2024

Issue

items_to_consider = 8200
get_doc in the for loop

Traceback with variables (most recent call last):
  File "apps/erpnext/erpnext/stock/reorder_item.py", line 205, in create_material_request
    mr.insert()
  File "apps/frappe/frappe/model/document.py", line 286, in insert
    
  File "apps/frappe/frappe/model/document.py", line 1085, in run_before_save_methods
    self.run_method("validate")
      self = <MaterialRequest: MREQ24-00031>
  File "apps/frappe/frappe/model/document.py", line 954, in run_method
    
  File "apps/frappe/frappe/model/document.py", line 1320, in composer
    
  File "apps/frappe/frappe/model/document.py", line 1302, in runner
    
  File "apps/frappe/frappe/model/document.py", line 951, in fn
    
  File "apps/erpnext/erpnext/stock/doctype/material_request/material_request.py", line 116, in validate
    super(MaterialRequest, self).validate()
      self = <MaterialRequest: MREQ24-00031>
      __class__ = <class 'erpnext.stock.doctype.material_request.material_request.MaterialRequest'>
  File "apps/erpnext/erpnext/controllers/buying_controller.py", line 31, in validate
    super(BuyingController, self).validate()
      self = <MaterialRequest: MREQ24-00031>
      __class__ = <class 'erpnext.controllers.buying_controller.BuyingController'>
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 56, in validate
    super(SubcontractingController, self).validate()
      self = <MaterialRequest: MREQ24-00031>
      __class__ = <class 'erpnext.controllers.subcontracting_controller.SubcontractingController'>
  File "apps/erpnext/erpnext/controllers/stock_controller.py", line 45, in validate
    super(StockController, self).validate()
      self = <MaterialRequest: MREQ24-00031>
      __class__ = <class 'erpnext.controllers.stock_controller.StockController'>
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 169, in validate
    self.set_missing_values(for_validate=True)
      self = <MaterialRequest: MREQ24-00031>
  File "apps/erpnext/erpnext/controllers/buying_controller.py", line 152, in set_missing_values
    self.set_missing_item_details(for_validate)
      self = <MaterialRequest: MREQ24-00031>
      for_validate = True
      __class__ = <class 'erpnext.controllers.buying_controller.BuyingController'>
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 679, in set_missing_item_details
   
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    
  File "apps/erpnext/erpnext/stock/get_item_details.py", line 76, in get_item_details
    out = get_basic_details(args, item, overwrite_warehouse)
      args = {'name': 'MREQ24-00031', 'owner': 'Administrator', 'creation': '2024-01-31 00:48:49.661371', 'modified': '2024-01-31 00:48:49.661371', 'modified_by': 'Administrator', 'docstatus': 0, 'idx': 4214, 'naming_series': 'MREQ.YY.-.#####', 'title': None, 'material_request_type': 'Purchase', 'customer': None, 'company': 'Il Pezzo Mancante srl', 'transaction_date': '2024-01-31', 'schedule_date': '2024-01-31', 'amended_from': None, 'scan_barcode': None, 'set_from_warehouse': None, 'set_warehouse': None, 'tc_name': None, 'terms': None, 'status': '', 'per_ordered': None, 'transfer_status': '', 'sales_order': None, 'cliente': None, 'per_received': None, 'letter_head': 'IPM test', 'select_print_heading': None, 'job_card': None, 'work_order': None, 'item_code': 'STR-P03MR-CUS-XX', 'item_name': 'Struttura per specchio custom Pezzo 3-XX', 'description': '<div class="ql-editor read-mode"><p>Struttura per specchio custom Pezzo 3</p><p><br></p><p>Tubolare piegato + staffine</p></div> <div>Finitura: grezzo<...
      doc = <MaterialRequest: MREQ24-00031>
      for_validate = True
      overwrite_warehouse = False
      item = <Item: STR-P03MR-CUS-XX>
  File "apps/erpnext/erpnext/stock/get_item_details.py", line 273, in get_basic_details
    item.update_template_tables()
      args = {'name': 'MREQ24-00031', 'owner': 'Administrator', 'creation': '2024-01-31 00:48:49.661371', 'modified': '2024-01-31 00:48:49.661371', 'modified_by': 'Administrator', 'docstatus': 0, 'idx': 4214, 'naming_series': 'MREQ.YY.-.#####', 'title': None, 'material_request_type': 'Purchase', 'customer': None, 'company': 'Il Pezzo Mancante srl', 'transaction_date': '2024-01-31', 'schedule_date': '2024-01-31', 'amended_from': None, 'scan_barcode': None, 'set_from_warehouse': None, 'set_warehouse': None, 'tc_name': None, 'terms': None, 'status': '', 'per_ordered': None, 'transfer_status': '', 'sales_order': None, 'cliente': None, 'per_received': None, 'letter_head': 'IPM test', 'select_print_heading': None, 'job_card': None, 'work_order': None, 'item_code': 'STR-P03MR-CUS-XX', 'item_name': 'Struttura per specchio custom Pezzo 3-XX', 'description': '<div class="ql-editor read-mode"><p>Struttura per specchio custom Pezzo 3</p><p><br></p><p>Tubolare piegato + staffine</p></div> <div>Finitura: grezzo<...
      item = <Item: STR-P03MR-CUS-XX>
      overwrite_warehouse = False
  File "apps/erpnext/erpnext/stock/doctype/item/item.py", line 354, in update_template_tables
    template = frappe.get_cached_doc("Item", self.variant_of)
      self = <Item: STR-P03MR-CUS-XX>
  File "apps/frappe/frappe/__init__.py", line 1137, in get_cached_doc
    doc = get_doc(*args, **kwargs)
      args = ('Item', 'STR-P03MR-CUS')
      kwargs = {}
      key = ********
      doc = None
  File "apps/frappe/frappe/__init__.py", line 1265, in get_doc
    doc = frappe.model.document.get_doc(*args, **kwargs)
      args = ('Item', 'STR-P03MR-CUS')
      kwargs = {}
      frappe = <module 'frappe' from 'apps/frappe/frappe/__init__.py'>
  File "apps/frappe/frappe/model/document.py", line 82, in get_doc
    return controller(*args, **kwargs)
      args = ('Item', 'STR-P03MR-CUS')
      kwargs = {}
      doctype = 'Item'
      controller = <class 'erpnext.stock.doctype.item.item.Item'>
  File "apps/frappe/frappe/model/document.py", line 123, in __init__
    self.load_from_db()
      self = <Item: STR-P03MR-CUS>
      args = ('Item', 'STR-P03MR-CUS')
      kwargs = {}
      __class__ = <class 'frappe.model.document.Document'>
  File "apps/frappe/frappe/model/document.py", line 185, in load_from_db
    frappe.db.get_values(
      self = <Item: STR-P03MR-CUS>
      get_value_kwargs = {'for_update': None, 'as_dict': True, 'order_by': None}
      d = {'name': 'STR-P03MR-CUS', 'creation': datetime.datetime(2021, 9, 30, 11, 12, 23, 17995), 'modified': datetime.datetime(2023, 4, 3, 15, 55, 43, 337251), 'modified_by': 'cristina@ilpezzomancante.com', 'owner': 'marta@ilpezzomancante.com', 'docstatus': 0, 'parent': None, 'parentfield': None, 'parenttype': None, 'idx': 0, 'default_supplier': None, 'selling_cost_center': None, 'net_weight': 0.0, 'expense_account': None, 'max_discount': 0.0, 'income_account': None, 'item_name': 'Struttura per specchio custom Pezzo 3', 'website_warehouse': None, 'default_material_request_type': 'Purchase', '_assign': None, 'disabled': 0, 'tolerance': 0.0, 'item_group': 'Materie prime', 'thumbnail': None, 'web_long_description': None, 'valuation_method': '', 'warranty_period': None, 'has_variants': 1, 'default_warehouse': None, 'inspection_required_before_delivery': 0, 'is_sales_item': 1, 'is_sub_contracted_item': 0, 'manufacturer_part_no': None, 'customer_code': '', 'barcode': None, 'is_stock_item': 1, '_user...
      df = <TableDocField: uoms parent=Item>
      children = [{'name': '5036640ee4', 'creation': datetime.datetime(2021, 9, 30, 11, 12, 23, 17995), 'modified': datetime.datetime(2023, 4, 3, 15, 55, 43, 337251), 'modified_by': 'cristina@ilpezzomancante.com', 'owner': 'cristina@ilpezzomancante.com', 'docstatus': 0, 'parent': 'STR-P03MR-CUS', 'parentfield': 'reorder_levels', 'parenttype': 'Item', 'idx': 1, 'warehouse': 'Principale - IPM', 'warehouse_reorder_qty': 1.0, 'warehouse_group': 'tutti i Magazzini - IPM', 'warehouse_reorder_level': 0.0, 'material_request_type': 'Purchase', 'doctype': 'Item Reorder'}]
      __class__ = <class 'frappe.model.document.Document'>
  File "apps/frappe/frappe/database/database.py", line 617, in get_values
    
  File "apps/frappe/frappe/database/database.py", line 884, in _get_values_from_table
    
  File "apps/frappe/frappe/query_builder/utils.py", line 86, in execute_query
    query, params = prepare_query(query)
      query = SELECT * FROM `tabUOM Conversion Detail` WHERE `parent`='STR-P03MR-CUS' AND `parenttype`='Item' AND `parentfield`='uoms' ORDER BY `idx` ASC
      args = ()
      kwargs = {'as_dict': True, 'debug': False, 'update': None, 'run': True, 'pluck': False}
      child_queries = []
      execute_child_queries = <function patch_query_execute.<locals>.execute_child_queries at 0x7f7d9ca08180>
      prepare_query = <function patch_query_execute.<locals>.prepare_query at 0x7f7d9bf434c0>
 
rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value (300 seconds)

@github-actions github-actions bot added the stock label Jan 31, 2024
@rohitwaghchaure rohitwaghchaure force-pushed the fixed-timeout-error-while-making-auto-mr branch from 0b9156b to 60f2393 Compare January 31, 2024 09:37
Copy link

codecov bot commented Jan 31, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (31f586f) 60.12% compared to head (60f2393) 60.13%.
Report is 9 commits behind head on develop.

❗ Current head 60f2393 differs from pull request most recent head 951023f. Consider uploading reports for the commit 951023f to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #39659   +/-   ##
========================================
  Coverage    60.12%   60.13%           
========================================
  Files          758      758           
  Lines        70951    70971   +20     
========================================
+ Hits         42662    42677   +15     
- Misses       28289    28294    +5     
Files Coverage Δ
...stock/doctype/material_request/material_request.py 69.76% <100.00%> (+0.08%) ⬆️
erpnext/stock/get_item_details.py 82.88% <100.00%> (-0.17%) ⬇️
erpnext/stock/reorder_item.py 78.20% <94.59%> (+3.75%) ⬆️

... and 5 files with indirect coverage changes

@rohitwaghchaure rohitwaghchaure force-pushed the fixed-timeout-error-while-making-auto-mr branch from 60f2393 to b7fb557 Compare January 31, 2024 10:06
@rohitwaghchaure rohitwaghchaure force-pushed the fixed-timeout-error-while-making-auto-mr branch from b7fb557 to 951023f Compare January 31, 2024 11:57
@rohitwaghchaure rohitwaghchaure merged commit 675a0b8 into frappe:develop Feb 5, 2024
13 checks passed
rohitwaghchaure added a commit that referenced this pull request Feb 5, 2024
…-39659

perf: timeout for auto material request through reorder level (backport #39659)
rohitwaghchaure added a commit that referenced this pull request Feb 5, 2024
…-39659

perf: timeout for auto material request through reorder level (backport #39659)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant