Skip to content

Enable prism by default (where supported) #34612

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

Merged
merged 90 commits into from
Jul 15, 2025
Merged

Conversation

damccorm
Copy link
Contributor

@damccorm damccorm commented Apr 11, 2025

Changes the default Python runner to be prism (when prism is supported). Excludes it from interactive environments for now.

There are a bunch of use cases automatically excluded, but this also required updating a bunch of tests. The 2 main breaking changes this introduces are:

  1. Instead of raising Python-specific exceptions, when Prism jobs fail a RuntimeError is always raised. To fix any tests relying on the old error, change your exception catching logic to look for broader errors and use regexes to verify the contents of the error. There are lots of examples of this in this PR.
  2. Prism names its metrics differently than the local runner. For this PR in Beam, I just kept all of those on the old FnApiRunner for now, but you could also just change the metric name you're looking for (this will be the eventual fix for these tests in this repo).

If this change breaks you in unexpected ways, please:

  1. Pin to the FnApiRunner instead of the DirectRunner. There are lots of examples of this in this PR.
  2. Comment in [Task]: Make Prism default #34549 describing your broken use case.

Part of #34549


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 or the workflows README to see a list of phrases to trigger workflows.

@damccorm
Copy link
Contributor Author

damccorm commented May 12, 2025

Looks like

def __ror__(self, left, label=None):
is the source of a lot of the test failures and that we're not handling applying transforms to non-PCollections in a portable-friendly way. This currently keys off of the process id and pipeline id (not-pickle safe), which is probably causing some problems -
def _allocate_materialized_pipeline(pipeline):

EDIT: I think that this is actually a function of pipelines double executing before #34921 was patched. So I think this is fine and my temporary patch can be removed

@@ -405,7 +405,7 @@ def get_all_options(
# sub-classes in the main session might be repeated. Pick last unique
# instance of each subclass to avoid conflicts.
subset = {}
parser = _BeamArgumentParser()
parser = _BeamArgumentParser(allow_abbrev=False)
Copy link
Contributor Author

@damccorm damccorm May 13, 2025

Choose a reason for hiding this comment

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

This was causing all sorts of problems because --output was getting assigned to --output_executable_path (https://github.com/apache/beam/blob/f6d209ff6a3ea638f11dfb96e52f7c21292dfbc1/sdks/python/apache_beam/options/pipeline_options.py#L1693C12-L1693C34) which meant the portable runner couldn't find prism

@github-actions github-actions bot added the io label May 14, 2025
@github-actions github-actions bot added the yaml label May 15, 2025
@github-actions github-actions bot removed the yaml label May 15, 2025
@github-actions github-actions bot removed the prism label Jun 27, 2025
@damccorm damccorm marked this pull request as ready for review July 1, 2025 16:32
@damccorm
Copy link
Contributor Author

damccorm commented Jul 1, 2025

R: @shunping

Copy link
Contributor

github-actions bot commented Jul 1, 2025

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@@ -128,7 +128,8 @@ def test_predict_tensor_with_batch_size(self):
model = _create_mult2_model()
model_path = os.path.join(self.tmpdir, f'mult2_{uuid.uuid4()}.keras')
tf.keras.models.save_model(model, model_path)
with TestPipeline() as pipeline:
# FnApiRunner guarantees large batches, which this pipeline assumes
Copy link
Collaborator

@shunping shunping Jul 14, 2025

Choose a reason for hiding this comment

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

This could be due to the fact that prism is using accelerated processing time by default. The processing-time timer in BatchElements may not work as expected.

PR #35202 added an experimental flag for using real-time processing time, which may help to resolve this problem.

# more targeted, but for now we'll just ignore all unsafe triggers.
if pipeline.allow_unsafe_triggers:
self.supported_by_prism_runner = False
# TODO(https://github.com/apache/beam/issues/33623): Prism currently
Copy link
Collaborator

@shunping shunping Jul 14, 2025

Choose a reason for hiding this comment

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

What else problems do you face here when using prism in interactive mode?

@@ -254,8 +254,8 @@ def test_constant_batch_no_metrics(self):
self.assertEqual(len(results["distributions"]), 0)

def test_grows_to_max_batch(self):
# Assumes a single bundle...
with TestPipeline() as p:
# Assumes a single bundle, so we pin to the FnApiRunner
Copy link
Collaborator

@shunping shunping Jul 14, 2025

Choose a reason for hiding this comment

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

Do we have a reliable way of getting elements in a single bundle? Maybe only for testing purpose. This seems to be a recurrent issue I meet when I am working on some other tests.

Alternatively, we may be able to change the tests so that they won't rely on this assumption, but it is not working all the time.

Copy link
Collaborator

@shunping shunping left a comment

Choose a reason for hiding this comment

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

Thank you for making this big step for prism! I really appreciate the thorough and detailed work you've put into this.

The overall PR looks solid. I've left a few minor comments for your consideration.

@damccorm
Copy link
Contributor Author

damccorm commented Jul 15, 2025

There were failing postcommit tests, but not on prism, so I'm not going to block merging

@damccorm damccorm merged commit f7071ef into master Jul 15, 2025
108 of 122 checks passed
@damccorm damccorm deleted the users/damccorm/prismByDefault branch July 15, 2025 13:36
@Abacn
Copy link
Contributor

Abacn commented Jul 16, 2025

@damccorm
Copy link
Contributor Author

There are tests failing after this PR, could it be related?

https://github.com/apache/beam/actions/workflows/beam_PostCommit_Python_Xlang_Gcp_Direct.yml?query=event%3Aschedule

https://github.com/apache/beam/actions/workflows/beam_PostCommit_Yaml_Xlang_Direct.yml?query=event%3Aschedule

I think it likely is - #35608 tested these workflows with extended timeouts and they still failed. Temporarily reverting the core of this change here - #35610

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

Successfully merging this pull request may close these issues.

4 participants