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

Python: Fix warnings from pytest #6703

Closed
wants to merge 8 commits into from
Closed

Conversation

Fokko
Copy link
Contributor

@Fokko Fokko commented Jan 30, 2023

Because TestType contains test in the name, pytest tries to collect it and run tests on it. Setting __test__ = False tells PyTest to ignore it

Also, s3 emits an error because we clean up buckets that still has content in it, so I've added some code to clean them up after we use the bucket.

Because TestType contains test in the name,
pytest tries to collect it and run tests on it.
Setting `__test__ = False` tells PyTest to ignore it

Also, s3 emits an error because we clean up buckets that
still has content in it, so I've added some code to clean them
up after we use the bucket.
python/pyproject.toml Outdated Show resolved Hide resolved
Co-authored-by: Ajantha Bhat <ajanthabhat@gmail.com>
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

One comment, it's non-blocking IMO for this since I don't think it's an issue when we actually run the tests but I think we should fix it at some point just so it's more robust

Bucket=BUCKET_NAME,
)
while response["KeyCount"] > 0:
_s3.delete_objects(Bucket=BUCKET_NAME, Delete={"Objects": [{"Key": obj["Key"]} for obj in response["Contents"]]})
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar Jan 30, 2023

Choose a reason for hiding this comment

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

I haven't checked the details of this test, but delete_objects can delete at max 1000 keys for a given bucket. We're probably not creating close to that much here which is why this is passing, but just so the logic is robust we probably want to handle that (if not here, we can do in a separate PR as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also no expert on the subject, but it looks like the max number of key returned is also 1000:
image
From: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.list_objects_v2

This will iterate until KeyCount is zero

@Fokko Fokko changed the title Python: Fix warnings from PyLint Python: Fix warnings from pytest Jan 30, 2023
@Fokko Fokko added this to the Python 0.4.0 release milestone Jan 30, 2023
@@ -422,6 +422,7 @@ def test_void_transform() -> None:

class TestType(IcebergBaseModel):
__root__: Transform[Any, Any]
__test__ = False
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 fixed in the other PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that was a PR to the 0.3.0 branch, so we can create another RC from that branch without having the latest pyarrow changes released along with it.

@@ -67,7 +67,18 @@ def get_random_databases(n: int) -> Set[str]:

@pytest.fixture(name="_bucket_initialize")
def fixture_s3_bucket(_s3) -> None: # type: ignore
_s3.create_bucket(Bucket=BUCKET_NAME)
bucket = _s3.create_bucket(Bucket=BUCKET_NAME)
yield bucket
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change the return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is a bit of an interesting fixture. It didn't return anything before, and now it just blocks the yield until the test is passed, and then cleans it up.

Copy link
Contributor

@rdblue rdblue left a comment

Choose a reason for hiding this comment

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

Looks good to me when tests are passing.

@Fokko
Copy link
Contributor Author

Fokko commented Feb 1, 2023

This PR needs a bit of TLC; it looks like the adlfs test also throws some warnings that we need to fix.

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.

4 participants