Package: rewards-api
Rewards API:latestThis 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 repoThis latest API is dependent onrewards_experimentalandrewards_envspackages. So first please install the following two packages by typing:pipinstallrewards-experimental
pipinstallrewards-envsAfter this clone the repository and go inside the repository.gitclone-blatesthttps://github.com/rewards-ai/rewards-api.gitThis will clone the latest branch of the API. Please make sure you haveflaskand some other flask related third-party library installed. If not you can install them by:pipinstallflaskflask_corsflasggerAfter this you can run the start the server by typing:PYTHONPATH=.python3rewards_api/main.pyAPI endpoints requests and responsesHere 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_sessionCreates a new session for the user to carry out different experiments. It expects the following request parameterssession_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_sessionDeletes the mentioned session. It expects the following request parameterssession_id: The name of the session/api/v1/write_env_paramsWrites the environment parameters. It writesenv_params.jsonwhich looks something like this.{"environment_name":"car-race","environment_world":2,"mode":"training","car_speed":20}/api/v1/write_agent_parametersAfter 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/streamThis starts the training streaming process. After the training fininshes or after the training is exited, it will write themodel_history.jsonsomething 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 TODOsCreat the evaluation stream.evaluation endpoint must recieve the following request arguments:session_idThe id of the sessionmodeIt can betrainingorevaluationtrack_numWhich track environment to evaluate onThis should write the following json on theevaluation_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 theYour modelssection we will need to show the following thingsThe date and time of creation and latest trainThe model configurationsThe latest record the model madeA very small graph of the training (optional)UI Changes for integrating other inputs tooSupport for re-training the same model in different environmentsSupport for pushing the model to AWSLeaderboardDocumentation support (optional)Change thetemp.jsonpath to thetraining_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