Skip to content

Conversation

@SergioSim
Copy link
Collaborator

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

  • Add xAPI statement forwarding

@SergioSim SergioSim force-pushed the add-statement-forwarding branch from 3c8d751 to fbeafa9 Compare June 20, 2022 13:03
Copy link
Contributor

@jmaupetit jmaupetit left a 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?

min_anystr_length = 1

url: AnyUrl
is_active: Literal[True]
Copy link
Contributor

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 ?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

),
],
)
def test_api_forwarding_get_valid_xapi_forwarding_with_valid_and_invalid_values(
Copy link
Contributor

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 ?

Copy link
Collaborator Author

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?

Copy link
Contributor

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!

@SergioSim
Copy link
Collaborator Author

This feature is not documented in the LRS specification?

Yes, it seems xAPI statement forwarding is not a standard (required) LRS feature.

Should we consider rule-based forwarding to filter which statement should be forwarded to which LRS?

Great idea) Would simple rules like (path_to_field, exact_value_match) be sufficient?

@jmaupetit
Copy link
Contributor

Great idea) Would simple rules like (path_to_field, exact_value_match) be sufficient?

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

@SergioSim SergioSim force-pushed the add-statement-forwarding branch 3 times, most recently from cd4e496 to 65abc34 Compare June 28, 2022 17:24
docs/api.md Outdated
### Forwarding statements

Ralph's API server can be configured to forward xAPI statements it receives to other
Learning Record Stores.
Copy link
Contributor

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 😉

Copy link
Collaborator Author

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")

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""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

Copy link
Collaborator Author

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)

Comment on lines 268 to 468
url="http://localhost:8101/xAPI/statements/",
is_active=True,
basic_username="ralph",
basic_password="admin",
max_retries=1,
timeout=10,
Copy link
Contributor

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) ?

Copy link
Collaborator Author

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.
@SergioSim SergioSim force-pushed the add-statement-forwarding branch 3 times, most recently from f2c75e1 to 15260fb Compare August 31, 2022 17:56
@SergioSim SergioSim force-pushed the add-statement-forwarding branch from 15260fb to 71f9a1b Compare September 1, 2022 06:46
Copy link
Contributor

@jmaupetit jmaupetit left a comment

Choose a reason for hiding this comment

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

That's brilliant! Tests should have been tricky to write 😍

@SergioSim SergioSim force-pushed the add-statement-forwarding branch from 9bcb356 to b43c4c0 Compare September 1, 2022 12:09
Copy link
Contributor

@jmaupetit jmaupetit left a comment

Choose a reason for hiding this comment

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

Merge this! Thx!

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.
@SergioSim SergioSim force-pushed the add-statement-forwarding branch from 2564871 to 92f53e7 Compare September 2, 2022 09:11
@SergioSim SergioSim merged commit 7645139 into openfun:master Sep 2, 2022
@SergioSim SergioSim deleted the add-statement-forwarding branch September 2, 2022 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants