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

Give users easier access to container logs #470

Merged
merged 8 commits into from
Jan 9, 2025
Merged

Conversation

BSchilperoort
Copy link
Member

@BSchilperoort BSchilperoort commented Dec 10, 2024

Closes #469, #231

Usage example:
image

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 10 lines in your changes missing coverage. Please review.

Project coverage is 78.49%. Comparing base (cf5f3c9) to head (09e8d3b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/ewatercycle/base/model.py 16.66% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
- Coverage   78.89%   78.49%   -0.40%     
==========================================
  Files          28       28              
  Lines        1876     1888      +12     
  Branches      159      162       +3     
==========================================
+ Hits         1480     1482       +2     
- Misses        337      347      +10     
  Partials       59       59              
Files with missing lines Coverage Δ
src/ewatercycle/base/model.py 92.42% <16.66%> (-4.89%) ⬇️

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@BSchilperoort
Copy link
Member Author

BSchilperoort commented Dec 10, 2024

@RolfHut to review you could just test the functionality in a notebook you are already using somewhere else.

Install this in-dev version of ewatercycle in your terminal with:

python -m pip install --no-deps https://github.com/eWaterCycle/ewatercycle/archive/refs/heads/main.zip

This should not mess up your environment (due to the no-deps flag only this package will be updated).


I know that the code coverage check is failing, but it's not trivial to write a test for this case and time is sadly limited.

@BSchilperoort
Copy link
Member Author

@ahmedfarhatx22 this should give you easy access to the model container logs :)

@RolfHut
Copy link
Contributor

RolfHut commented Dec 11, 2024

machines already running do not have remote BMI and now fall over...

@RolfHut
Copy link
Contributor

RolfHut commented Dec 11, 2024

in testing on HBV I get this error:

'HBV' object has no attribute 'logs'

screenshot:
Screenshot 2024-12-11 at 17 50 17

so maybe something goed wrong in error handling if a model does not support this?

@BSchilperoort
Copy link
Member Author

in testing on HBV I get this error:

'HBV' object has no attribute 'logs'

screenshot: Screenshot 2024-12-11 at 17 50 17

so maybe something goed wrong in error handling if a model does not support this?

It's a property of the ContainerizedModel class: any (grpc) containerized model should work.

I did add a check if the model is set up yet in 388f748, and improved the error messages.

@RolfHut
Copy link
Contributor

RolfHut commented Dec 12, 2024

Screenshot 2024-12-12 at 09 07 27

also a no at leaky bucket

@RolfHut
Copy link
Contributor

RolfHut commented Dec 12, 2024

in testing on HBV I get this error:
'HBV' object has no attribute 'logs'
screenshot: Screenshot 2024-12-11 at 17 50 17
so maybe something goed wrong in error handling if a model does not support this?

It's a property of the ContainerizedModel class: any (grpc) containerized model should work.

I did add a check if the model is set up yet in 388f748, and improved the error messages.

how do I pull your commit on my SRC machine? than I can check if this fixes it.

@BSchilperoort
Copy link
Member Author

I realize now I gave you the wrong command, sorry.

It should have been
python -m pip install --no-deps https://github.com/eWaterCycle/ewatercycle/archive/refs/heads/access-logs.zip

the other one was for main

@RolfHut
Copy link
Contributor

RolfHut commented Dec 12, 2024

tried that and same error on leaky bucket: no attribute 'logs'

Copy link
Member

@sverhoeven sverhoeven left a comment

Choose a reason for hiding this comment

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

Ran the notebook with model_instance.logs calls successfully.

However it would be nice to have some unit tests that take less work to setup.

@BSchilperoort
Copy link
Member Author

However it would be nice to have some unit tests that take less work to setup.

I considered this, but the logs are part of the containerized model, where testing relies on mocking a lot. As we don't actually start a container, I would have to mock the starting of the container, and mock the log return. At that point not much would be left to actually test as it's only mocks. The classes which actually implement the logs are in grpc4bmi and remotebmi. It would be good for this package to actually have a containerized model integrated which is used in unit tests, but that's not in the scope of this PR.

@BSchilperoort BSchilperoort merged commit b441c93 into main Jan 9, 2025
5 of 6 checks passed
@BSchilperoort BSchilperoort deleted the access-logs branch January 9, 2025 12:16
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.

Wrapping of BMI models with OptionalDestBmi/MemoizedBmi drops .logs()
3 participants