-
Notifications
You must be signed in to change notification settings - Fork 1
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
R server #10
R server #10
Conversation
Merged eWaterCycle/bmi-r#3 |
Cool, I'm looking forward to trying it out! 🚀 |
|
||
``` r | ||
# install.packages("pak") | ||
pak::pak("github::eWaterCycle/remotebmi/R/remotebmi") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command does not work,
> pak::pak("github::eWaterCycle/remotebmi/R/remotebmi")
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Error:
! error in pak subprocess
Caused by error:
! Could not solve package dependencies:
* github::eWaterCycle/remotebmi/R/remotebmi: ! pkgdepends resolution error for
github::eWaterCycle/remotebmi/R/remotebmi.
Caused by error:
! Can't find R package in GitHub repo eWaterCycle/remotebmi in directory 'R/remotebmi'
Is that because of this:?
rename package from R/remotebmi to /remotebmir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the path is according to https://pak.r-lib.org/reference/pak_package_sources.html#github-packages-github-
I was using
cd R/remotebmi
R
devtools::load_all()
# and/or
devtools::install_local()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that uses main branch, try pak::pak("github::eWaterCycle/remotebmi/R/remotebmi#10")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I git cloned the repo and installed it from a local path. That worked fine
## basic example code | ||
|
||
pak::pak("github::ClaudiaBrauer/WALRUS") | ||
pak::pak("github::eWaterCycle/bmi-r") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get stuck on building the stringi
package. install.package("stringi")
fails to build, and R binaries are only available for Windows and MacOS, not linux 🙄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Managed to finally build it with install.packages("stringi", configure.args="--disable-pkg-config")
R/remotebmi/README.md
Outdated
array([0.0044]) | ||
client.get_var_nbytes('Q') | ||
'mm/h' | ||
# TODO get_var_nbytes should return int not str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting error! Seems like a mismapping of a function (get_var_units vs. get_var_nbytes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, seems I fixed it in https://github.com/eWaterCycle/grpc4bmi-examples/pull/10/files, but never completed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't fully follow the readme, but got past the errors and have WALRUS running 🥳
Something still seems to be going wrong. I can do the first update, but after the second .update() I can't use get_value anymore:
The running R server shows no errors |
What does R server say and what does curl do
|
Before the first update it returns nothing. After one update it returns So that looks OK. Running the curl command and then using get_value also works fine 😕 .
|
With httpx trace I see it fails when reusing connectionsfrom httpx import Client
client = Client(base_url='http://localhost:50051')
def log(event_name, info):
print(event_name, info)
In [326]: try:
...: client.post('/update', extensions={"trace": log})
...: except Exception as e:
...: print(e)
...:
connection.connect_tcp.started {'host': 'localhost', 'port': 50051, 'local_address': None, 'timeout': 5.0, 'socket_options': None}
connection.connect_tcp.complete {'return_value': <httpcore._backends.sync.SyncStream object at 0x7f6f19125910>}
http11.send_request_headers.started {'request': <Request [b'POST']>}
http11.send_request_headers.complete {'return_value': None}
http11.send_request_body.started {'request': <Request [b'POST']>}
http11.send_request_body.complete {'return_value': None}
http11.receive_response_headers.started {'request': <Request [b'POST']>}
http11.receive_response_headers.complete {'return_value': (b'HTTP/1.1', 204, b'No Content', [(b'Date', b'Thu, 03 Oct 2024 14:50:36 GMT'), (b'Content-Type', b'text/plain'), (b'Content-Encoding', b'gzip'), (b'Transfer-Encoding', b'chunked')])}
http11.receive_response_body.started {'request': <Request [b'POST']>}
http11.receive_response_body.complete {'return_value': None}
http11.response_closed.started {}
http11.response_closed.complete {'return_value': None}
In [327]: try:
...: client.post('/update', extensions={"trace": log})
...: except Exception as e:
...: print(e)
...:
http11.send_request_headers.started {'request': <Request [b'POST']>}
http11.send_request_headers.complete {'return_value': None}
http11.send_request_body.started {'request': <Request [b'POST']>}
http11.send_request_body.complete {'return_value': None}
http11.receive_response_headers.started {'request': <Request [b'POST']>}
http11.receive_response_headers.failed {'exception': RemoteProtocolError(RemoteProtocolError("illegal status line: bytearray(b'14')"))}
http11.response_closed.started {}
http11.response_closed.complete {'return_value': None}
illegal status line: bytearray(b'14') Each time it fails it is not making a connection.connect_tcp.started message. |
Error happens sometimes on POST /update on n Ubuntu 22.04 in wsl with R 44.1, Python 3.11rc0, Python 3.12.6, but not with urllib
telnet
Unable to replicate on Ubuntu 24.04 with R 4.4.1, Python 3.12.3, httpx 0.27.2, fiery 1.2.1, routr 0.4.1, reqres 0.2.5, httpuv 1.6.15 (installed via mamba) |
I stopped the reusing of the same connection. @BSchilperoort could you try again |
Seems to work properly now! I did notice that Details
>>> client.get_input_var_names()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bart/git/remotebmi/python/remotebmi/client/client.py", line 41, in get_input_var_names
return response.json()
^^^^^^^^^^^^^^^
File "/home/bart/git/remotebmi/.venv/lib/python3.12/site-packages/httpx/_models.py", line 766, in json
return jsonlib.loads(self.content, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) |
Tested all methods exposed by walrus, get_input_var_names is still giving error due to R return empty list as empty string somehow. |
Could not get packages to be installed just for tests
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Need to raise coverage of https://app.codecov.io/gh/eWaterCycle/remotebmi/blob/r-server/R%2Fremotebmi%2FR%2Froute.R |
Coverage is now 97.36% |
…ome request validation
Added workaround in 27a583f |
TODO