Skip to main content

Rewards API:latest

This latest version of rewards api has some very major changes. The main changes has been introduced in the areas of streaming and endpoint response body formats and intodcuing newer endpoints and deprecating old ones.

How to install and run this repo

This latest API is dependent on rewards_experimental and rewards_envs packages. So first please install the following two packages by typing:

pip install rewards-experimental
pip install rewards-envs

After this clone the repository and go inside the repository.

git clone -b latest https://github.com/rewards-ai/rewards-api.git

This will clone the latest branch of the API. Please make sure you have flask and some other flask related third-party library installed. If not you can install them by:

pip install flask flask_cors flasgger

After this you can run the start the server by typing:

PYTHONPATH=. python3 rewards_api/main.py

API endpoints requests and responses

Here we explain the different API endpoints that rewards-api provides and the expected work it does under the hood and the responses body it provides.

/api/v1/create_session

Creates a new session for the user to carry out different experiments. It expects the following request parameters

  • session_id : The name of the session to be created (must be unique)

Response body looks like this

{
    "status": 200,
    "session_id": "some-session-name",
    "session_creation_date": "2023-04-21",
    "session_creation_time": "10:21:10.414299",
    "dir_paths": {
        "session_root_dir": "path for.rewards_ai",
        "saved_models_dir": "path for session_saved_models"
    },
    "json_paths": {
        "training_metrics": "path for training_metrics.json",
        "evaluation_metrics": "path for evaluation_metrics.json",
        "model_history": "path for model_history.json"
    }
}

/api/v1/delete_session

Deletes the mentioned session. It expects the following request parameters

  • session_id : The name of the session

/api/v1/write_env_params

Writes the environment parameters. It writes env_params.json which looks something like this.

{
  "environment_name": "car-race",
  "environment_world": 2,
  "mode": "training",
  "car_speed": 20
}

/api/v1/write_agent_parameters

After creating the first model it will make provide a response which looks something like this.

{
    "last_created": {
        "date": "2023-04-21",
        "time": "10:21:10.431062",
        "loss": "mse",
        "optimizer": "adam",
        "gamma": 90,
        "epsilon": 20,
        "model_config": "[[5,49],[49,3]]"
    },
    "last_trained": {}
}

This writes the agent parameters inside the required default path. This looks something like this

{
  "model_configuration": "[[5,49],[49,3]]",
  "learning_rate": 60,
  "loss_fn": "mse",
  "optimizer": "adam",
  "gamma": 90,
  "epsilon": 20,
  "num_episodes": 700
}

/api/v1/stream

This starts the training streaming process. After the training fininshes or after the training is exited, it will write the model_history.json something like this, so that it can be accesed

{
  "last_created": {
    "date": "2023-04-21",
    "time": "09:51:10.808311",
    "loss": "mse",
    "optimizer": "adam",
    "gamma": 90,
    "epsilon": 20,
    "model_config": "[[5,62],[62,3]]"
  },
  "last_trained": {
    "date": "2023-04-21",
    "time": "09:51:37.416074",
    "record": 9,
    "scores": [
      9,
      8
    ],
    "mean_scores": [
      9,
      8.5
    ]
  }
}

Some important TODOs

  • Creat the evaluation stream.

    • evaluation endpoint must recieve the following request arguments:

      • session_id The id of the session

      • mode It can be training or evaluation

      • track_num Which track environment to evaluate on

      This should write the following json on the evaluation_metrics.json. :

      {
          "session_id" : "session_id",
          "training": { 
              "total_elapsed_time" : "total_elapsed_time", 
              "1": {
                  "num_trials" : 5, 
                  "record" : 120
              }, 
              "2": {
                  "num_trials" : 5, 
                  "record" : 120
              }, 
              "3": {
                  "num_trials" : 5, 
                  "record" : 120
              }
          }, 
          "evaluation": {
              "total_elapsed_time" : "total_elapsed_time", 
              "1": {
                  "num_trials" : 5, 
                  "record" : 120
              } 
          } 
      }
      

           This endpoint is already created. We need to integrate this to react.

  • Need to show all the information about the training. In the Your models section we will need to show the following things

    • The date and time of creation and latest train

    • The model configurations

    • The latest record the model made

    • A very small graph of the training (optional)

  • UI Changes for integrating other inputs too

  • Support for re-training the same model in different environments

  • Support for pushing the model to AWS

  • Leaderboard

  • Documentation support (optional)

  • Change the temp.json path to the training_metrics.json. The path will also be given when the session is created. So there will be no issue for react to create that inside assets.

  • Authentication

Metadata

Release files for rewards-api 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rewards-api 0.1.4
File Size Uploaded Provenance Actions
rewards_api-0.1.4.tar.gz 14.5 kB Without provenance Details for rewards_api-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rewards-api 0.1.4
File Interpreter ABI Platform Actions
rewards_api-0.1.4-py3-none-any.whl Python 3 none any Details for rewards_api-0.1.4-py3-none-any.whl

Total release size: 29.3 kB

Release files / rewards_api-0.1.4.tar.gz

Download URL rewards_api-0.1.4.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
40cb48bc45e494da3bde90922df17696eda9810613512913fed7b4b869d703c0
BLAKE2b-256 checksum
How to use checksums
b7f2a8fbf98676dcaffbfb9d6ce5274de5fd1f15304d6d5bdbaa55088270bbc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / rewards_api-0.1.4-py3-none-any.whl

Download URL rewards_api-0.1.4-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fc706ef29b0424e95b2dda39e79d965689aa0321a56ff4720042cf80b0986f3
BLAKE2b-256 checksum
How to use checksums
1317df609dd56c14bd201292d24fc3d1f19f73b0b22bf27431123555fa5f0c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for rewards-api 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page