You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "MaksYermak (via GitHub)" <gi...@apache.org> on 2024/05/02 11:54:41 UTC
[PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
MaksYermak opened a new pull request, #39371:
URL: https://github.com/apache/airflow/pull/39371
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
In this PR I have prepared a fix for an error in deferrable mode for `BeamRunJavaPipelineOperator`.
This error happens on a distributed system when the user has `trigger` and `worker` on different machines. `BeamRunJavaPipelineOperator` needs a local `jar` file for starting a Job. Users can specify a path to `jar` file which is located in GCS bucket and then the operator will download this file to the local system. In the current deferrable mode implementation operator downloads `jar` file before going to the deferrable mode. It means that on a distributed system the file is downloaded on the `worker` machine not on the `trigger` machine. And then when the operator tries to execute a Job on the `trigger` machine Airflow throws an error that the executable `jar` file does not exist.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on PR #39371:
URL: https://github.com/apache/airflow/pull/39371#issuecomment-2109949565
@potiuk @Lee-W I have updated the code.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #39371:
URL: https://github.com/apache/airflow/pull/39371#issuecomment-2102274847
Hi @eladkal @potiuk !
Can you please check the changes here? Thanks!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1595379583
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
I am not sure (I am not that experienced in asyncio) if that one is correct. the docs https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop
suggest that if get_event_loop() is run in the coroutine, it will not create a new event loop - it will return the current loop, and suggestion is to use `get_running_loop` instead, so the comment is quite a bit misleading.
Can you explain what's the expected behaviour here please ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1599729072
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
@potiuk @Lee-W I have checked. We can't get rid of `event_loop` here, because as I understand it's only one option to execute a synchronous method in async code. Also we can't change this method to async, because google does not have async client for this method. But we can change `get_event_loop` to `get_running_loop` for improving code quality. I will do it in the next commit.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1595380774
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
BTW. I see it was copied from the previous implementation but it might be good to clarify and possibly fix it to use get_running_loop() (and fix the comment) if that's what is expected.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1600189482
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
Thanks for checking it.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1600189482
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
Thanks for checking it!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W merged PR #39371:
URL: https://github.com/apache/airflow/pull/39371
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix deferrable mode for BeamRunJavaPipelineOperator [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #39371:
URL: https://github.com/apache/airflow/pull/39371#discussion_r1597917950
##########
airflow/providers/apache/beam/triggers/beam.py:
##########
@@ -233,6 +235,22 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override]
if is_running:
await asyncio.sleep(self.poll_sleep)
try:
+ # Creating a new event loop to manage I/O operations asynchronously
Review Comment:
I also feel like this might not be necessary if we already run it in the trigger. @MaksYermak Could you please check whether we can get rid of the event_loop? Thanks!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org