PathmindAI / nativerl

Train reinforcement learning agents using AnyLogic or Python-based simulations
Apache License 2.0
19 stars 4 forks source link

MA can analyze pm_single, pm_multi, py_single models #467

Closed kepricon closed 3 years ago

kepricon commented 3 years ago

The main purpose of this PR is to make MA can analyze types of Python models. We have assumed that MA analyzes only for Gym single model(py_single). This PR makes MA can analyze other types of python models(Pathmind Simulation model, pm_single, pm_multi) instead of relying on user's flag when uploading model.

kepricon commented 3 years ago

python_examples.zip Here's my test model that includes py_single, pm_single, pm_multi.

py_single (Gym)

env=examples.mouse.single_agent_mouse_env.MouseAndCheese

curl -i -XPOST -H "X-PM-API-TOKEN: 11202253-5709-4eb7-9102-f87122314464" -F 'file=@/home/kepricon/Downloads/python_examples/python_examples.zip' -F 'projectId=500' -F 'env=examples.mouse.single_agent_mouse_env.MouseAndCheese' -F 'start=TRUE' http://localhost:8081/py/upload

pm_single (Pathmind Simulation)

env=examples.mouse.mouse_env_pathmind.MouseAndCheese

curl -i -XPOST -H "X-PM-API-TOKEN: 11202253-5709-4eb7-9102-f87122314464" -F 'file=@/home/kepricon/Downloads/python_examples/python_examples.zip' -F 'projectId=500' -F 'env=examples.mouse.mouse_env_pathmind.MouseAndCheese' -F 'start=TRUE' http://localhost:8081/py/upload

pm_multi (Pathmind Simulation)

env=env=examples.mouse.multi_mouse_env_pathmind.MultiMouseAndCheese

curl -i -XPOST -H "X-PM-API-TOKEN: 11202253-5709-4eb7-9102-f87122314464" -F 'file=@/home/kepricon/Downloads/python_examples/python_examples.zip' -F 'projectId=500' -F 'env=examples.mouse.multi_mouse_env_pathmind.MultiMouseAndCheese' -F 'start=TRUE' http://localhost:8081/py/upload
kepricon commented 3 years ago

wrong class name

env=examples.mouse.mouse_env_pathmind.MouseAndCheese1

kepricon@kepricon-G732LXS:~/git/pathmind-webapp/pathmind-api$ curl -i -XPOST -H "X-PM-API-TOKEN: 11202253-5709-4eb7-9102-f87122314464" -F 'file=@/home/kepricon/Downloads/python_examples/python_examples.zip' -F 'projectId=500' -F 'env=examples.mouse.mouse_env_pathmind.MouseAndCheese1' http://localhost:8081/py/upload
HTTP/1.1 100 

HTTP/1.1 400 
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: http://localhost:8080/uploadModelError/module%20'examples.mouse.mouse_env_pathmind'%20has%20no%20attribute%20'MouseAndCheese1'
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: text/plain;charset=UTF-8
Content-Length: 77
Date: Fri, 29 Oct 2021 00:12:15 GMT
Connection: close

module 'examples.mouse.mouse_env_pathmind' has no attribute 'MouseAndCheese1'

wrong package name

env=examples.mouse.mouse_env_pathmind1.MouseAndCheese

kepricon@kepricon-G732LXS:~/git/pathmind-webapp/pathmind-api$ curl -i -XPOST -H "X-PM-API-TOKEN: 11202253-5709-4eb7-9102-f87122314464" -F 'file=@/home/kepricon/Downloads/python_examples/python_examples.zip' -F 'projectId=500' -F 'env=examples.mouse.mouse_env_pathmind1.MouseAndCheese' http://localhost:8081/py/upload
HTTP/1.1 100 

HTTP/1.1 400 
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: http://localhost:8080/uploadModelError/No%20module%20named%20'examples.mouse.mouse_env_pathmind1'
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: text/plain;charset=UTF-8
Content-Length: 52
Date: Fri, 29 Oct 2021 00:12:25 GMT
Connection: close

No module named 'examples.mouse.mouse_env_pathmind1'
slinlee commented 3 years ago

I really like the validation checks and error messages. Nice work. This will make the python uploading process a lot easier for users.