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

WP5 indiv process testing: code style improvements #21

Closed
wants to merge 7 commits into from

Conversation

soxofaan
Copy link
Member

@m-mohr I went through .../processing/test_example.py while playing with the individual process tests and made some minor code style tweaks along the way.
I wanted to run them with you first before merging into main.

included tweaks:

  • avoid in-place dict mutations
  • add type hints
  • use more keyword args for call robustness
  • more clearly mark internal helpers as private
  • finetune exception handling
  • finetune pytest asserts (where default value rendering should be good enough)

- avoid in-place dict mutations
- add type hints
- use more keyword args for call robustness
- more clearly mark internal helpers as private
- finetune exception handling
- finetune pytest asserts (where default value rendering should be good enough)
@soxofaan soxofaan requested a review from m-mohr January 16, 2024 11:06
except Exception as e:
# TODO: skipping on a generic `Exception` is very liberal and might hide real issues
Copy link
Member

@m-mohr m-mohr Jan 16, 2024

Choose a reason for hiding this comment

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

Unless we have a more specific handler, this should be kept for now and not just raise the exceptions. It's a behavioral change, not a code style change.

Copy link
Member Author

Choose a reason for hiding this comment

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

This liberal except clause hid a bug I introduced with this PR.
Luckily I noticed it in another way.

I guess your intention is to skip when something is not implemented, so I would propose to change it to
except NotImplementedError

Copy link
Member

Choose a reason for hiding this comment

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

I can only check what I meant once I can run it again ;-)

Copy link
Member

Choose a reason for hiding this comment

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

I'm going through it now to check what changes if we change to NotImplementedError and if the additional failures are test issues etc. Stay tuned ;-)

Copy link
Member

@m-mohr m-mohr Jan 17, 2024

Choose a reason for hiding this comment

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

I just pushed 7507407 which switches to only NotImplementedError and fixes a couple of mostly datetime-related things in the background so that test coverage is still similar. Feel free to have a look at the changes and whether they are inline with your changes.

Copy link
Member

@m-mohr m-mohr left a comment

Choose a reason for hiding this comment

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

Thanks. Some change requests, otherwise looks good in theory.
Wasn't able to run it, it looks like a recent merge corrupted the individual process tests.
pytest src/openeo_test_suite/tests/processes/processing/test_example.py --runner=dask worked before, is not running any longer.

@soxofaan
Copy link
Member Author

Wasn't able to run it, it looks like a recent merge corrupted the individual process tests.
pytest src/openeo_test_suite/tests/processes/processing/test_example.py --runner=dask worked before, is not running any longer.

what error do you get? Please create a bug ticket if that makes sense

@m-mohr
Copy link
Member

m-mohr commented Jan 16, 2024

Done: #23

@soxofaan soxofaan requested a review from m-mohr January 16, 2024 18:30
@soxofaan
Copy link
Member Author

I restored the liberal except: pytest.skip() logic and moved the custom assert messages back.
Unless you have more remarks, I'd like to move this forward and merge it.
(I'd like to work on some more unification across the different WPs and that would conflict too easily with this PR I guess)

example["throws"], result.__class__.__name__
)
# TODO: better way to report this warning?
_log.warning(
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this warning anylonger in the logs, I tried before this PR and after and these ones are missing. Any clue why?

Copy link
Member Author

Choose a reason for hiding this comment

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

logs of successful tests are hidden by default.
logs of failing tests should be visible

you can disable capturing of all logs (and print statements) with options --capture=no --log-cli-level=INFO

Copy link
Member

@m-mohr m-mohr Jan 17, 2024

Choose a reason for hiding this comment

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

But that shouldn't have changed. The number of successful/failing tests is the same, just the logs for this specific line are missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

do you have an example use case (process that fails on some implementation) for this, so I can play with this too?

Copy link
Member

Choose a reason for hiding this comment

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

Run pytest src/openeo_test_suite/tests/processes/processing/test_example.py --runner=dask both on this branch and on master.

You can then see differences:
grafik

@m-mohr m-mohr force-pushed the indiv-process-tests-code-style-tweaks branch from 7b28019 to 7507407 Compare January 17, 2024 13:20
@soxofaan soxofaan marked this pull request as draft January 19, 2024 20:57
@soxofaan
Copy link
Member Author

hmm this PR got in conflicting state with main branch.
I think I'm going to abort this, and just cherry pick some minor things

soxofaan added a commit that referenced this pull request Jan 19, 2024
soxofaan added a commit that referenced this pull request Jan 19, 2024
- avoid in-place dict mutations
- add type hints
- use more keyword args for call robustness
- more clearly mark internal helpers as private
- finetune exception handling
- finetune pytest asserts (where default value rendering should be good enough)

Rebased version of PR #21
@soxofaan
Copy link
Member Author

I see you merged main in this PR, but at the same time I managed to rebase PR #21 on latest main branch, and created new PR #32, which will give a cleaner history

I'm also considering to just cherrypick you "fix temporal issues" commit on util.py, to get that out of the way already

@m-mohr
Copy link
Member

m-mohr commented Jan 19, 2024

See #32

@m-mohr m-mohr closed this Jan 19, 2024
@m-mohr m-mohr deleted the indiv-process-tests-code-style-tweaks branch January 19, 2024 22:03
soxofaan added a commit that referenced this pull request Jan 22, 2024
- avoid in-place dict mutations
- add type hints
- use more keyword args for call robustness
- more clearly mark internal helpers as private
- finetune exception handling
- finetune pytest asserts (where default value rendering should be good enough)

Rebased version of PR #21
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.

2 participants