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

refactor: add internal with_operation_context #2525

Merged
merged 8 commits into from
Jun 16, 2023

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Jun 15, 2023

This PR refactors our operations to use a decorator for providing an error context. This makes it easier to add new functions, but also improves readability.

Closes #1839

@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #2525 (c5cd53e) into main (f928ba2) will increase coverage by 0.20%.
The diff coverage is 92.48%.

Additional details and impacted files
Impacted Files Coverage Δ
src/awkward/operations/ak_mean.py 82.22% <57.14%> (+4.44%) ⬆️
src/awkward/operations/ak_std.py 85.36% <57.14%> (+4.87%) ⬆️
src/awkward/operations/ak_var.py 83.33% <57.14%> (+4.16%) ⬆️
src/awkward/highlevel.py 76.82% <60.00%> (+1.28%) ⬆️
src/awkward/operations/ak_from_avro_file.py 80.00% <63.63%> (ø)
src/awkward/operations/ak_from_arrow_schema.py 70.00% <66.66%> (+10.00%) ⬆️
src/awkward/operations/ak_from_cupy.py 83.33% <66.66%> (+16.66%) ⬆️
src/awkward/operations/ak_from_rdataframe.py 33.33% <66.66%> (+7.24%) ⬆️
src/awkward/operations/ak_nan_to_none.py 45.45% <66.66%> (+7.35%) ⬆️
src/awkward/operations/ak_to_cupy.py 58.33% <66.66%> (+12.87%) ⬆️
... and 94 more

@agoose77 agoose77 temporarily deployed to docs-preview June 15, 2023 16:20 — with GitHub Actions Inactive
@agoose77 agoose77 temporarily deployed to docs-preview June 15, 2023 17:17 — with GitHub Actions Inactive
@agoose77 agoose77 requested a review from jpivarski June 15, 2023 17:31
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

This is definitely a maintenance win. I didn't check that the error messages still look okay. If you've checked that, then merge it!

@agoose77 agoose77 temporarily deployed to docs-preview June 15, 2023 18:16 — with GitHub Actions Inactive
@agoose77
Copy link
Collaborator Author

I've changed a couple of the error messages so that the keyword argument names match the signatures (in places where we invoke the context manager manually), and made some of these cases render the self argument by position (for readability).

@agoose77 agoose77 enabled auto-merge (squash) June 15, 2023 19:11
@agoose77 agoose77 temporarily deployed to docs-preview June 15, 2023 19:20 — with GitHub Actions Inactive
We want to avoid stateful iterators
@agoose77 agoose77 temporarily deployed to docs-preview June 15, 2023 19:58 — with GitHub Actions Inactive
@agoose77 agoose77 merged commit 96b26b8 into main Jun 16, 2023
@agoose77 agoose77 deleted the agoose77/refactor-error-context branch June 16, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace with OperationErrorContext with a function decorator
2 participants