Metadata-Version: 2.1
Name: ralph-malph
Version: 4.2.0
Summary: Ralph, the ultimate Learning Record Store (and more!) for your learning analytics.
Author-email: "Open FUN (France Université Numérique)" <fun.dev@fun-mooc.fr>
License: MIT License
        
        Copyright (c) 2020-present France Université Numérique
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://openfun.github.io/ralph/
Project-URL: Bug Tracker, https://github.com/openfun/ralph/issues
Project-URL: Changelog, https://github.com/openfun/ralph/blob/main/CHANGELOG.md
Project-URL: Repository, https://github.com/openfun/ralph
Keywords: LRS,Analytics,xAPI,Open edX
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: importlib-metadata<8.0,>=7.0.1
Requires-Dist: langcodes>=3.2.0
Requires-Dist: pydantic[dotenv,email]<2.0,>=1.10.0
Requires-Dist: rfc3987>=1.3.0
Provides-Extra: backend-clickhouse
Requires-Dist: clickhouse-connect[numpy,pandas]<0.6; extra == "backend-clickhouse"
Requires-Dist: python-dateutil>=2.8.2; extra == "backend-clickhouse"
Provides-Extra: backend-es
Requires-Dist: elasticsearch[async]>=8.0.0; extra == "backend-es"
Provides-Extra: backend-ldp
Requires-Dist: ovh>=1.0.0; extra == "backend-ldp"
Requires-Dist: requests>=2.0.0; extra == "backend-ldp"
Provides-Extra: backend-lrs
Requires-Dist: httpx<0.25.0; extra == "backend-lrs"
Provides-Extra: backend-mongo
Requires-Dist: motor[srv]>=3.3.0; extra == "backend-mongo"
Requires-Dist: pymongo[srv]>=4.0.0; extra == "backend-mongo"
Requires-Dist: python-dateutil>=2.8.2; extra == "backend-mongo"
Provides-Extra: backend-s3
Requires-Dist: boto3>=1.24.70; extra == "backend-s3"
Requires-Dist: botocore>=1.27.71; extra == "backend-s3"
Requires-Dist: requests-toolbelt>=1.0.0; extra == "backend-s3"
Provides-Extra: backend-swift
Requires-Dist: python-keystoneclient>=5.0.0; extra == "backend-swift"
Requires-Dist: python-swiftclient>=4.0.0; extra == "backend-swift"
Provides-Extra: backend-ws
Requires-Dist: websockets>=10.3; extra == "backend-ws"
Provides-Extra: backends
Requires-Dist: ralph-malph[backend-clickhouse,backend-es,backend-ldp,backend-lrs,backend-mongo,backend-s3,backend-swift]; extra == "backends"
Provides-Extra: ci
Requires-Dist: twine==5.0.0; extra == "ci"
Provides-Extra: cli
Requires-Dist: bcrypt>=4.0.0; extra == "cli"
Requires-Dist: click>=8.1.0; extra == "cli"
Requires-Dist: click-option-group>=0.5.0; extra == "cli"
Requires-Dist: sentry-sdk[fastapi]>=1.9.0; extra == "cli"
Provides-Extra: dev
Requires-Dist: anyio<4.3.1; extra == "dev"
Requires-Dist: black==24.3.0; extra == "dev"
Requires-Dist: cryptography==42.0.5; extra == "dev"
Requires-Dist: factory-boy==3.3.0; extra == "dev"
Requires-Dist: hypothesis<6.92.0; extra == "dev"
Requires-Dist: logging-gelf==0.0.32; extra == "dev"
Requires-Dist: mike==2.0.0; extra == "dev"
Requires-Dist: mkdocs==1.5.3; extra == "dev"
Requires-Dist: mkdocs-click==0.8.1; extra == "dev"
Requires-Dist: mkdocs-material==9.5.17; extra == "dev"
Requires-Dist: mkdocstrings[python-legacy]==0.24.3; extra == "dev"
Requires-Dist: moto==5.0.5; extra == "dev"
Requires-Dist: mypy==1.9.0; extra == "dev"
Requires-Dist: neoteroi-mkdocs==1.0.5; extra == "dev"
Requires-Dist: pyfakefs==5.4.0; extra == "dev"
Requires-Dist: pymdown-extensions==10.7.1; extra == "dev"
Requires-Dist: pytest<8.0.0; extra == "dev"
Requires-Dist: pytest-cov==5.0.0; extra == "dev"
Requires-Dist: pytest-httpx<0.23.0; extra == "dev"
Requires-Dist: requests-mock==1.12.1; extra == "dev"
Requires-Dist: responses==0.24.1; extra == "dev"
Requires-Dist: ruff==0.3.5; extra == "dev"
Requires-Dist: types-python-dateutil==2.9.0.20240316; extra == "dev"
Requires-Dist: types-python-jose==3.3.4.20240106; extra == "dev"
Requires-Dist: types-requests<2.31.0.20240407; extra == "dev"
Requires-Dist: types-cachetools==5.3.0.7; extra == "dev"
Provides-Extra: lrs
Requires-Dist: bcrypt==4.1.2; extra == "lrs"
Requires-Dist: fastapi==0.110.1; extra == "lrs"
Requires-Dist: cachetools==5.3.3; extra == "lrs"
Requires-Dist: httpx<0.25.0; extra == "lrs"
Requires-Dist: sentry_sdk==1.44.1; extra == "lrs"
Requires-Dist: python-jose==3.3.0; extra == "lrs"
Requires-Dist: uvicorn[standard]==0.29.0; extra == "lrs"
Provides-Extra: full
Requires-Dist: ralph-malph[backends,cli,lrs]; extra == "full"


<p align="center">
  <a href="https://openfun.github.io/ralph"><img src="https://raw.githubusercontent.com/openfun/logos/main/ralph/ralph-color-dark.png" alt="Ralph logo" width="400"></a>
</p>

<p align="center">
    <em>Ralph, the ultimate Learning Record Store (and more!) for your learning analytics</em>
</p>

<p align="center">
<a href="https://circleci.com/gh/openfun/ralph/tree/main">
    <img src="https://img.shields.io/circleci/build/gh/openfun/ralph/main?label=Tests&logo=circleci" alt="Tests Status">
</a>
<a href="https://pypi.org/project/ralph-malph">
    <img src="https://img.shields.io/pypi/v/ralph-malph?label=PyPI+package" alt="PyPI package version">
</a>
<a href="https://pypi.org/project/ralph-malph">
    <img src="https://img.shields.io/pypi/pyversions/ralph-malph?label=Python" alt="Python versions supported">
</a>
<a href="https://hub.docker.com/r/fundocker/ralph/tags">
    <img src="https://img.shields.io/docker/v/fundocker/ralph/latest?label=Docker+image" alt="Docker image version">
</a>
<a href="https://hub.docker.com/r/openfuncharts/ralph/tags">
    <img src="https://img.shields.io/docker/v/openfuncharts/ralph?label=Helm+chart&color=blue" alt="Helm chart version">
</a>
<a href="https://discord.gg/vYx6YWxJCS">
    <img src="https://img.shields.io/discord/1082704478463082496?label=Discord&logo=discord&style=shield" alt="Discord">
</a>
</p>

---

**Documentation**: [https://openfun.github.io/ralph](https://openfun.github.io/ralph)

**Source Code**: [https://github.com/openfun/ralph](https://github.com/openfun/ralph)

---

Ralph is a toolbox for your learning analytics, it can be used as a:

- **[LRS](https://en.wikipedia.org/wiki/Learning_Record_Store)**, a HTTP API server to collect xAPI statements (learning events), following the [ADL LRS standard](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#partthree)
- **command-line interface** (CLI), to build data pipelines the UNIX-way™️,
- **library**, to fetch learning events from various backends, (de)serialize or
    convert them from and to various standard formats such as
    [xAPI](https://adlnet.gov/projects/xapi/), or
    [openedx](https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/index) html

## ⚡️ Quick start guide: Run the LRS server

> Preliminary notes:
>
> 1. [`curl`](https://curl.se), [`jq`](https://stedolan.github.io/jq/) and
>    [`docker compose`](https://docs.docker.com/compose/) are required to run
>    some commands of this tutorial. Make sure they are installed first.
>
> 2. In order to run the Elasticsearch backend locally on GNU/Linux operating
>    systems, ensure that your virtual memory limits are not too low and
>    increase them (temporally) if needed by typing this command from your
>    terminal (as `root` or using `sudo`): `sysctl -w vm.max_map_count=262144`
>
> Reference:
> https://www.elastic.co/guide/en/elasticsearch/reference/master/vm-max-map-count.html

To bootstrap a test environment on your machine, clone this project first and
run the `bootstrap` Makefile target:

```bash
make bootstrap
```

This command will create required `.env` file (you may want to edit it for your
test environment), build the Ralph's Docker image and start a single node
Elasticsearch cluster _via_ Docker compose.

You can check the `elasticsearch` service status using the `status` helper:

```bash
make status # This is an alias for: docker compose ps
```

You may now start the LRS server using:

```bash
make run
```

The server should be up and running at
[http://localhost:8100](http://localhost:8100). You can check its status using
the heartbeat probe:

```bash
curl http://localhost:8100/__heartbeat__
```

The expected answer should be:

```json
{"database":"ok"}
```

If the database status is satisfying, you are now ready to send xAPI statements
to the LRS:

```bash
gunzip -c data/statements.json.gz | \
head -n 100 | \
jq -s . | \
curl -Lk \
    --user ralph:secret \
    -X POST \
    -H "Content-Type: application/json" \
    -d @- \
    http://localhost:8100/xAPI/statements/
```

The command above fetches one hundred (100) example xAPI statements from our
[Potsie](https://github.com/openfun/potsie) project and sends them to the LRS
using `curl`.

You can get them back from the LRS using `curl` to query the
`/xAPI/statements/` endpoint:

```bash
curl -s \
    --user ralph:secret \
    -H "Content-Type: application/json" \
    http://localhost:8100/xAPI/statements/ \ |
jq
```

> Note that using `jq` is optional in this case, it is used to improve response
> readability. It is not required to install it to run this snippet.

## ⚡️ Quick start guide: Manipulate data with the CLI

### With the Docker image

Ralph is distributed as a [Docker
image](https://hub.docker.com/repository/docker/fundocker/ralph). If
[Docker](https://docs.docker.com/get-docker/) is installed on your machine, it
can be pulled from DockerHub:

```bash
docker run --pull always --rm fundocker/ralph:latest ralph --help
```

### With the Python package

Ralph is distributed as a standard python package; it can be installed _via_
`pip` or any other python package manager (_e.g._ Poetry, Pipenv, etc.):

```bash
# Install the full package
pip install \
    ralph-malph[full]

# Install only the core package (library usage without backends, CLI and LRS)
pip install ralph-malph
```

If you installed the full package (including the CLI, LRS and supported
backends), the `ralph` command should be available in your `PATH`. Try to
invoke the program usage thanks to the `--help` flag:

```bash
ralph --help
```

You should see a list of available commands and global flags for `ralph`. Note
that each command has its own usage that can be invoked _via_:

```bash
ralph COMMAND --help
```

> You should substitute `COMMAND` by the target command, _e.g._ `list`, to see
> its usage.

## Migrating

Some major version changes require updating persistence layers. Check out the [migration guide](https://github.com/openfun/ralph/blob/main/UPGRADE.md) for more information.

## Contributing

This project is intended to be community-driven, so please, do not hesitate to
get in touch if you have any question related to our implementation or design
decisions.

We try to raise our code quality standards and expect contributors to follow
the recommendations from our
[handbook](https://handbook.openfun.fr).

## Useful commands


You can explore all available rules using:

```bash
make help
```
but here are some of them:

- Bootstrap the project: `make bootstrap`
- Run tests: `make test`
- Run all linters: `make lint`
- If you add new dependencies to the project, you will have to rebuild the Docker
image (and the development environment): `make down && make bootstrap`

## License

This work is released under the MIT License (see [LICENSE](./LICENSE.md)).
