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

Fail when main session cannot be loaded. #25617

Merged
merged 4 commits into from
Mar 7, 2023

Conversation

tvalentyn
Copy link
Contributor

@tvalentyn tvalentyn commented Feb 23, 2023

Sometimes when users don't install runtime dependencies, main session cannot load. Fail with an error message when this happens.

To make sure the error is reported to a runner, delay the failure until SDK startes to process bundles. This mechanism could potentially be reused for other worker startup misconfigurations.

Addresses #25401


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

@tvalentyn
Copy link
Contributor Author

Run Python_Transforms PreCommit

@tvalentyn
Copy link
Contributor Author

Run PythonFormatter PreCommit

@tvalentyn
Copy link
Contributor Author

r: @psobot
cc: @robertwb

@github-actions
Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

@codecov
Copy link

codecov bot commented Feb 23, 2023

Codecov Report

Merging #25617 (a384f49) into master (39cab94) will increase coverage by 0.00%.
The diff coverage is 40.00%.

@@           Coverage Diff           @@
##           master   #25617   +/-   ##
=======================================
  Coverage   72.81%   72.81%           
=======================================
  Files         775      775           
  Lines      102928   102934    +6     
=======================================
+ Hits        74948    74956    +8     
+ Misses      26525    26523    -2     
  Partials     1455     1455           
Flag Coverage Δ
python 81.96% <40.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...thon/apache_beam/runners/worker/sdk_worker_main.py 76.87% <28.57%> (-0.77%) ⬇️
...ks/python/apache_beam/runners/worker/sdk_worker.py 89.20% <66.66%> (-0.11%) ⬇️
...eam/runners/portability/fn_api_runner/execution.py 93.13% <0.00%> (+0.63%) ⬆️
sdks/python/apache_beam/internal/metrics/metric.py 94.00% <0.00%> (+1.00%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@psobot psobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me - just left two suggestions inline. Thanks for the super-quick turnaround on this @tvalentyn!

@@ -120,9 +121,17 @@ def create_harness(environment, dry_run=False):
'Could not load main session: %s', exception_details, exc_info=True)
raise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it also be useful to set deferred_exception here instead raising this CorruptMainSessionException directly?

Copy link
Contributor Author

@tvalentyn tvalentyn Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are such errors transient or permanent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a comment on your PR introducing this exception I assumed these were transient, if so, we can keep it as is to create less noise.

exception_details = traceback.format_exc()
_LOGGER.error(
'Could not load main session: %s', exception_details, exc_info=True)
deferred_exception = CorruptMainSessionException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if CorruptMainSessionException is the best exception type to use here, as the main session file isn't actually corrupted in this case. Would ImportError be appropriate?

Suggested change
deferred_exception = CorruptMainSessionException(
deferred_exception = ImportError(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we rename it to LoadMainSessionException to fit both scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made this change.

@tvalentyn
Copy link
Contributor Author

Run Portable_Python PreCommit

@tvalentyn tvalentyn merged commit 2011cfc into apache:master Mar 7, 2023
@tvalentyn tvalentyn deleted the main_session_error branch March 7, 2023 03:14
ruslan-ikhsan pushed a commit to akvelon/beam that referenced this pull request Mar 10, 2023
@psobot
Copy link
Contributor

psobot commented Mar 13, 2023

Catching up on this - thanks for merging @tvalentyn! Appreciate the super quick turnaround. 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants