-
Notifications
You must be signed in to change notification settings - Fork 17
✨(api) add xAPI statement forwarding background task #199
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
Conversation
3c8d751 to
fbeafa9
Compare
jmaupetit
left a comment
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.
Looks amazing!
- This feature is not documented in the LRS specification?
- Should we consider rule-based forwarding to filter which statement should be forwarded to which LRS?
src/ralph/api/forwarding.py
Outdated
| min_anystr_length = 1 | ||
|
|
||
| url: AnyUrl | ||
| is_active: Literal[True] |
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.
Why are you using a Literal ?
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.
The idea is to consider forwarding configurations that have a value other than True as invalid and skip those in get_valid_xapi_forwarding.
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.
Updated this part) as we now use pydantic settings management, deactivated forwarding configurations need to be considered valid, thus the is_active field became bool, and we manually skip deactivated forwardings in the get_active_xapi_forwardings method.
tests/api/test_forwarding.py
Outdated
| ), | ||
| ], | ||
| ) | ||
| def test_api_forwarding_get_valid_xapi_forwarding_with_valid_and_invalid_values( |
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 propose a fixture for this test but not sure if this would work. Create a fixture with default values and then you can overwrite the values (for this test is_active to False and also specify which field to ignore, with an input parameter ignored as a list of fields. Maybe it's too overthought ?
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 like the idea) however, I don't find an easy way to achieve it as this test uses lists of variable length containing forwarding configurations. I now tried to split this test into more simple tests to benefit from the hypothesis fixtures. WDYT?
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 think that is a good idea to split into more simple tests indeed. It would strengthen the test viability. If that is good for you, let's go!
Yes, it seems xAPI statement forwarding is not a standard (required) LRS feature.
Great idea) Would simple rules like |
Afterthought: I don't think we'll have to implement this feature in a near future. If this is required, we can use https://github.com/yetanalytics/xapipe |
cd4e496 to
65abc34
Compare
docs/api.md
Outdated
| ### Forwarding statements | ||
|
|
||
| Ralph's API server can be configured to forward xAPI statements it receives to other | ||
| Learning Record Stores. |
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.
On line 2 of this document, could you replace "LRS" with "Learning Record Store (LRS)" and use here the "LRS" acronym. Just for the documentation consistency 😉
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.
Good Idea) Thanks) update this part with "LRSes")
tests/api/test_forwarding.py
Outdated
| def test_api_forwarding_forward_xapi_statements_with_unsuccessful_request( | ||
| monkeypatch, caplog, statements, config | ||
| ): | ||
| """Tests the `forward_xapi_statements` function should log the the error if the |
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.
| """Tests the `forward_xapi_statements` function should log the the error if the | |
| """Tests the `forward_xapi_statements` function should log the error if the |
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.
Well spotted) Thanks) updated this part)
tests/api/test_statements_post.py
Outdated
| url="http://localhost:8101/xAPI/statements/", | ||
| is_active=True, | ||
| basic_username="ralph", | ||
| basic_password="admin", | ||
| max_retries=1, | ||
| timeout=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.
Could it be (an) input configuration parameter(s) ?
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.
Good point) Indeed we could define this part using hypothesis; however, I'm hesitating as now the test has changed and already contains nine arguments.
The ES backend query_statements_by_ids method should only search for documents under the specified index and not in the whole ES database. We also test this behaviour for the Mongo database to avoid future surprises.
f2c75e1 to
15260fb
Compare
15260fb to
71f9a1b
Compare
jmaupetit
left a comment
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.
9bcb356 to
b43c4c0
Compare
jmaupetit
left a comment
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.
We want to support xAPI statement forwarding to make ralph able to forward statements it receives to other Learning Record Stores. For now, we only support forwarding statements using HTTP basic auth.
2564871 to
92f53e7
Compare


Purpose
We want to support xAPI statement forwarding to make ralph able to
forward statements it receives to other Learning Record Stores.
For now, we only support forwarding statements using HTTP basic auth.
Proposal