Coder Social home page Coder Social logo

gama-platform / gama.clients Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 8.32 MB

Gama Client - Repository dedicated to development of different Gama Client and the corresponding GAMA API

JavaScript 64.15% HTML 18.90% CSS 4.81% Dockerfile 0.76% C 0.16% C++ 0.16% Java 0.20% Python 9.65% GAML 1.22%

gama.clients's People

Contributors

agrignard avatar benoitgaudou avatar hqnghi88 avatar lesquoyb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lddtoan

gama.clients's Issues

Confusing naming of "client" repositories

We currently have two repositories:

Now this is confusing !

  1. If gama.client is the repository for developing different GAMA clients, why is the python version in its own repository ?
  2. If the python version is called Gama Client, how do we distinguish this from the other clients ?
  3. Why do we have a different pattern of naming the repositories ? gama DOT client vs. gama MINUS client ... ?

It needs to be changed as soon as possible (i.e. before too many people begin to use these clients) so that we prevent more mess to appear.

  1. If we go for a repository gathering all the clients, we merge gama-client-python into it and call the repository gama.clients or gama.server.clients, with sub-folders in it corresponding to the different languages. This solution has my favor for a question of management (and also because it would provide one place where the API of the server is documented, etc. )
  2. If we go for separate repositories (a bit of a waste of energy, but I'm not developing these so I can't really choose), then let's name them consistently gama.client.python, gama.client.json... etc. We might keep a gama.clients or gama.server.clients around for common things if necessary (but I'm not sure).
  3. The naming of these clients should also be consistent and not Gama Client alone.

@lesquoyb @hqnghi88 I think you are the two more concerned here. Can you make sure one of the first 2 options can be done quickly ? It is absolutely essential that we do not maintain messy situations like this one too long.

Client not running with customized model

I am trying to make the client architecture working with my own model (that use to work in the 1.8)

In order to plug it to Gama

  1. Clone this repo: https://github.com/VCityTeam/UD_ReAgent_ABM/
  2. In gama.client comment this lines:
var ABSOLUTE_PATH_TO_GAMA = '/Users/hqn88/git/';
var modelPath = ABSOLUTE_PATH_TO_GAMA + 'gama/msi.gama.models/models/Tutorials/Road Traffic/models/Model 05.gaml';
var experimentName = 'road_traffic';
var species1Name = 'people';
var attribute1Name = 'objective';
var species2Name = 'building';
var attribute2Name = 'type';

and uncomment this one (be sure it's poiting to the right folder where you have downloaded ReAgent

const modelPath = '/Users/arno/Projects/GitHub/UD_ReAgent_ABM/ReAgent/models/Gratte_Ciel_Demo.gaml';
const experimentName = 'Demo';
const species1Name = 'people';
const attribute1Name = 'type';
//const species2Name = 'building';
//const attribute2Name = 'type';
  1. run gama headless
  2. Open index.html

You should see this:
Screenshot 2023-02-21 at 11 42 22

After few iteration I have the following error in my browser console


> Error: J"... is not valid JSON
    at JSON.parse (<anonymous>)
    at Object.callback (gama_client.js:93:20)
    at wSocket.onmessage (GAMA.js:53:48)

index.html not rendering or showing what gama_client.js is supposed to show

Hi great people!

Thanks for investing in my issues.

I found the GAMA headless server https://gama-platform.org/wiki/HeadlessServer#hello-world-visualization-in-mapbox and tried to run a copy on my local machine. I had not been successful yet (elaboration below). I assume this server and the JS client allow me to run and show GAMA simulation results on the web. Have there been any successful examples deployed on the web that I can click and see?

For the issue I ran into, here is an elaboration:

I am using a MacOS M1 Chip computer, with a M1 chip GAMA installation. I followed the steps in this webpage: https://gama-platform.org/wiki/HeadlessServer#hello-world-visualization-in-mapbox to start a headless server and try to run the HellowWorld Visualization in Mapbox (JS client).
 
To start the server, I entered the following codes in my terminal:

cd Gama.app/Contents/headless
bash gama-headless.sh -socket 6868

The server seems to start fine:
Screen Shot 2023-02-08 at 11 31 06 AM

Then, I go to the gama.client.js to modify the path of the library model file (highlighted). The path is found by opening the specific library model in local GAMA software, going to File -> Properties -> Location.

I uncommented the example that is on road traffic and commented out all other examples (see below).

Screen Shot 2023-02-08 at 11 32 58 AM

Then in the same gama_client.js, I modify the local path to Websocket to ws://localhost:6868/, because that is the port in the server.

Screen Shot 2023-02-08 at 11 35 00 AM

That are ALL the changes I made. Then, I opened the index.html file in my browser and it shows this: The base map is rendered correctly, but no simulation is rendered (I am expecting something from gama_client.js).

Screen Shot 2023-02-08 at 11 38 57 AM

Once I loaded the index.html, the terminal says:
0:0:0:0:0:0:0:1 entered the room!
 
And there are no other error messages. I am not sure how to interpret the error warnings in the browser inspector.
 
I tried the following approaches, and it did not solve the problem:
-       Change to a different port
-       Change to a different html (e.g., syntax.html)
-       Change to a different browser
 
Any idea of what to go next will be appreciated because I am clueless. Thanks!

Headless server/Python wrapper stuck with multiple requests

Describe the bug
Using python to run a gama model on a local gama headless sever 5 times, it keep running with no more respond after 2-3 model loaded.

To Reproduce
The python code:

import asyncio
from typing import Dict

from gama_client.base_client import GamaBaseClient

load_command_secret_id = 123
other_id = 1


async def message_handler(message: Dict):
    if "command" in message.keys() and "my_secret_id" in message['command'] and message['command']["my_secret_id"] == load_command_secret_id:
        print("\nanswer for the load command we wanted to retrieve received:", message)
    else:
        print("\nother kind of message", message)

async def main(gaml_file, experiment):
    client = GamaBaseClient("localhost", 6868, message_handler)
    await client.connect(False)
    
    await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})
    await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})
    await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})
    await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})
    await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})
    # # this is the command we want to retrieve the answer to
    # await client.load(gaml_file, experiment, additional_data={"my_secret_id": load_command_secret_id})

    # # this is not the command we want to retrieve
    # await client.load(gaml_file, experiment, additional_data={"my_secret_id": other_id})

    while True:
        pass


gaml_file = r"C:\Users\DUNG DO\Gama_Workspace\test\models\test.gaml"
experiment = "exp"

if __name__ == "__main__":
    asyncio.run(main(gaml_file=gaml_file, experiment=experiment))

Gama file at "C:\Users\DUNG DO\Gama_Workspace\test\models\test.gaml":


model test

global
{
	reflex stop when: cycle > 5
	{
		do pause;
	}
	reflex save_test
	{
		save cycle to: "C:/Test/Output/test1.txt" format: txt;
	}
}

experiment exp type: gui until:cycle >1
{
	output
	{
		display "display"
		{
			chart "log"
			{
				data "log" value: log(cycle+1);
			}
		}
		
	}
}

Screenshots
headless

Information:

  • OS: Window 11 Pro
  • GAMA version: 1.9

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.