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

Use request.addfinalizer instead of the yield based approach in integ tests #2089

Merged
merged 3 commits into from
Dec 1, 2021

Conversation

achals
Copy link
Member

@achals achals commented Nov 25, 2021

Signed-off-by: Achal Shah achals@gmail.com

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

none

Signed-off-by: Achal Shah <achals@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2021

Codecov Report

Merging #2089 (a2d5521) into master (54d0f3a) will decrease coverage by 25.43%.
The diff coverage is 10.41%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2089       +/-   ##
===========================================
- Coverage   83.44%   58.01%   -25.44%     
===========================================
  Files         100      100               
  Lines        8077     8088       +11     
===========================================
- Hits         6740     4692     -2048     
- Misses       1337     3396     +2059     
Flag Coverage Δ
integrationtests ?
unittests 58.01% <10.41%> (-0.10%) ⬇️

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

Impacted Files Coverage Δ
...ts/integration/feature_repos/repo_configuration.py 46.73% <0.00%> (-48.06%) ⬇️
...s/integration/registration/test_universal_types.py 36.00% <0.00%> (-64.00%) ⬇️
sdk/python/tests/conftest.py 61.79% <21.73%> (-30.42%) ⬇️
.../integration/online_store/test_universal_online.py 15.34% <0.00%> (-82.80%) ⬇️
.../integration/online_store/test_online_retrieval.py 17.39% <0.00%> (-82.61%) ⬇️
...fline_store/test_universal_historical_retrieval.py 19.29% <0.00%> (-80.12%) ⬇️
sdk/python/tests/utils/online_read_write_test.py 20.68% <0.00%> (-79.32%) ⬇️
...gration/registration/test_feature_service_apply.py 31.25% <0.00%> (-68.75%) ⬇️
sdk/python/feast/infra/online_stores/redis.py 26.97% <0.00%> (-67.11%) ⬇️
sdk/python/tests/data/data_creator.py 34.78% <0.00%> (-65.22%) ⬇️
... and 52 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 54d0f3a...a2d5521. Read the comment docs.

def environment(request):
with construct_test_environment(request.param) as e:
yield e
def environment(request, tmp_path_factory, worker_id):
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is tmp_path_factory needed here? doesn't look like it's being used

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah. Using pytest-xdist, each worker creates its own version of fixtures. I had a version of this PR that creates the fixture in a single worker and shares it across workers by pickling it, but that won't work because when a single fixture is used across workers, there's data corruption (because multiple processes write to the same registry location or sqlite online store).

tmp_path_factory is a holdover from there. Removing.

with construct_test_environment(request.param) as e:
yield e
def environment(request, tmp_path_factory, worker_id):
logger.info("Worker: %s, Request: %s", worker_id, request.param)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be debug level?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah

e = construct_test_environment(IntegrationTestRepoConfig(online_store=REDIS_CONFIG))

def cleanup():
logger.info("Running cleanup in %s, Request: %s", worker_id, request.param)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is request.param supposed to represent here?

Copy link
Member Author

Choose a reason for hiding this comment

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

request.param refers to the config used to create the environment, from params=FULL_REPO_CONFIGS



@pytest.fixture(scope="session")
def universal_data_sources(environment):
def universal_data_sources(request, environment, tmp_path_factory, worker_id):
Copy link
Collaborator

Choose a reason for hiding this comment

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

again, why do we have tmp_path_factory and worker_id here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't. Removing.

Signed-off-by: Achal Shah <achals@gmail.com>
Signed-off-by: Achal Shah <achals@gmail.com>
Copy link
Collaborator

@felixwang9817 felixwang9817 left a comment

Choose a reason for hiding this comment

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

/lgtm

@feast-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [achals,felixwang9817]

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

def cleanup():
e.feature_store.teardown()

request.addfinalizer(cleanup)
Copy link
Collaborator

Choose a reason for hiding this comment

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

but isn't this code equivalent to the previous version with context managers?
I believe pytest under the hook does the same addfinalizer, https://github.com/pytest-dev/pytest/blob/main/src/_pytest/fixtures.py#L921

@feast-ci-bot feast-ci-bot merged commit 3cbd75c into feast-dev:master Dec 1, 2021
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