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

[yaml] Add enrichment transform to Beam YAML #32286

Merged
merged 11 commits into from
Oct 17, 2024

Conversation

reeba212
Copy link
Contributor

  1. Added enrichment transform
  2. Registered it in standard_providers.yaml
  3. Added integration and unit tests for enrichment transform

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.

@reeba212 reeba212 changed the title Add enrichment transform to Beam YAML [yaml] Add enrichment transform to Beam YAML Aug 22, 2024
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

sdks/python/apache_beam/yaml/yaml_enrichment.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/yaml/yaml_enrichment.py Outdated Show resolved Hide resolved
sdks/python/apache_beam/yaml/yaml_enrichment_test.py Outdated Show resolved Hide resolved
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@shunping
Copy link
Contributor

Thanks for contributing to Beam, @reeba212!

I see there is some lint problem you will need to fix in your code: https://github.com/apache/beam/actions/runs/10944933393/job/30387980829?pr=32286

Then, I also see the errors on when import feast package. Currently feast is not on our dependency list (i.e. setup.py), that's why those tests fail.

target/.tox-py310-cloud/py310-cloud/lib/python3.10/site-packages/apache_beam/yaml/yaml_enrichment.py:22: in <module>
    from apache_beam.transforms.enrichment_handlers.feast_feature_store import FeastFeatureStoreEnrichmentHandler
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    #
    # 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.
    #
    import logging
    import tempfile
    from pathlib import Path
    from typing import Any
    from typing import Callable
    from typing import List
    from typing import Mapping
    from typing import Optional
    
    import apache_beam as beam
    from apache_beam.io.filesystems import FileSystems
    from apache_beam.transforms.enrichment import EnrichmentSourceHandler
    from apache_beam.transforms.enrichment_handlers.utils import ExceptionLevel
>   from feast import FeatureStore
E   ModuleNotFoundError: No module named 'feast'

target/.tox-py310-cloud/py310-cloud/lib/python3.10/site-packages/apache_beam/transforms/enrichment_handlers/feast_feature_store.py:30: ModuleNotFoundError

@Polber, what's the plan for supporting the enrichment transform? To make tests green, we have a few options. For example:

  • including feast as the standard dependency of beam,
  • decorating yaml tests with "@pytest.mark.uses_feast", or
  • totally ignoring the feast handler.

What do you think?

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Left a couple comments to hopefully get tests green!

sdks/python/apache_beam/yaml/yaml_enrichment.py Outdated Show resolved Hide resolved
Copy link
Contributor

Reminder, please take a look at this pr: @shunping

Copy link
Contributor

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

Some tests are still failing. Could you please fix them?

@@ -69,7 +69,7 @@ def temp_bigquery_table(project, prefix='yaml_bq_it_'):
dataset_id = '%s_%s' % (prefix, uuid.uuid4().hex)
bigquery_client.get_or_create_dataset(project, dataset_id)
logging.info("Created dataset %s in project %s", dataset_id, project)
yield f'{project}:{dataset_id}.tmp_table'
yield f'{project}.{dataset_id}.tmp_table'
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC this is reused by EnrichmentTransform's BQ handler which uses the non-legacy form and BigQueryIO accepts both, so this should be safe

from apache_beam.yaml import options

try:
from apache_beam.transforms.enrichment import Enrichment
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps not to fix in this PR (but if not let's file a bug). It seems that Enrichment itself should not require GCP, only specific handlers.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

I think the only class imported is a custom Exception class

raise ValueError(
f'Unable to instantiate provider of type {type} '
f'at line {SafeLineLoader.get_line(spec)}: {exn}') from exn
if isinstance(exn, ModuleNotFoundError) and config.get('requires_gcp',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed in addition to the import guards in yaml_enrichment.py?

It would also be better to get an error on an attempted use rather than a print statement whenever this is imported without [gcp] installed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah you're right this isn't needed anymore. This was my initial solution for another test failure before I realized the imports needed to be disabled entirely to fix another test suite. I think this is redundant and misleading as you said at this point.

@reeba212 I added some comments on what to remove!

@Polber
Copy link
Contributor

Polber commented Oct 8, 2024

@robertwb Do you mind taking another look?

Copy link
Contributor

Reminder, please take a look at this pr: @shunping

@liferoad liferoad merged commit 33fdb23 into apache:master Oct 17, 2024
93 checks passed
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.

5 participants