GithubHelp home page GithubHelp logo

standardgalactic / cartpole-py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/cartpole-py

0.0 2.0 0.0 71 KB

A cart and pole simulator.

License: MIT License

Dockerfile 10.16% Python 89.84%

cartpole-py's Introduction

cartpole-py

A simple Python example that creates a training simulator for Bonsai. It simulates a cartpole balancing environment. The SimulatorSession interface is implemented to demonstrate using bonsai-common, a Python framework for interfacing with the Bonsai platform.

Prerequisites

Simulators need two environment variables set to be able to attach to the platform.

The first is SIM_ACCESS_KEY. You can create one from the Account Settings page. You have one chance to copy the key once it has been created. Make sure you don't enter the ID.

The second is SIM_WORKSPACE. You can find this in the URL after /workspaces/ once you are logged in to the platform.

There is also an optional SIM_API_HOST key, but if it is not set it will default to https://api.bons.ai.

If you're launching your simulator from the command line, make sure that you have these two environment variables set. If you like, you could use the following example Bash script:

export SIM_WORKSPACE=<your-workspace-id>
export SIM_ACCESS_KEY=<your-access-key>

You will need to install support libraries prior to running. Our demos depend on bonsai-common. This library will need to be installed from source.

pip3 install git+https://github.com/microsoft/bonsai-common

Running from your local Python environment

python3 cartpole.py

When you run this, the simulator registers with your Bonsai workspace. This adds an unmanaged entry to the list of simulators in your workspace portal that can be used to train brains while executing the simulation in your local Python environment.

Building Demo Dockerfile

docker build -t <IMAGE_NAME> -f Dockerfile ../../

Run Dockerfile local

docker run --rm -it -e SIM_ACCESS_KEY="<ACCESS_KEY>" -e SIM_API_HOST="<TARGET>" -e SIM_WORKSPACE="<WORKSPACE>" <IMAGE_NAME>

This adds an unmanaged entry to the list of simulators in your workspace portal that can be used to train brains while executing the simulation in your container.

How to push to ACR

az login # (Is not necessary if you are already up to date or logged in recently)
az acr login --subscription <SUBSCRIPTION_ID> --name <ACR_REGISTRY_NAME>
docker tag <IMAGE_NAME> <ACR_REGISTRY_NAME>.azurecr.io/bonsai/<IMAGE_NAME>
docker push <ACR_REGSITRY_NAME>.azurecr.io/bonsai/<IMAGE_NAME>

Example run Dockerfile

docker build -t cartpole -f Dockerfile ../../
docker run --rm -it -e SIM_ACCESS_KEY="111" -e SIM_API_HOST="https://api.bons.ai" -e SIM_WORKSPACE="123"

Example push to ACR(Assuming you logged in)

docker build -t cartpole -f Dockerfile ../../
docker tag cartpole bonsaisimpreprod.azurecr.io/bonsai/cartpole
docker push bonsaisimpreprod.azurecr.io/bonsai/cartpole

Once your image is registered in the ACR you can switch the web and click Add Simulator from the left hand navigation. Enter the URL to the image there and give it a name. Use this name in your Inkling to refer to the simulator.

Microsoft Open Source Code of Conduct

This repository is subject to the Microsoft Open Source Code of Conduct.

cartpole-py's People

Contributors

nmann4 avatar forresttrepte avatar mikest avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.