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

chore: Generate environments for each individual test based on its markers/fixtures #2648

Merged
merged 2 commits into from
May 11, 2022

Conversation

pyalex
Copy link
Collaborator

@pyalex pyalex commented May 6, 2022

Signed-off-by: Oleksii Moskalenko moskalenko.alexey@gmail.com

What this PR does / why we need it:

Test environment is being generated individually for each integration test based on its markers and/or requested fixtures. This allows us to drop some unnecessary use cases (eg, looping various online stores against test_historical_features) and shorten total run time.

The main change is pytest_generate_tests function in conftest.py that replaces static declaration of repo configs. It generates environments for each test and retrieves them from configs cache, so that environments could be shared between different tests.

Which issue(s) this PR fixes:

Fixes #

@pyalex pyalex changed the title chore: Generate environments for each individual test based on their markers [WIP] chore: Generate environments for each individual test based on their markers May 6, 2022
@pyalex pyalex added ok-to-test and removed size/XL labels May 6, 2022
@codecov-commenter
Copy link

codecov-commenter commented May 6, 2022

Codecov Report

Merging #2648 (900df33) into master (640ff12) will decrease coverage by 21.65%.
The diff coverage is 53.73%.

@@             Coverage Diff             @@
##           master    #2648       +/-   ##
===========================================
- Coverage   80.55%   58.89%   -21.66%     
===========================================
  Files         163      164        +1     
  Lines       13815    13761       -54     
===========================================
- Hits        11128     8105     -3023     
- Misses       2687     5656     +2969     
Flag Coverage Δ
integrationtests ?
unittests 58.89% <53.73%> (+0.28%) ⬆️

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

Impacted Files Coverage Δ
sdk/python/feast/feature_logging.py 49.45% <0.00%> (-39.44%) ⬇️
...s/contrib/spark_offline_store/tests/data_source.py 40.42% <ø> (ø)
...thon/feast/infra/online_stores/contrib/postgres.py 32.69% <0.00%> (ø)
sdk/python/feast/infra/online_stores/datastore.py 39.90% <0.00%> (-10.33%) ⬇️
...tegration/feature_repos/universal/feature_views.py 36.11% <ø> (-45.84%) ⬇️
...s/contrib/trino_offline_store/tests/data_source.py 47.05% <25.00%> (ø)
...ests/integration/e2e/test_python_feature_server.py 32.39% <25.00%> (-67.61%) ⬇️
sdk/python/feast/feature_server.py 34.28% <33.33%> (-38.85%) ⬇️
...ts/integration/feature_repos/repo_configuration.py 55.17% <37.50%> (-34.28%) ⬇️
...on/tests/integration/e2e/test_go_feature_server.py 41.66% <42.85%> (-56.61%) ⬇️
... and 102 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 640ff12...900df33. Read the comment docs.

@pyalex pyalex force-pushed the simplify-tests branch 2 times, most recently from 134251c to b58c052 Compare May 9, 2022 18:56
@@ -78,7 +78,7 @@ func (b *MemoryBuffer) getArrowSchema() (*arrow.Schema, error) {
fields = append(fields, arrow.Field{Name: featureName, Type: arrowType})
fields = append(fields, arrow.Field{
Name: fmt.Sprintf("%s__timestamp", featureName),
Type: arrow.FixedWidthTypes.Timestamp_s})
Type: arrow.FixedWidthTypes.Timestamp_ms})
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this should in a separate PR, unless it's fixing some bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is reverted


AVAILABLE_OFFLINE_STORES = [("local", PostgreSQLDataSourceCreator)]

AVAILABLE_ONLINE_STORES = {"postgres": (POSTGRES_ONLINE_CONFIG, None)}
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use the AVAILABLE_OFFLINE_STORES here as well? POSTGRES_ONLINE_CONFIG assumes you have a local version of postgres running and a containerized version is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines +217 to +196
if "universal_offline_stores" in markers:
offline_stores = AVAILABLE_OFFLINE_STORES
else:
# default offline store for testing online store dimension
offline_stores = [("local", FileDataSourceCreator)]

online_stores = None
if "universal_online_stores" in markers:
Copy link
Member

Choose a reason for hiding this comment

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

Should we get rid of the universal flag? since it doesn't seem like the online and offline versions are more versatile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I need a name here that would represent that specific tests works with all offline stores (universal_offline_stores mark currently) or all online stores (universal_online_stores mark). Any ideas for a better name?

Copy link
Member

Choose a reason for hiding this comment

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

I meant the pytest.mark.universal flag (since it seems like this the universal_online_stores and universal_offline_stores together would represent the same thing that current flag is supposed to represent).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it. Removed universal.

@@ -8,63 +8,48 @@
import pyarrow as pa
import pytest

from feast import Entity
Copy link
Member

Choose a reason for hiding this comment

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

nit, from feast.entity import Entity (for tests)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 6 to 14
POSTGRES_ONLINE_CONFIG = {
"type": "postgres",
"host": "localhost",
"port": "5432",
"database": "postgres",
"db_schema": "feature_store",
"user": "postgres",
"password": "docker",
}
Copy link
Member

Choose a reason for hiding this comment

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

My PR changes this, #2650

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reverted

Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
query = client.query(kind="Row", ancestor=key)
while True:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

infinite looping here might hang the whole testing flow

@pyalex pyalex changed the title [WIP] chore: Generate environments for each individual test based on their markers chore: Generate environments for each individual test based on their markers May 11, 2022
@pyalex pyalex changed the title chore: Generate environments for each individual test based on their markers chore: Generate environments for each individual test based on its markers/fixtures May 11, 2022
_config_cache = {}


def pytest_generate_tests(metafunc):
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some docs to how this pytest_generate_tests thingy works? It's the first time I've seen it used and seems extremely powerful

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added comment.

Comment on lines +217 to +196
if "universal_offline_stores" in markers:
offline_stores = AVAILABLE_OFFLINE_STORES
else:
# default offline store for testing online store dimension
offline_stores = [("local", FileDataSourceCreator)]

online_stores = None
if "universal_online_stores" in markers:
Copy link
Member

Choose a reason for hiding this comment

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

I meant the pytest.mark.universal flag (since it seems like this the universal_online_stores and universal_offline_stores together would represent the same thing that current flag is supposed to represent).

@feast-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: achals, pyalex

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
@achals
Copy link
Member

achals commented May 11, 2022

/lgtm

Thanks for addressing! This looks great.

@feast-ci-bot feast-ci-bot merged commit d4b0b1a into feast-dev:master May 11, 2022
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