ghostbody opened a new issue #8238: Debug Executor: 'dict' object has no 
attribute 'remove'
URL: https://github.com/apache/airflow/issues/8238
 
 
   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the 
following questions.
   Don't worry if they're not all applicable; just try to include what you can 
:-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   Please complete the next sections or the issue will be closed.
   This questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**: v1.10.9
   
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**:
   - **OS** (e.g. from /etc/os-release): ubuntu 18.04
   - **Kernel** (e.g. `uname -a`):
   - **Install tools**:
   - **Others**:
   **What happened**:
   
   Error ocurs when using `DebugExecutor`
   
   ```
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py",
 line 1380, in _execute
       self._execute_helper()
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py",
 line 1441, in _execute_helper
       if not 
self._validate_and_run_task_instances(simple_dag_bag=simple_dag_bag):
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py",
 line 1503, in _validate_and_run_task_instances
       self.executor.heartbeat()
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/executors/base_executor.py",
 line 134, in heartbeat
       self.sync()
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/executors/debug_executor.py",
 line 71, in sync
       task_succeeded = self._run_task(ti)
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/executors/debug_executor.py",
 line 84, in _run_task
       self.change_state(key, State.FAILED)
     File 
"/some-path/.virtualenv/lib/python3.7/site-packages/airflow/executors/debug_executor.py",
 line 148, in change_state
       self.running.remove(key)
   AttributeError: 'dict' object has no attribute 'remove'
   ```
   
   <!-- (please include exact error messages if you can) -->
   
   **What you expected to happen**:
   
   This error shoud not happen.
   
   <!-- What do you think went wrong? -->
   
   **How to reproduce it**:
   <!---
   
   As minimally and precisely as possible. Keep in mind we do not have access 
to your cluster or dags.
   
   If you are using kubernetes, please attempt to recreate the issue using 
minikube or kind.
   
   ## Install minikube/kind
   
   - Minikube https://minikube.sigs.k8s.io/docs/start/
   - Kind https://kind.sigs.k8s.io/docs/user/quick-start/
   
   If this is a UI bug, please provide a screenshot of the bug or a link to a 
youtube video of the bug in action
   
   You can include images using the .md sytle of
   ![alt text](http://url/to/img.png)
   
   To record a screencast, mac users can use QuickTime and then create an 
unlisted youtube video with the resulting .mov file.
   
   --->
   
   1. use `CeleryExecutor` to run some dags. 
   2. switch to `DebugExecutor`
   3. this error happens
   
   
   **Anything else we need to know**:
   
   
   <!--
   
   How often does this problem occur? Once? Every time etc?
   
   Any relevant logs to include? Put them here in side a detail tag:
   <details><summary>x.log</summary> lots of stuff </details>
   
   -->
   
   I am sure that some of the logic in `DebugExecutor` is not correct
   
   in `BaseExecutor`, there is a instance variable named `running`, which is 
initialized with a `{}` notation.
   
   `airflow/executors/base_executor.py:46`
   ```python
   class BaseExecutor(LoggingMixin):
   
       def __init__(self, parallelism=PARALLELISM):
           """
           Class to derive in order to interface with executor-type systems
           like Celery, Mesos, Yarn and the likes.
   
           :param parallelism: how many jobs should run at one time. Set to
               ``0`` for infinity
           :type parallelism: int
           """
           self.parallelism = parallelism
           self.queued_tasks = OrderedDict()
           self.running = {}                                   # here
           self.event_buffer = {}
   ```
   
   **However** in the `DebugExector` class, it use the variable as both `Set` 
and `Dict`.
   
   `airflow/executors/debug_executor.py:130`
   ```python
       def trigger_tasks(self, open_slots):
           """
           Triggers tasks. Instead of calling exec_async we just
           add task instance to tasks_to_run queue.
   
           :param open_slots: Number of open slots
           """
           sorted_queue = sorted(
               [(k, v) for k, v in self.queued_tasks.items()],
               key=lambda x: x[1][1],
               reverse=True,
           )
           for _ in range(min((open_slots, len(self.queued_tasks)))):
               key, (_, _, _, ti) = sorted_queue.pop(0)
               self.queued_tasks.pop(key)
               self.running[key] = ti                                           
    # here, use as a dict
               self.tasks_to_run.append(ti)  # type: ignore
   ```
   
   but here, `airflow/executors/debug_executor.py:146`
   ```python
       def change_state(self, key, state):
           self.log.debug("Popping %s from executor task queue.", key)
           self.running.remove(key)                                             
# here, use a set. And there is no `remove` method for a dict.
           self.event_buffer[key] = state
   ```
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to