sul-dlss / libsys-airflow

Airflow DAGS for migrating and managing ILS data into FOLIO along with other LibSys workflows
Apache License 2.0
5 stars 0 forks source link

add_marc_tags_to_records failed with KeyError #1328

Closed shelleydoljack closed 1 month ago

shelleydoljack commented 1 month ago

I uploaded the a test file of 8 instances and selected the fund with druid bt942vy4674. The dag runs failed at the add_marc_tags_to_records task:

[2024-10-23, 22:32:02 UTC] {taskinstance.py:2731} ERROR - Task failed with exception
Traceback (most recent call last):
  File "/home/airflow/.local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 444, in _execute_task
    result = _execute_callable(context=context, **execute_callable_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/airflow/.local/lib/python3.11/site-packages/airflow/models/taskinstance.py", line 414, in _execute_callable
    return execute_callable(context=context, **execute_callable_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/airflow/.local/lib/python3.11/site-packages/airflow/decorators/base.py", line 241, in execute
    return_value = super().execute(context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/airflow/.local/lib/python3.11/site-packages/airflow/operators/python.py", line 200, in execute
    return_value = self.execute_callable()
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/airflow/.local/lib/python3.11/site-packages/airflow/operators/python.py", line 217, in execute_callable
    return self.python_callable(*self.op_args, **self.op_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/airflow/libsys_airflow/plugins/digital_bookplates/bookplates.py", line 116, in add_marc_tags_to_record
    marc_tags = kwargs["marc_instances_tags"]
                ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'marc_instances_tags'

https://sul-libsys-airflow-dev.stanford.edu/dags/digital_bookplate_979/grid?root=&execution_date=2024-10-23T22%3A30%3A49.775476%2B00%3A00&tab=logs&dag_run_id=manual__2024-10-23T22%3A30%3A49.661478%2B00%3A00&task_id=add_marc_tags_to_record

Neat! You can download the file I used here: https://sul-libsys-airflow-dev.stanford.edu/digital_bookplates_download/

shelleydoljack commented 1 month ago

Hi Josh! Just wanted to confirm that the data coming out of instances_from_po_lines and eventually triggering digital_bookplates_979 DAG will look like this:

{
  "b6e80385-3be3-4e84-a530-d89d072af46b": [
    {
      "fund_name": "STEINMETZ",
      "druid": "nc092rd1979",
      "image_filename": "nc092rd1979_00_0001.jp2",
      "title": "Verna Pace Steinmetz Endowed Book Fund in History"
    },
    {
      "fund_name": "WHITEHEAD",
      "druid": "ph944pq1002",
      "image_filename": "ph944pq1002_00_0001.jp2",
      "title": "Barry Whitehead Memorial Book Fund"
    }
  ]
}

for the case where one instance was purchased with multiple bookplate funds. See https://github.com/sul-dlss/libsys-airflow/issues/1322#issuecomment-2436382511