villebro commented on code in PR #22328:
URL: https://github.com/apache/superset/pull/22328#discussion_r1039686343


##########
superset/tasks/utils.py:
##########
@@ -0,0 +1,94 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+from typing import List, Optional, Tuple, TYPE_CHECKING, Union
+
+from flask import current_app, g
+
+from superset.tasks.exceptions import ExecutorNotFoundError
+from superset.tasks.types import ExecutorType
+
+if TYPE_CHECKING:
+    from superset.models.dashboard import Dashboard
+    from superset.models.slice import Slice
+    from superset.reports.models import ReportSchedule
+
+
+# pylint: disable=too-many-branches
+def get_executor(
+    executor_types: List[ExecutorType],
+    model: Union[Dashboard, ReportSchedule, Slice],
+    initiator: Optional[str] = None,
+) -> Tuple[ExecutorType, str]:

Review Comment:
   The reason why this function returns the username as a string, and not the 
`User` object, is because this function will be called frequently (e.g. when 
getting all charts/dashboards). Since we only know the selenium username in the 
config, we would otherwise have to fetch it from the metastore, causing 
unnecessary round trips to the metastore.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to